You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Engine crash (Access Violation) when iterating over a sparse array after delete and push operations #1430
[Bug] Engine crash (Access Violation) when iterating over a sparse array after delete and push operations
Description
The engine crashes with an Access Violation (exit code -1073741819 / 0xC0000005 on Windows) when accessing elements of a sparse array that was modified using a specific sequence of push and delete operations.
This issue was originally discovered when using the engine to render multi-line templates with mustache.js, which internally uses delete on a token array to strip whitespaces and then continues processing the array.
Steps to Reproduce
We have isolated this bug to the following 10-line minimal reproducible script:
It crashes most of the time, but occasionally runs successfully and outputs done.
// crash_minimal.jsvarsize=2;vararr=[];// 1. Push initial elementsfor(vari=0;i<size;i++)arr.push(["a",i]);// 2. Delete the last element to create a hole (makes it a sparse array)deletearr[size-1];// 3. Push new elements into the arrayfor(vari=0;i<size;i++)arr.push(["b",i]);// 4. Iterate and access the elementsfor(vari=0;i<arr.length;i++){console.log("accessing "+i);vart=arr[i];// <--- CRASH occurs here when accessing newly pushed elementsconsole.log("accessed "+i);}console.log("done");
Command
qjs crash_minimal.js
Expected Behavior
The script should execute successfully and output the logs without crashing. The deleted index should simply yield undefined.
Actual Behavior
The engine crashes immediately during the loop when attempting to access the array element.
Output before crash:
Activity
saghul commentedon Mar 30, 2026
Thanks for the report!
bnoordhuis commentedon Apr 9, 2026
I believe this was addressed by 1b0b660.