Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
I see! Thanks a lot for all the help :) On Fri, Dec 2, 2016 at 11:50 AM, Ben Noordhuis wrote: > On Fri, Dec 2, 2016 at 11:18 AM, Thomas Barusseau > wrote: > > Isn't there a simpler way, by the way, than using uv_async_send? > > Maybe not the answer you're looking for but: don't use threads. :-) > > > I've seen in the documentation that there are Lockers/Unlockers. From > what > > I've > > read they might be the things I need? > > Node.js never releases the lock while running so that won't really > work. You _might_ be able to make it work by releasing/acquiring the > lock in uv_prepare_t and uv_check_t callbacks but then you'll be deep > in uncharted territory. > > > Also, I decided to just pass around the pointer to Isolate since it > > shouldn't change > > anyway. So now doing this : > > https://gist.github.com/anonymous/585d2e8577b9c8669e31c9844f3d41de > > > > However, as the code suggests, the execution is completely locked in the > > Local->Call(). > > > > Any idea why? > > You're violating thread safety. Hangs and crashes are to be expected. > > -- > -- > v8-users mailing list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to a topic in the > Google Groups "v8-users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/v8-users/rdlZrw8xKhI/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > v8-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Thomas Barusseau -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
On Fri, Dec 2, 2016 at 11:18 AM, Thomas Barusseau wrote: > Isn't there a simpler way, by the way, than using uv_async_send? Maybe not the answer you're looking for but: don't use threads. :-) > I've seen in the documentation that there are Lockers/Unlockers. From what > I've > read they might be the things I need? Node.js never releases the lock while running so that won't really work. You _might_ be able to make it work by releasing/acquiring the lock in uv_prepare_t and uv_check_t callbacks but then you'll be deep in uncharted territory. > Also, I decided to just pass around the pointer to Isolate since it > shouldn't change > anyway. So now doing this : > https://gist.github.com/anonymous/585d2e8577b9c8669e31c9844f3d41de > > However, as the code suggests, the execution is completely locked in the > Local->Call(). > > Any idea why? You're violating thread safety. Hangs and crashes are to be expected. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
Isn't there a simpler way, by the way, than using uv_async_send? I've seen in the documentation that there are Lockers/Unlockers. From what I've read they might be the things I need? Also, I decided to just pass around the pointer to Isolate since it shouldn't change anyway. So now doing this : https://gist.github.com/anonymous/585d2e8577b9c8669e31c9844f3d41de However, as the code suggests, the execution is completely locked in the Local->Call(). Any idea why? On Friday, December 2, 2016 at 10:25:18 AM UTC+1, Ben Noordhuis wrote: > > On Fri, Dec 2, 2016 at 9:52 AM, Thomas Barusseau > > wrote: > > So, anyway, I tried your fix. New errors/crashes arise. I believe it's > > because of the > > structure of my code, but here's what I do now : > > > > I put up the Local copying of the Persistent > earlier, > > and tried > > to get its context the way you told me to. > > First of all, to copy it I had to define a HandleScope scope(isolate), > else > > I had a > > "#Fatal error in v8::HandleScope::CreateHandle() > > # Cannot create a handle without a HandleScope" > > error. So after I added the HandleScope right above the `Local > > lpe` definition, > > now I have a segfault during the part where I get the context, from lpe, > > here is the stack trace : > > https://gist.github.com/anonymous/1d939e3e339243fc19baacf3066ffd12 > > > > Would be really thankful if you could help me further. Thanks in > advance. > > I can tell from your stack trace that you are calling into V8 from a > different thread. That's not safe, use a mechanism like > uv_async_send() to message the main thread. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
Thanks a lot for your help, I'll look into that! On Fri, Dec 2, 2016 at 10:25 AM, Ben Noordhuis wrote: > On Fri, Dec 2, 2016 at 9:52 AM, Thomas Barusseau > wrote: > > So, anyway, I tried your fix. New errors/crashes arise. I believe it's > > because of the > > structure of my code, but here's what I do now : > > > > I put up the Local copying of the Persistent earlier, > > and tried > > to get its context the way you told me to. > > First of all, to copy it I had to define a HandleScope scope(isolate), > else > > I had a > > "#Fatal error in v8::HandleScope::CreateHandle() > > # Cannot create a handle without a HandleScope" > > error. So after I added the HandleScope right above the `Local > > lpe` definition, > > now I have a segfault during the part where I get the context, from lpe, > > here is the stack trace : > > https://gist.github.com/anonymous/1d939e3e339243fc19baacf3066ffd12 > > > > Would be really thankful if you could help me further. Thanks in advance. > > I can tell from your stack trace that you are calling into V8 from a > different thread. That's not safe, use a mechanism like > uv_async_send() to message the main thread. > > -- > -- > v8-users mailing list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to a topic in the > Google Groups "v8-users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/v8-users/rdlZrw8xKhI/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > v8-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Thomas Barusseau -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
On Fri, Dec 2, 2016 at 9:52 AM, Thomas Barusseau wrote: > So, anyway, I tried your fix. New errors/crashes arise. I believe it's > because of the > structure of my code, but here's what I do now : > > I put up the Local copying of the Persistent earlier, > and tried > to get its context the way you told me to. > First of all, to copy it I had to define a HandleScope scope(isolate), else > I had a > "#Fatal error in v8::HandleScope::CreateHandle() > # Cannot create a handle without a HandleScope" > error. So after I added the HandleScope right above the `Local > lpe` definition, > now I have a segfault during the part where I get the context, from lpe, > here is the stack trace : > https://gist.github.com/anonymous/1d939e3e339243fc19baacf3066ffd12 > > Would be really thankful if you could help me further. Thanks in advance. I can tell from your stack trace that you are calling into V8 from a different thread. That's not safe, use a mechanism like uv_async_send() to message the main thread. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
So, anyway, I tried your fix. New errors/crashes arise. I believe it's because of the structure of my code, but here's what I do now : I put up the Local copying of the Persistent earlier, and tried to get its context the way you told me to. First of all, to copy it I had to define a HandleScope scope(isolate), else I had a "#Fatal error in v8::HandleScope::CreateHandle() # Cannot create a handle without a HandleScope" error. So after I added the HandleScope right above the `Local lpe` definition, now I have a segfault during the part where I get the context, from lpe, here is the stack trace : https://gist.github.com/anonymous/1d939e3e339243fc19baacf3066ffd12 Would be really thankful if you could help me further. Thanks in advance. On Thursday, December 1, 2016 at 10:46:05 PM UTC+1, Ben Noordhuis wrote: > > On Thu, Dec 1, 2016 at 9:55 PM, Thomas Barusseau > > wrote: > > I read somewhere that if Isolate::GetCurrent() returned NULL, it was > > because the current isolate was being already used, I guess by the > running > > node.js itself? > > Node.js never unlocks the isolate while running so if > Isolate::GetCurrent() returns NULL, you either call it from a > different thread or at program exit when the VM has been shut down. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
Let's assume that I can't wait for the VM to shut down. Do I have to fork the main node.js process itself? I suppose a simple fork in my node addon won't do much good... On Thursday, December 1, 2016 at 10:46:05 PM UTC+1, Ben Noordhuis wrote: > > On Thu, Dec 1, 2016 at 9:55 PM, Thomas Barusseau > > wrote: > > I read somewhere that if Isolate::GetCurrent() returned NULL, it was > > because the current isolate was being already used, I guess by the > running > > node.js itself? > > Node.js never unlocks the isolate while running so if > Isolate::GetCurrent() returns NULL, you either call it from a > different thread or at program exit when the VM has been shut down. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
On Thu, Dec 1, 2016 at 9:55 PM, Thomas Barusseau wrote: > I read somewhere that if Isolate::GetCurrent() returned NULL, it was > because the current isolate was being already used, I guess by the running > node.js itself? Node.js never unlocks the isolate while running so if Isolate::GetCurrent() returns NULL, you either call it from a different thread or at program exit when the VM has been shut down. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
Hello, That makes sense, and I was pretty sure that just creating a new isolate was clearly not the way to go. Since I'm dealing with Persistent objects, what should I do, then? I read somewhere that if Isolate::GetCurrent() returned NULL, it was because the current isolate was being already used, I guess by the running node.js itself? If so, I really need assistance, because I technically can't stop it (because other modules are running on it and some are time-sensitive), and even if I could, I don't see how I'd do that. I can't test your suggestions right now but will try tomorrow and make a follow-up. Thanks a lot! On Thursday, December 1, 2016 at 8:34:41 PM UTC+1, Ben Noordhuis wrote: > > On Thu, Dec 1, 2016 at 5:09 PM, Thomas Barusseau > > wrote: > > Hello, > > > > I'm having a hard time making this piece of code work. Basically, I need > to > > take a node.js function (in this case : `process.emit()`), > > store it in a C++ class, and use it at runtime whenever a callback > method is > > called. > > > > Here is the code : > > https://gist.github.com/Neph0/21bcfcebc23596f76defad0e743ec929 > > > > And here is gdb's output : > > https://gist.github.com/Neph0/0e668d427e2788c54f3d9b744c9a7abc > > > > Could anyone help me with that? There's no doubt my code has stupid > things > > in it. > > I've read a lot of documentation today but somehow I can't figure out > some > > things and I'm stuck trying things without fully understanding > > the big picture... > > > > Thanks in advance. > > From your gist: > > Local context = isolate->GetCurrentContext(); > context->Enter(); // /!\ SIGSEGV HAPPENS HERE /!\ > > I bet that context.IsEmpty() is true. You could move this line up: > > Local lpe = Local::New(isolate, process_emit); > > And then you can get its context with lpe->CreationContext(). > > One last word of advice: conditionally creating a new isolate when > Isolate::GetCurrent() returns NULL is not going to work. Objects and > functions are intrinsically tied to the isolate that created them. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [v8-users] [novice] SIGSEGV upon entering new top of the stack context
On Thu, Dec 1, 2016 at 5:09 PM, Thomas Barusseau wrote: > Hello, > > I'm having a hard time making this piece of code work. Basically, I need to > take a node.js function (in this case : `process.emit()`), > store it in a C++ class, and use it at runtime whenever a callback method is > called. > > Here is the code : > https://gist.github.com/Neph0/21bcfcebc23596f76defad0e743ec929 > > And here is gdb's output : > https://gist.github.com/Neph0/0e668d427e2788c54f3d9b744c9a7abc > > Could anyone help me with that? There's no doubt my code has stupid things > in it. > I've read a lot of documentation today but somehow I can't figure out some > things and I'm stuck trying things without fully understanding > the big picture... > > Thanks in advance. >From your gist: Local context = isolate->GetCurrentContext(); context->Enter(); // /!\ SIGSEGV HAPPENS HERE /!\ I bet that context.IsEmpty() is true. You could move this line up: Local lpe = Local::New(isolate, process_emit); And then you can get its context with lpe->CreationContext(). One last word of advice: conditionally creating a new isolate when Isolate::GetCurrent() returns NULL is not going to work. Objects and functions are intrinsically tied to the isolate that created them. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[v8-users] [novice] SIGSEGV upon entering new top of the stack context
Hello, I'm having a hard time making this piece of code work. Basically, I need to take a node.js function (in this case : `process.emit()`), store it in a C++ class, and use it at runtime whenever a callback method is called. Here is the code : https://gist.github.com/Neph0/21bcfcebc23596f76defad0e743ec929 And here is gdb's output : https://gist.github.com/Neph0/0e668d427e2788c54f3d9b744c9a7abc Could anyone help me with that? There's no doubt my code has stupid things in it. I've read a lot of documentation today but somehow I can't figure out some things and I'm stuck trying things without fully understanding the big picture... Thanks in advance. -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.