Description
@joyeecheung ... I'm running into an issue with the node_mksnapshot tool during build. It apparently does not know how to handle BindingData for native modules when the snapshot is created...
I'm working on a rework of internalBinding('trace_events')
module, and attempting to add binding data to it:
TraceEventsState* const state =
env->AddBindingData<TraceEventsState>(context, target);
if (state == nullptr) return;
The trace_events
module is loaded during bootstrap, so the created TraceEventsState
object is attached as the binding data at that step.
Unfortunately, this causes node_mksnapshot
to crash:
global handle not serialized: 0x327e5e9f3281: [JS_API_OBJECT_TYPE] in OldSpace
- map: 0x2c1d4730fe89 <Map(HOLEY_ELEMENTS)> [FastProperties]
- prototype: 0x218677ec84b1 <Object map = 0x2c1d473101a1>
- elements: 0x1fd3c5ec0b29 <FixedArray[0]> [HOLEY_ELEMENTS]
- embedder fields: 1
- properties: 0x1fd3c5ec0b29 <FixedArray[0]> {}
- embedder fields = {
22006, aligned pointer: 0x55f6648c31e0
}
#
# Fatal error in , line 0
# Check failed: handle_checker.CheckGlobalAndEternalHandles().
#
#
#
#FailureMessage Object: 0x7ffd2543d6c0
1: 0x55f65ee301a1 [/home/james/node/node/out/Release/node_mksnapshot]
2: 0x55f65fd6af3e V8_Fatal(char const*, ...) [/home/james/node/node/out/Release/node_mksnapshot]
3: 0x55f65f3e3823 v8::SnapshotCreator::CreateBlob(v8::SnapshotCreator::FunctionCodeHandling) [/home/james/node/node/out/Release/node_mksnapshot]
4: 0x55f65ed1c016 node::SnapshotBuilder::Generate(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >) [/home/james/node/node/out/Release/node_mksnapshot]
5: 0x55f65e953832 main [/home/james/node/node/out/Release/node_mksnapshot]
6: 0x7f2df6bb1b97 __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
7: 0x55f65e95b42a _start [/home/james/node/node/out/Release/node_mksnapshot]
Illegal instruction (core dumped)
node.target.mk:26: recipe for target '/home/james/node/node/out/Release/obj/gen/node_snapshot.cc' failed
make[1]: *** [/home/james/node/node/out/Release/obj/gen/node_snapshot.cc] Error 132
rm 82c869d3ddd844a851343f4dda5865e1e173131d.intermediate 53b6ae97571ad65714c594648ab8f1c04245ce26.intermediate
Makefile:104: recipe for target 'node' failed
make: *** [node] Error 2
We should be able to attach BindingData
to any of the internal native modules without having to fight with this. I know that addaleax's original implementation design for this bit covered but I'm not sure of the details so I'm not entirely sure what is missing in the version of your approach that landed here.