pcmacdon / jsish

Jsi is a small, C-embeddable javascript interpreter with tightly woven Web and DB support.
https://jsish.org/
MIT License
40 stars 8 forks source link

SEGV src/jsiArray.c:1172 in jsi_ArraySpliceCmd #65

Closed hope-fly closed 2 years ago

hope-fly commented 2 years ago
Jsish revision

Commit: 9fa798e

Version: v3.5.0

Build platform

Ubuntu 18.04.5 LTS (Linux 5.4.0-44-generic x86_64)

Build steps
export CFLAGS='-fsanitize=address'
make
Test case
var myColors = new Array(99999);
var lastElement = myColors.push('yellow');
myColors.push('yellow');
var firstElement = myColors.shift();
myColors.splice('pink');

Execution steps & Output
$ ./jsish/jsish poc.js
/poc.js:5: error: invalid number
ASAN:DEADLYSIGNAL
=================================================================
==825==ERROR: AddressSanitizer: SEGV on unknown address 0x60c0000dc4f0 (pc 0x555a355a5e18 bp 0x7ffcd17c49b0 sp 0x7ffcd17c4960 T0)
==825==The signal is caused by a WRITE memory access.
    #0 0x555a355a5e17 in jsi_ArraySpliceCmd src/jsiArray.c:1172
    #1 0x555a35574818 in jsi_FuncCallSub src/jsiProto.c:244
    #2 0x555a3583e71a in jsiFunctionSubCall src/jsiEval.c:796
    #3 0x555a3583e71a in jsiEvalFunction src/jsiEval.c:837
    #4 0x555a3583e71a in jsiEvalCodeSub src/jsiEval.c:1264
    #5 0x555a3585215e in jsi_evalcode src/jsiEval.c:2204
    #6 0x555a35856274 in jsi_evalStrFile src/jsiEval.c:2665
    #7 0x555a3554566a in Jsi_Main src/jsiInterp.c:936
    #8 0x555a35d4a03a in jsi_main src/main.c:47
    #9 0x7fb00f1a5bf6 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21bf6)
    #10 0x555a354d9969 in _start (/usr/local/bin/jsish+0xe8969)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV src/jsiArray.c:1172 in jsi_ArraySpliceCmd

Credits: Found by OWL337 team.

hope-fly commented 2 years ago

This issue may have a correlation with #64, but I'm not for sure. Report this issue to assist your debug.