Worker resourceLimits are not enforced while DevTools has the Debugger domain enabled
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- cpp
- Domaine
- backend, mobile-dev
Piste de recherche
Start in WorkerWrapper::OnNearHeapLimit and PrepareV8Runtime, then trace how the worker inspector session enables Debugger and how V8Debugger::enable and disable manage heap-limit callbacks. Reproduce with a debug build and a worker using resourceLimits; check that the parent receives the heap-limit error and the worker terminates after any intended debugger pause or resume.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
In a debug build, once a DevTools session enables the Debugger domain on a worker target, that worker's resourceLimits stop being enforced and the parent never receives the heap-limit error.
Why
WorkerWrapper::OnNearHeapLimit is registered with AddNearHeapLimitCallback in PrepareV8Runtime. It reports ERR_WORKER_OUT_OF_MEMORY to the parent and terminates the worker. V8 only invokes the most recently added near-heap-limit callback (Heap::InvokeNearHeapLimitCallback calls near_heap_limit_callbacks_.back(), src/heap/heap.cc). V8Debugger::enable adds its own callback (src/inspector/v8-debugger.cc), which shadows the worker's for as long as the Debugger domain stays enabled. That callback:
- schedules an OOM break (
BreakReason::kOOM), and - returns
HeapLimitForDebugging(initial_heap_limit), which raises the limit well past the configuredmaxOldGenerationSizeMb.
So while a debugger is attached to the worker, the worker either pauses on OOM in DevTools or keeps running above its cap. Either way OnNearHeapLimit never runs: the parent gets no error event, terminate/exit never follow, and code that relies on resourceLimits to contain a runaway worker behaves differently under the debugger than without it. Detaching restores the worker's callback (V8Debugger::disable removes the debugger's).
Release builds are unaffected (no inspector), and so are debug builds with no DevTools session, or with one that never enables Debugger on the worker target.
Expected
Pausing on OOM while debugging is reasonable and matches Chrome. But after the user resumes (or if the debugger's raised limit is also exhausted), the worker should still be reported and terminated as it is without a debugger. Possible directions:
- Re-register
OnNearHeapLimitafter the worker's inspector session enablesDebugger, so it stays last, and decide explicitly whether to break first. - Or chain: keep the debugger's break, but have the worker's handler run on resume, or once the debug allowance is exhausted.
Repro (sketch)
- Debug build of an app with a worker created with
resourceLimits: { maxOldGenerationSizeMb: 16 }whose script allocates until it runs out of memory. - Without DevTools: the parent gets the heap-limit
error, and the worker ends. - Attach Chrome DevTools to the worker target (which enables
Debugger) and rerun: noerrorreaches the parent. The worker pauses on OOM, or, after resuming, keeps allocating past 16 MB.
Found while reviewing #2070.
- Langage dominant
- C++
- Étoiles
- 565
- Forks
- 147
- Merge moyen
- 1 j 2 h
- PR mergées (30 j)
- 27
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NativeScript/android
-
improvement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
NativeScript/android#2100 ·
Les mainteneurs répondent en général sous 1 jour
-
ErrorReportActivity draws under the status bar on targetSdk 35 (forced edge-to-edge)Peut-être pris @aleclarson l’a pris il y a 48 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 76/100
NativeScript/android#2053 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 38/100
NativeScript/android#2039 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
NativeScript/android#2024 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
NativeScript/android#2020 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de NativeScript/android
Issues similaires
-
Difficulté 1/5 1-3 heures Accessibilité débutants 77/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
phantoslayer21/wronggpu#275 ·
Les mainteneurs répondent en général sous 1 jour
-
bug good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
ReyeMe/SaturnRingLib#155 ·
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Nheko-Reborn/nheko#2092 ·
-
Difficulté 1/5 1-3 heures Accessibilité débutants 78/100
isocpp/CppCoreGuidelines#2345 ·