A native program crashes with SIGSEGV when a string or JSON builder grows past 4 MiB
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 22/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- c, linux, typescript
- Ambito
- compilers, operating-systems
Direzione di ricerca
Start in scr_sa_run_move in scr_alloc.c, where the run is moved with mremap(..., MREMAP_MAYMOVE | MREMAP_FIXED, q) and the fallback memcpy(q, p, have) runs after a failed call. Reproduce with the 1760 x 2400-character JSON snippet from the issue, which should exit 139 today. Done means that snippet prints 4229281 and the slice without crashing, and that the fallback no longer writes to unmapped memory. PR #3643 already targets this, so review or coordinate there before starting a second fix.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A compiled program dies with SIGSEGV when a string builder grows past 4 MiB, in scr_sa_run_move's fallback copy. Node runs the same program.
Environment
- scriptc 0.4.12 from npm (the release's
@scriptc/compilerunder Node, linking@scriptc/runtime-linux-x64-gnu); upstreammainat 3198190fb3 has the same code. - Linux 6.8.0 x86_64, glibc 2.39.
What happens
const lines: string[] = [];
for (let i = 0; i < 1760; i++) lines.push("x".repeat(2400));
const text = JSON.stringify(lines);
console.log(String(text.length));
console.log(text.slice(0, 8));
Node prints 4229281 and ["xxxxxx. The native build prints nothing and exits 139.
The backtrace from an unstripped build of a larger app that hit it (resuming a 5 MB transcript, which became one JSON text):
#0 __memcpy_evex_unaligned_erms
#1 scr_sa_run_move () at scr_alloc.c
#2 scr_mem_realloc_ref ()
#3 scr_str_regrow ()
#4 scr_jb_grow ()
#5 scr_jb_put_json_str ()
#6 scr_dyn_json_write ()
...
#9 scr_json_stringify_with ()
At the fault: p=0x387c00000, q=0x388400000, have=0x800000, n=0x800019. info proc mappings showed an unmapped hole at exactly [0x388400000, 0x388c00000), which is q to q + have.
Cause
scr_sa_run_move moves the run with mremap(p, have, have, MREMAP_MAYMOVE | MREMAP_FIXED, q). When the old run spans two mappings, the call fails. On Linux a failed MREMAP_FIXED has already unmapped the destination range, so the fallback memcpy(q, p, have) writes into unmapped memory.
#3595 (the native CLI segfaulting on a large program) may be the same crash, since the CLI builds large strings too. I have not checked that.
- Lingua principale
- TypeScript
- Stelle
- 6.6k
- Fork
- 216
- Merge medio
- 9h 35m
- PR unite (30g)
- 775
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vercel-labs/scriptc
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vercel-labs/scriptc#3979 ·
I maintainer di solito rispondono entro 1 giorno
-
Support undici 8.x request() through the built-in implementationForse già presa @younggglcy l’ha presa 1 giorno fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
vercel-labs/scriptc#3894 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
vercel-labs/scriptc#3613 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
vercel-labs/scriptc#3605 ·
I maintainer di solito rispondono entro 1 giorno
-
Native CLI (scriptc.exe) segfaults on a large program that the same release compiles under NodeAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
vercel-labs/scriptc#3595 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di vercel-labs/scriptc
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
milind-soni/OpenMausBot#6730 ·
I maintainer di solito rispondono entro 1 giorno
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Apertaarea: @angular/build
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
angular/angular-cli#34764 ·
I maintainer di solito rispondono entro 1 giorno
-
status/need-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
google-gemini/gemini-cli#30384 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
P2
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
area:image documentation good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno