Open mischnic opened 5 years ago
There should be some problem withthe area file... on Windows 10, I can't compile the project using node 11. I get this error:
test_main_stub.c
win_delay_load_hook.cc
Creating library c:\Users\parroit\repos\libui-napi\build\Release\ui.lib and object c:\Users\par
roit\repos\libui-napi\build\Release\ui.exp
Generating code
83 of 386 functions (21.5%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation
61 functions had inline decision re-evaluated but remain unchanged
Finished generating code
area.obj : fatal error LNK1103: debugging information corrupt; recompile module [c:\Users\parroit\re
pos\libui-napi\build\ui.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\parroit\AppData\Roaming\nvm\v11.0.0\node_modules\npm\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\parroit\\AppData\\Roaming\\nvm\\v11.0.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "build"
I'm investigating further... do you have any idea?
Have you tried deleting the whole build folder and doing an complete rebuild?
(Segfaults also on macOS)
This is causing the segfault: https://github.com/parro-it/libui-napi/blob/10518288422f9d142273a0a72ab8fd967981945c/example/area.js#L43
Specifically, the v.color
part:
const x = new libui.BrushGradientStop(0, new libui.Color(1, 0, 0, 1))
console.log(x.color); // here
So in AreaBrush.stop_getColor
, but the call to make_color
itself seems to fail, make_color
doesn't actually run before the crash.
Have you tried deleting the whole build folder and doing an complete rebuild?
(Segfaults also on macOS)
Yes. I cleared all built artifacts and try building from scratch, but no luck. I can build and reproduce the segfault in linux anyway...
Got it! Within make_color function, the handle_scope is not really necessary, because you are calling that function with a JS scope already present in your call stack.
If you remove the scope creation code, the segfault go away.
Anyway, I don't know why the crash happens... maybe node 11 changed something in the way it hadle nested scopes....
Will publish a fix this evening...
Anyway, I don't know why the crash happens... maybe node 11 changed something in the way it handles nested scopes....
Node 10.12.0 crashes as well, but 8.12.0 doesn't.
Now, pressing any key on macOS with an area in focus causes a segfault...
* frame #0: 0x000000010017ab02 node`v8::Value::ToBoolean(v8::Local<v8::Context>) const + 12
frame #1: 0x0000000100045928 node`napi_coerce_to_bool + 144
frame #2: 0x0000000103e0bd84 ui.node`event_key_cb(h=<unavailable>, a=<unavailable>, e=0x00007ffeefbfe698) at area.c:169 [opt]
frame #3: 0x0000000103e4b2c6 libui.A.dylib`-[areaView sendKeyEvent:] + 86
frame #4: 0x0000000103e4b376 libui.A.dylib`-[areaView doKeyDownUp:up:] + 166
frame #5: 0x0000000103e4b3d0 libui.A.dylib`-[areaView doKeyDown:] + 64
frame #6: 0x0000000103e4b8ca libui.A.dylib`uiprivSendAreaEvents + 314
frame #7: 0x0000000103e6804d libui.A.dylib`-[uiprivApplicationClass sendEvent:] + 29
frame #8: 0x0000000103e6892c libui.A.dylib`uiprivMainStep + 252
frame #9: 0x0000000103e68826 libui.A.dylib`uiMainStep + 118
frame #10: 0x0000000103e13422 ui.node`main_thread(handle=<unavailable>) at event_loop.c:129 [opt]
frame #11: 0x0000000100759318 node`uv__run_timers + 51
frame #12: 0x000000010075c380 node`uv_run + 149
frame #13: 0x0000000100040db7 node`node::Start(v8::Isolate*, node::IsolateData*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 1127
frame #14: 0x000000010003fe76 node`node::Start(uv_loop_s*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 333
frame #15: 0x000000010003faef node`node::Start(int, char**) + 241
frame #16: 0x00007fff69902015 libdyld.dylib`start + 1
Should be fixed on Node 11 on master by b51baa7ec9eb378b62cc168e84611b1718309e67. I also fixed a similar problem on font-attribute https://github.com/parro-it/libui-napi/commit/b51baa7ec9eb378b62cc168e84611b1718309e67#diff-5441eb82f3119132336b51aa23263b3e I didn't try the fix yet with other Node versions. I will try it with Windows 10 to see if this fixes also the compilation problem I had.
Now, pressing any key on macOS with an area in focus causes a segfault...
Just to clarify: this is different (new) crash (but only with Node 11).
Should be fixed on Node 11 on master I didn't try the fix yet with other Node versions.
The original crash is fixed on Node 10 as well.
The original crash is fixed on Node 10 as well.
Good!
Just to clarify: this is different (new) crash (but only with Node 11).
I'll test this tomorrow.
Now, pressing any key on macOS with an area in focus causes a segfault...
It seems the cause it's the same: fire_event_args open itself a handle scope, and in function event_key_cb we are calling it with another handle scope already open, so we have a nesting of scopes that causes the segfault.
It seems like this behavior was introduced in Node 10.12.0 (10.11.0 works), but the changelog doesn't list even a single napi change. Is this a bug in Node?
From node.js docs: "N-API only supports a single nested hierarchy of scopes" and we are effectively using just that: a single level nesting... so yes, it seems to be a Node bug. Anyway, I extracted a fire_event_args_unscoped function that does not create an handle scope itself, and I changed the area cb to use that.
I add an event to area-adv.js that log arguements for any key pressed. It works fine on Windows 10, could you check master branch on macOS and see if this solve the problem?
Yes, it works! But there could still be functions where nested scopes could be created?
well, it works on Ubuntu too.
But there could still be functions where nested scopes could be created?
Ah yes, good catch... I'll change these other functions too
I fixed also the mouse & draw callbacks. Strangely, they does'nt cause any segfault. Maybe we are missing or misunderstanding something here?
Ubuntu 18.10 Node 11
This happens with area.js and area-adv.js, but not area-scrolling.js Do you know how to get more details? (This is already with
node-gyp configure -d
)