You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
parallel/test-domain-error-types can crash if GC timings get unlucky #28275
It appears that the TickObject used for process.nextTick can die between the tick callback and the tick's after hook (possibly only in the case where the callback throws an exception), in which case there is no longer a strong reference to the tick's domain and the WeakReference to the domain can die (on an unlucky GC run). Then, the exit() call in domain.js will be called on undefined, and will crash.
Depending on the desired semantics, either current.get() in the after() call should check the WeakReference, or the TickObject resource/domain should be kept strongly alive until after the after hook.
Reproducible by manually setting a tighter GC interval and stressing compaction on a debug node build:
$ node --gc-interval=100 --stress-compaction test/parallel/test-domain-error-types.js
TypeError: Cannot read property 'exit' of undefined
at AsyncHook.after (domain.js:82:20)
at emitHook (internal/async_hooks.js:164:38)
at emitAfterScript (internal/async_hooks.js:363:5)
at process._fatalException (internal/process/execution.js:180:9)
Actually, I think this may have been caused by #26211 because the domain is now no longer kept alive through the domain stack. I’ll open a PR with the above suggestion, it does seem to resolve the issue.
Activity
addaleax commentedon Jun 19, 2019
Thanks for the bug report, this is something I definitely missed.
I can’t reproduce the issue without a debug build, so testing this out is going to take a while, but something like this might help:
addaleax commentedon Jun 20, 2019
Actually, I think this may have been caused by #26211 because the domain is now no longer kept alive through the domain stack. I’ll open a PR with the above suggestion, it does seem to resolve the issue.
domain: use strong reference to domain while active
domain: use strong reference to domain while active
domain: use strong reference to domain while active
domain: use strong reference to domain while active
Please ignore this msg (#1)