mapbox / node-cpp-skel

Skeleton for bindings to C++ libraries for Node.js using node-addon-api
Creative Commons Zero v1.0 Universal
72 stars 10 forks source link

CFI build failing on travis #166

Open springmeyer opened 3 years ago

springmeyer commented 3 years ago

The CFI build is failing with:

# success: prints expected string
Illegal instruction (core dumped)

https://travis-ci.com/github/mapbox/node-cpp-skel/jobs/455213147#L449

I wonder if this started at https://github.com/mapbox/node-cpp-skel/commit/0f679d2a5eee050c7fe5d6f104016f501522554e? @artemp can you take a look?

artemp commented 3 years ago

The issue is cfi sanitizer doesn't like CRTP pattern cast here: https://github.com/nodejs/node-addon-api/blob/master/napi-inl.h#L3545

Process 27867 launched: '/opt/node/bin/node' (x86_64)
TAP version 13
# success: prints expected string
Process 27867 stopped
* thread #1, name = 'node', stop reason = signal SIGILL: illegal instruction operand
    frame #0: 0x00007ffff52271c2 module.node`Napi::ObjectWrap<object_sync::HelloObject>::ObjectWrap(this=0x00005555577d10c0, callbackInfo=0x00007fffffffc1a8) at napi-inl.h:3545:17
   3542   napi_value wrapper = callbackInfo.This();
   3543   napi_status status;
   3544   napi_ref ref;
-> 3545   T* instance = static_cast<T*>(this); <===================== FAIL  
   3546   status = napi_wrap(env, wrapper, instance, FinalizeCallback, nullptr, &ref);
   3547   NAPI_THROW_IF_FAILED_VOID(env, status);
   3548 

I'll submit PR with the fix (disabling cfi-derived-cast check for any functions which has 'ObjectWrap` string in its name.

artemp commented 3 years ago

Fixed in https://github.com/mapbox/node-cpp-skel/pull/167