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

Why calling ThreadSafeFunction::Release() will cause a core dump #753

Closed
ke4nec opened this issue Jun 29, 2020 · 0 comments
Closed

Why calling ThreadSafeFunction::Release() will cause a core dump #753

ke4nec opened this issue Jun 29, 2020 · 0 comments

Comments

@ke4nec
Copy link

ke4nec commented Jun 29, 2020

Hi, all! I'm working on the Ubuntu 2004. why i got a core dump with this code? I run this code on windows 7 is ok.

Environment

  • ubuntu 20.04

  • node 10.16.3

  • node-addon-api 1.7.1

Refs: #592 , After update Node-addon-api to v3.0.0, the problem has been fixed.

binding.cpp

#include <napi.h>
using namespace Napi;

void Foo( const CallbackInfo& info )
{
    auto tsf = ThreadSafeFunction::New(
            info.Env(),
            info[0].As<Napi::Function>(),
            "TSF",
            0,
            1);

    tsf.Release();
}

Napi::Object Init( Napi::Env env, Object exports )
{
    exports.Set( "foo", Function::New( env, Foo ) );
    return exports;
}

NODE_API_MODULE( addon, Init )

file: tsf.js

const { foo } = require('bindings')('tsf');

function bar() {}

process.on('uncaughtException', function(err) {
    console.log('uncautch')
});

setInterval(() => {
    foo(bar)
},  1000)

nonexistentFunc();

binding.gyp

{
  'targets': [{
    'target_name': 'tsf',
    'sources': ['binding.cpp'],
    'include_dirs': ["<!@(node -p \"require('node-addon-api').include\")"],
    'cflags!': ['-fno-exceptions'],
    'cflags_cc!': ['-fno-exceptions'],
  }]
}
@ke4nec ke4nec changed the title why calling ThreadSafeFunction::Release() will cause a core dump Why calling ThreadSafeFunction::Release() will cause a core dump Jun 29, 2020
@ke4nec ke4nec closed this as completed Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant