Commit 3cf8944
committed
fix: don't abort on worker termination during module load
worker.terminate() calls Isolate::TerminateExecution() on the worker
isolate from the parent thread, after which every V8 entry that runs JS
hands back an empty handle. Three call sites in the worker's script-load
path unwrapped those handles without checking:
- ModuleInternal::LoadModule called script->Run(...).ToLocalChecked() one
line before the tc.HasCaught() guard meant to handle exactly that, so a
terminate landing mid-load killed the process with "Fatal error in
v8::ToLocalChecked / Empty MaybeLocal".
- The same function unwrapped the __extends lookup unconditionally.
- CallWorkerScopeOnErrorHandle, which runs precisely when a worker script
fails to load, unwrapped the global "onerror" lookup.
NativeScriptException's TryCatch constructor then dereferenced
tc.Message() unconditionally. A terminated TryCatch exposes no message
object, so building the error to report turned the abort into a SIGSEGV,
which the runtime's own signal handler converted into an opaque "JNI
Exception occurred (SIGSEGV)" and no tombstone.
All four now test before unwrapping, matching the sibling compile sites
in LoadModule. Reporting already suppresses termination -- BackgroundLooper
guards on isTerminating_ and CallWorkerScopeOnErrorHandle returns early
for a terminating wrapper -- so a terminate during load unwinds as a
normal shutdown.
Also zero-initialises the sigaction struct used to install the SIGABRT and
SIGSEGV handlers, whose sa_mask and sa_flags were stack garbage.
The device suite hit this on roughly 20% of cold runs (pm clear + launch)
on an arm64 emulator, always in a worker spawned by the Workers suite
within the first seconds of the run; the faulting frame symbolised to
ModuleInternal::LoadModule. 27 cold runs on the fixed build are clean.1 parent 55a357a commit 3cf8944
7 files changed
Lines changed: 67 additions & 9 deletions
File tree
- test-app
- app/src/main/assets/app
- tests
- runtime/src/main/cpp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1496 | 1496 | | |
1497 | 1497 | | |
1498 | 1498 | | |
1499 | | - | |
1500 | | - | |
1501 | | - | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
1502 | 1504 | | |
1503 | 1505 | | |
1504 | | - | |
| 1506 | + | |
1505 | 1507 | | |
1506 | 1508 | | |
1507 | 1509 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
378 | | - | |
| 377 | + | |
| 378 | + | |
379 | 379 | | |
380 | 380 | | |
| 381 | + | |
381 | 382 | | |
382 | 383 | | |
383 | 384 | | |
| |||
425 | 426 | | |
426 | 427 | | |
427 | 428 | | |
428 | | - | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
429 | 434 | | |
430 | 435 | | |
431 | 436 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
49 | 60 | | |
50 | 61 | | |
51 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
0 commit comments