Place1 / node-gir

Node bindings to libgirepository
http://live.gnome.org/GObjectIntrospection
MIT License
27 stars 6 forks source link

Segmentation fault when tried to load Gio lib #35

Closed cedlemo closed 6 years ago

cedlemo commented 6 years ago

Here is the code that crash:

const { load, Gtk } = require('../');
const Gio = load('Gio');

I have the following error:

3500 segmentation fault (core dumped)  node hello_world.js
cedlemo commented 6 years ago

Here is what I have with gdb:

gdb --args /home/cedlemo/.nvm/versions/node/v9.4.0/bin/node hello_world.js                                                                              node-gir/examples  simple_hello_world_gtk_application
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/cedlemo/.nvm/versions/node/v9.4.0/bin/node...done.
(gdb) run
Starting program: /home/cedlemo/.nvm/versions/node/v9.4.0/bin/node hello_world.js
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff6b0c700 (LWP 6517)]
[New Thread 0x7ffff630b700 (LWP 6518)]
[New Thread 0x7ffff5b0a700 (LWP 6519)]
[New Thread 0x7ffff5309700 (LWP 6520)]
[New Thread 0x7ffff7ff6700 (LWP 6521)]
[New Thread 0x7fffdb148700 (LWP 6522)]
[New Thread 0x7fffda947700 (LWP 6523)]
[Thread 0x7ffff5309700 (LWP 6520) exited]
[Thread 0x7ffff5b0a700 (LWP 6519) exited]
[Thread 0x7ffff630b700 (LWP 6518) exited]
[Thread 0x7ffff6b0c700 (LWP 6517) exited]

Thread 1 "node" received signal SIGSEGV, Segmentation fault.
0x0000000000e4b8df in v8::internal::GlobalHandles::Destroy(v8::internal::Object**) ()

I guess it is a memory allocation problem.

Place1 commented 6 years ago

awesome. you can use the backtrace command inside gdb to get a more detailed stack trace. remember to build node-gir with npm run build:debug.

Place1 commented 6 years ago

~it seems that this is the problematic line: https://github.com/Place1/node-gir/blob/master/src/types/struct.cpp#L73-L74~

Ignore that. There's nothing wrong on that line.

The issue is happening when the GIRStruct::prepared_js_classes map is deallocated. My stacktrace shows that the seg fault happens when the PersistentFunctionTemplate's destructor is called.

cedlemo commented 6 years ago

@Place1 ,

like in the issue #15, if I add the following instruction : Gtk.main(); it does not crash ... heu ... which in fact make senses since v8::internal::GlobalHandles::Destroy(v8::internal::Object** is used when the nodejs VM clean it is environment, nonetheless this issue is the same than the issue #15.

Place1 commented 6 years ago

ok, closing in favour of #15