Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n-api: run all finalizers via SetImmediate() #34386

Commits on Jul 23, 2020

  1. n-api: run all finalizers via SetImmediate()

    Throwing an exception from a finalizer can cause the following fatal
    error:
    
    Error: async hook stack has become corrupted (actual: 2, expected: 0)
     1: 0x970b5a node::InternalCallbackScope::~InternalCallbackScope() [./node]
     2: 0x99dda0 node::Environment::RunTimers(uv_timer_s*) [./node]
     3: 0x13d8b22  [./node]
     4: 0x13dbe42 uv_run [./node]
     5: 0xa57974 node::NodeMainInstance::Run() [./node]
     6: 0x9dbc17 node::Start(int, char**) [./node]
     7: 0x7f4965417f43 __libc_start_main [/lib64/libc.so.6]
     8: 0x96f4ae _start [./node]
    
    By nodejs#34341 (comment),
    calling into JS from a finalizer and/or throwing exceptions from there
    is not advised, because the stack may or may not be set up for JS
    execution. The best solution is to run the user's finalizer from a
    `SetImmediate()` callback.
    
    Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
    Fixes: nodejs#34341
    Gabriel Schulhof committed Jul 23, 2020
    Copy the full SHA
    f04eaa7 View commit details
    Browse the repository at this point in the history
  2. fixup! testFinalizerException to gc until it throws

    Gabriel Schulhof committed Jul 23, 2020
    Copy the full SHA
    540ec7e View commit details
    Browse the repository at this point in the history