Constructing an X() object, using the v8pp::class_ example from the README leads to crashes in the DevTools console of an electron window. First, I'm attaching a zip file with a shell script that can be used in a subdirectory of a v8pp checkout to:
a) locally install electron and node-gyp
b) build addon.node using just v8pp and the 'class X' example
c) start electron, create a window with DevTools console and require("addon.node")
At that point entering " x = addon.X(1,false) " in the Console will crash it due to v8pp throwing an uncought exception from convert<...is_wrapped_class...>::from_v8.
I've added a small debugging printout to unwrap_object():
This indicates that the DevTools console is accessing objects withtout internal fields using the v8pp accessors written for wrapped objects (the access apparently happens to auto-display the object property values). A valid access should show InternalFieldCount=2.
I fail to see why that is the case.
I can just speculate that the DevTools console does some magic behind the scenes like "cloning" objects by copying all their Handles without internal fields before running the accessors. Knowing the v8 and DevTools internals might be required to get at the root cause here.
In any case, the crashes can be mitigated by turning the C++ exceptions from v8pp into V8 exceptions for failing property accessors.
Constructing an X() object, using the v8pp::class_ example from the README leads to crashes in the DevTools console of an electron window. First, I'm attaching a zip file with a shell script that can be used in a subdirectory of a v8pp checkout to:
a) locally install electron and node-gyp
b) build addon.node using just v8pp and the 'class X' example
c) start electron, create a window with DevTools console and require("addon.node")
At that point entering " x = addon.X(1,false) " in the Console will crash it due to v8pp throwing an uncought exception from convert<...is_wrapped_class...>::from_v8.
I've added a small debugging printout to unwrap_object():
Which shows multiple lines like this before the console crashes:
This indicates that the DevTools console is accessing objects withtout internal fields using the v8pp accessors written for wrapped objects (the access apparently happens to auto-display the object property values). A valid access should show InternalFieldCount=2.
I fail to see why that is the case. I can just speculate that the DevTools console does some magic behind the scenes like "cloning" objects by copying all their Handles without internal fields before running the accessors. Knowing the v8 and DevTools internals might be required to get at the root cause here.
In any case, the crashes can be mitigated by turning the C++ exceptions from v8pp into V8 exceptions for failing property accessors.
ecrash.zip