Context without the Promise intrinsic leaks async function bytecode and aborts in JS_FreeRuntime
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 57/100
Direzione di ricerca
Start in the runtime class registration and async-function creation paths described in the issue, then inspect the linked PR’s raw_context_async_function test in api-test.c. Reproduce the abort with a raw context that omits the Promise intrinsic and run the API tests. Done means the async-function bytecode is freed and JS_FreeRuntime exits cleanly without requiring the Promise intrinsic, or async syntax is rejected safely.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A context without the Promise intrinsic can still parse async function. The async function object then leaks its bytecode, and JS_FreeRuntime aborts.
Repro (current master, 2f0aa72)
#include "quickjs.h"
int main(void)
{
JSRuntime *rt = JS_NewRuntime();
JSContext *ctx = JS_NewContextRaw(rt);
JS_AddIntrinsicBaseObjects(ctx);
JS_AddIntrinsicEval(ctx); // no JS_AddIntrinsicPromise
const char src[] = "async function f() {}";
JS_FreeValue(ctx, JS_Eval(ctx, src, sizeof(src) - 1, "<input>", JS_EVAL_TYPE_GLOBAL));
JS_FreeContext(ctx);
JS_FreeRuntime(rt); // aborts here
return 0;
}
Output:
quickjs.c:2699: JS_FreeRuntime: Assertion `list_empty(&rt->gc_obj_list)' failed.
With JS_DUMP_LEAKS, the leaked object is a [function bytecode].
Why
- The parser accepts
async functionin any context. js_closuretags the function withJS_CLASS_ASYNC_FUNCTION.- That class, and the rest of
js_async_class_def, is only registered byJS_AddIntrinsicPromise. - Without that intrinsic the class has no finalizer, so the function's bytecode is never freed.
Adding JS_AddIntrinsicPromise(ctx) makes the repro exit cleanly. bellard/quickjs is affected the same way.
Possible fixes
- Register
js_async_class_def(and its.callhooks) inJS_NewRuntime, likejs_std_class_def. We tested this: the repro and the wholeapi-testpass. - Or reject async syntax at compile time when the Promise intrinsic is missing.
A failing test (raw_context_async_function in api-test.c) is in the linked PR. Happy to add either fix there.
We hit this in an embedder that builds minimal sandboxed contexts. Our workaround is to add the Promise intrinsic and then remove the globals.
- Lingua principale
- C
- Stelle
- 3.9k
- Fork
- 389
- Merge medio
- 4g 1h
- PR unite (30g)
- 24
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 quickjs-ng/quickjs
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
quickjs-ng/quickjs#1836 ·
I maintainer di solito rispondono entro 2 giorni
-
Array.prototype.find frees an element twice when interrupted between iterationsForse già presa @josefguenther l’ha presa 14 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
quickjs-ng/quickjs#1792 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Object.prototype.propertyIsEnumerable converts `this` before the property keyForse già presa @SomSamantray l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
quickjs-ng/quickjs#1772 ·
I maintainer di solito rispondono entro 2 giorni
-
Deserialization corrupts data or returns `undefined` when a RegExp precedes a shared object referenceForse già presa @Sree24-ui l’ha presa 13 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
quickjs-ng/quickjs#1771 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
quickjs-ng/quickjs#1835 · 1 reazione ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di quickjs-ng/quickjs
Issue simili
-
[WinReg] update to v12.0.0Apertacategory:port-update
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni
-
type-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
feat(palindrome): add C solutionForse già presa @aadiitya2007 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
techcsispit/code-corner#58 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[LOGO] Add Ruxt Linux LogoApertalogo request
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
fastfetch-cli/fastfetch#2661 ·
I maintainer di solito rispondono entro 1 giorno
-
Mark ignored Mac OS partitions RecoveryOSContainer and iBootSystemContainerForse già presa @meven l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
storaged-project/udisks#1559 ·