Skip to content

parallel/test-domain-error-types can crash if GC timings get unlucky #28275

Closed
@LeszekSwirski

Description

@LeszekSwirski
  • Version: v13.0.0-pre
  • Platform: Linux (debian)
  • Subsystem: Domain

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.domainIssues and PRs related to the domain subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions