$ ./mjs/build/mjs poc.js
=================================================================
==109503==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x607000000150 at pc 0x55d8ef005f6d bp 0x7ffe7d357b00 sp 0x7ffe7d357af0
READ of size 8 at 0x607000000150 thread T0
#0 0x55d8ef005f6c in mjs_array_length src/mjs_array.c:83
#1 0x55d8ef005f6c in mjs_array_push src/mjs_array.c:115
#2 0x55d8ef027dd8 in mjs_execute src/mjs_exec.c:679
#3 0x55d8ef034a05 in mjs_exec_internal src/mjs_exec.c:1073
#4 0x55d8ef034a05 in mjs_exec_file src/mjs_exec.c:1096
#5 0x55d8eeff1909 in main src/mjs_main.c:47
#6 0x7f6cb8331b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
#7 0x55d8eeff2449 in _start (/usr/local/bin/Gmjs+0xe449)
0x607000000150 is located 0 bytes to the right of 80-byte region [0x607000000100,0x607000000150)
allocated by thread T0 here:
#0 0x7f6cb89e3d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
#1 0x55d8ef0527be in gc_new_block src/mjs_gc.c:94
#2 0x55d8ef0527be in gc_alloc_cell src/mjs_gc.c:133
#3 0x55d8ef0527be in new_object src/mjs_gc.c:45
SUMMARY: AddressSanitizer: heap-buffer-overflow src/mjs_array.c:83 in mjs_array_length
Shadow bytes around the buggy address:
0x0c0e7fff7fd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c0e7fff7fe0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c0e7fff7ff0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c0e7fff8000: fa fa fa fa 00 00 00 00 00 00 00 00 00 fa fa fa
0x0c0e7fff8010: fa fa fd fd fd fd fd fd fd fd fd fa fa fa fa fa
=>0x0c0e7fff8020: 00 00 00 00 00 00 00 00 00 00[fa]fa fa fa fa fa
0x0c0e7fff8030: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0e7fff8040: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0e7fff8050: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0e7fff8060: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0c0e7fff8070: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
mJS revision
Commit: b1b6eac
Build platform
Ubuntu 18.04.5 LTS (Linux 5.4.0-44-generic x86_64)
Build steps
Test case
poc.js
Execution steps & Output