[BUG] qjs: SIGSEGV in __JS_FreeAtom with invalid atom index
Maintainers usually reply within 5 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- c, javascript
- Domain
- compilers
Research direction
Reproduce the crash with qjs --memory-limit 256K Heap_Corruption_4 using the attached PoC, then inspect quickjs.c around __JS_FreeAtom, resolve_variables, and js_create_function. Use the provided GDB stack to trace the invalid atom during cleanup or variable resolution. Done means the adversarial input exits cleanly or reports an error instead of triggering SIGSEGV.
Written by the indexing model from the issue text.
Description
BUG description:
Running qjs under a 256KB memory limit on a JavaScript input causes a segmentation fault in __JS_FreeAtom() while resolving variables during function creation.
The crash appears to involve an invalid atom index being freed during cleanup or variable resolution.
Steps to Reproduce:
The PoC attachment contains the input file that triggers the crash:
COMMAND LINE:
./qjs --memory-limit 256K Heap_Corruption_4
Expected behavior
qjs should handle malformed or adversarial scripts under memory pressure by reporting an error or exiting cleanly, rather than freeing an invalid atom and crashing.
version:
QuickJS version 2026-06-04
Git branch: master
commit: https://github.com/bellard/quickjs/commit/04be246001599f5995fa2f2d8c91a0f198d3f34c
OS and version:
Ubuntu 22.04.5 LTS
arch: x86_64
Compiler:
gcc 11.4.0
clang 14.0.0
GDB output excerpt:
Program received signal SIGSEGV, Segmentation fault.
#0 __JS_FreeAtom (
rt=0x148bf570,
i=)
at quickjs.c:3419
#1 JS_FreeAtom (
ctx=0x148c8370,
v=622)
at quickjs.c:3718
#2 resolve_variables (
ctx=ctx@entry=0x148c8370,
s=s@entry=0x148e9198)
at quickjs.c:34078
#3 0x00000000005f4589 in js_create_function (...)
at quickjs.c:35904
#4 0x00000000005f44f7 in js_create_function (...)
at quickjs.c:35884
#5 0x000000000050227f in __JS_EvalInternal (...)
at quickjs.c:37084
#6 0x00000000004d9c05 in JS_EvalInternal (...)
at quickjs.c:37123
#7 JS_EvalThis (...)
at quickjs.c:37156
#8 JS_Eval (...)
at quickjs.c:37164
#9 0x0000000000436faf in eval_buf (...)
at qjs.c:66
#10 eval_file (...)
at qjs.c:101
#11 main (...)
at qjs.c:519
Additional Information:
Crash type: SIGSEGV
Crash location: __JS_FreeAtom()
Memory limit: 256K
Fully reproducible.
- Dominant language
- C
- Stars
- 11.1k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bellard/quickjs
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 5 days
-
RegExp: patterns with more than 255 capture groups fail with "too many captures"Possibly taken @andreasrosdal claimed this 3 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
bellard/quickjs#624 · 1 comment ·
Maintainers usually reply within 5 days
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
bellard/quickjs#620 · 1 comment ·
Maintainers usually reply within 5 days
-
(comment on #611) `function g(a, d = (a = 10)) { return a; }` returns the argument instead of 10Open
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 5 days
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 5 days
Similar issues
-
documentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JulianKemmerer/PipelineC#409 ·
-
Linux build fails without libspeechd-dev, which INSTALL.md doesn't list and CMake reports as foundOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
needs-playtest slice
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Life-Framework/Life-Framework#4861 ·
Maintainers usually reply within 1 day