Skip to content

Switch statement creates incorrect VM context #3830

@owl337

Description

@owl337
JerryScript revision

d06c3a7

Build platform

Ubuntu 16.04.6 LTS (Linux 4.15.0-99-generic x86_64)

Build steps
 ./tools/build.py --clean --debug --compile-flag=-fsanitize=address \ 
--compile-flag=-m32 --compile-flag=-fno-omit-frame-pointer \
 --compile-flag=-fno-common --compile-flag=-g --strip=off \
 --system-allocator=on --logging=on \
 --linker-flag=-fuse-ld=gold --error-messages=on \
 --profile=es2015-subset --lto=off --stack-limit=50 
Test case
str = '';
 for (j = 0; j < 5; j++)
{
  str += 'A';

  b: for (i = 0; i < 5; i++)
  {
    str += 'B';

    switch (1)
    {
      case 1:
        continue b;
      function f2()
    {
      assert(k > 0);
      assert(i < 10000);

      if(--k == 0)
        {
          return;
        }

      f2();
    }

  k = 17;

  f2();
    }

    str += 'C';
  }

  str += 'D';
}
Output
ASAN:SIGSEGV
=================================================================
==35306==ERROR: AddressSanitizer: SEGV on unknown address 0x00001c25 (pc 0x00001c25 bp 0x00001c25 sp 0xfff1b9a0 T0)
ASAN:SIGSEGV
==35306==AddressSanitizer: while reporting a bug found another one. Ignoring.

Credits: This vulnerability is detected by chong from OWL337.

Metadata

Metadata

Assignees

Labels

bugUndesired behaviourparserRelated to the JavaScript parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions