new Functiontemplates ends in Segfault

48 views
Skip to first unread message

t...@ainfach.de

unread,
May 21, 2013, 3:30:52 PM5/21/13
to v8-u...@googlegroups.com
Hi,

i try to extend v8 and everytime i end up in a segmentation fault.

here is the code:

Line 69 ends up in a segmentation fault (debugged using GCC) but i have no idea why.


here is my gdb output:

Breakpoint 1 at 0x56afee: file /home/dev/proj/cpp/v8example/modul_point.cc, line 61.
(gdb) c
Continuing.
[New Thread 0x7f61b7c3e700 (LWP 16397)]
[New Thread 0x7f61b7c23700 (LWP 16398)]
[New Thread 0x7f61b7c12700 (LWP 16399)]
[New Thread 0x7f61b7c01700 (LWP 16400)]

Breakpoint 1, modul_point::addToV8Scope (scope=0x7fffd1594d30) at /home/dev/proj/cpp/v8example/modul_point.cc:61
61 tpl->InstanceTemplate()->SetInternalFieldCount(1);
(gdb) n
67 Local<String> s = String::NewSymbol("getPosX");
(gdb) 
68 Local<FunctionTemplate> f = FunctionTemplate::New(&getPosX);
(gdb) s
Handle (this=<optimized out>) at /home/dev/Downloads/v8/include/v8.h:242
242  V8_INLINE(Handle()) : val_(0) {}
(gdb) 
modul_point::addToV8Scope (scope=0x7fffd1594d30) at /home/dev/proj/cpp/v8example/modul_point.cc:68
68 Local<FunctionTemplate> f = FunctionTemplate::New(&getPosX);
(gdb) 
69 Local<Function> fi = f->GetFunction();
(gdb) p *f
Could not find operator*.
(gdb) p f
$1 = {<v8::Handle<v8::FunctionTemplate>> = {val_ = 0x16178f0}, <No data fields>}
(gdb) p f
$2 = {<v8::Handle<v8::FunctionTemplate>> = {val_ = 0x16178f0}, <No data fields>}
(gdb) p Handle
No symbol "Handle" in current context.
(gdb) p f
$3 = {<v8::Handle<v8::FunctionTemplate>> = {val_ = 0x16178f0}, <No data fields>}
(gdb) p f.val_
$4 = (v8::FunctionTemplate *) 0x16178f0
(gdb) p *f.val_
$5 = {<v8::Template> = {<v8::Data> = {<No data fields>}, <No data fields>}, <No data fields>}
(gdb) p f.val_
$6 = (v8::FunctionTemplate *) 0x16178f0
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x00000000006a6db5 in v8::internal::Isolate::native_context() ()


is it up to: V8_INLINE(Handle()) : val_(0) {} ?

t...@ainfach.de

unread,
May 23, 2013, 3:11:53 PM5/23/13
to v8-u...@googlegroups.com
here is the complete project https://github.com/timglabisch/jsfastcgi/blob/master/modul_point.cc#L95

at line 95 i get the segfault.

hope somebody could help me.

Stephan Beal

unread,
May 23, 2013, 3:51:11 PM5/23/13
to v8-u...@googlegroups.com
On Thu, May 23, 2013 at 9:11 PM, t...@ainfach.de <t...@ainfach.de> wrote:
here is the complete project https://github.com/timglabisch/jsfastcgi/blob/master/modul_point.cc#L95

at line 95 i get the segfault.

hope somebody could help me.

This is just a wild guess, but what happens if you remove the HandleScope?

Also, you shouldn't generally be passing around (Handle<T>*), but should pass around (Handle<T> const &) instead (but that's not the cause of your problem).

--
----- stephan beal
http://wanderinghorse.net/home/stephan/

t...@ainfach.de

unread,
May 23, 2013, 5:06:35 PM5/23/13
to v8-u...@googlegroups.com, sgb...@googlemail.com
Thanks for your reply!

if i remove the handleScope i stll have the same issue, i rewrote some lines, but it didnt help. getFunction() still cause a segfault.

Reply all
Reply to author
Forward
0 new messages