I had to use the uv_async_init(), uv_async_send() a persistent callback and 
uv_async_close() to wake up the main thread and perform the callback when 
the scope was back on the parent thread. Thanks!


On Thursday, October 23, 2014 2:42:02 AM UTC-6, Floby wrote:
>
> Not knowing much about your existing C functionnality, I would assume you 
> are calling V8 methods (scope) from the wrong thread. It is very much 
> possible that the library you are binding to uses threads.
> The rule of thumb is not to call any V8 function from any other thread 
> than the one running the main uv_loop.
>
> So, the best thing to do in your ReturnObject() function is to push some 
> work in the uv_queue or whatever that's called now. Your work will get 
> called next time the uv_loop runs, and you'll be in the right thread.
>
> On Wednesday, 22 October 2014 16:03:56 UTC+2, jas wrote:
>>
>> I am creating a linux shared object (.so) from an existing binary tool 
>> written in C, writing a custom C++ v8 bound native add on which links to 
>> the shared object.
>>
>> Everything so far is working swimmingly, node-gyp compiles, links & 
>> provides the module. The primary functionality is in place and also works 
>> fine until I attempt to do the following:
>>
>> From the existing C functionality compiled as ... 
>> extern "C" { /* ... */ }
>>
>> I pass a struct & additional data to another function (also wrapped with 
>> the extern) which passes that same data to a C++ function (member of a 
>> class) at which time the call to 
>> HandleScoope scope;
>> causes a segfault.
>>
>>
>>    
>> #include <node.h>
>> #include <v8.h>
>>  
>> using namespace node;
>> using namespace v8;
>>  
>> /* This function 'ReturnObject' is
>>  * called from an existing library
>>  * written in C
>> */
>> extern "C" {
>>   void ReturnObject() {
>>     classname cn;
>>  
>>     cn.Report();
>>   }
>> }
>>  
>> void classname::Report() {
>>   HandleScope scope; // Here is where I am getting segfaults
>>   classname cn;
>>  
>>   Local<Object> obj = Object::New();
>>   v8::Persistent<v8::Object> pobj(v8::Persistent<v8::Object>::New(obj));
>>  
>>   cn.RunCallback(pobj);
>> } 
>>
>> My assumption is that when I call HandleScope from the extern wrapped 
>> function is that the scope is missing. My other assumption is that I cannot 
>> do this from a child process, which is what I believe the problem is.
>>
>> Any tips or pointers on how I can accomplish this is appreciated.
>>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/d7771f4e-11e1-491d-b6fa-60aaa61507aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to