On 09/01/2016 01:06 AM, J Decker wrote:
> I'm working on a simple network proxy addon for node (yes it's sort of a
> crossover issue, but the error happens in ... hmm no adding run fixed
> that... moved the problem I guess
> 
> I cut out most of the excess code; there's still excess in the
> custructor callback... but I wanted to leave that flow intact.
> 

Was there a previous email I missed? I have no context thus far.

> when creating a new object, I create a single uv_default_loop() that
> I'll never close ?
> 

That's going to be a problem.  Node itself uses the default loop, so
you'd be using the same loop really, and uv_run is non-recursive, so you
cannot call it while it's already running, and it is, otherwise your JS
code wouldn't run.

> on destructor I do uv_close( (uv_handle_t*)&async, NULL );
> uv_run( fbdl.loop, UV_RUN_DEFAULT );
>  

As mentioned above, bad idea.  Even if you use a new loop, why?  Why not
use the existing loop?  Are you also using other threads?

> adding the run stops it from generating an assert(0) about a bad handle
> block in the loop (I guess, i forget the header)
> Assertion failed: 0, file c:\ws\deps\uv\src\win\handle-inl.h, line 159
> probably this version is
> close https://github.com/mapbox/node/blob/master/deps/uv/src/win/handle-inl.h
> 
> from a standard thread created with CreateThread in windows I call 
> uv_async_send( &state->object->async );
> 

That is OK, uv_async_send is thread-safe.

> I don't call uv_async_send( &state->object->async );
>  after the object destructs or anywhere near it... the sockets have long
> been closed and the object can be garbage collected because no more
> events will happen to it....
> 
> After running the 'uv_run' mentioend above, now node.exe is jumping to
> address 00000000 like somehow it lost a callback.  It's a fatal crash
> and node just exits... 
> 

[snip]

I haven't looked at the code, but you should just create the handle in
the loop which is attached to the current Environment, then just close
the handle when you're done with it.  Note that it's not OK to free the
memory for the handle right after the call to uv_close, you need to pass
a callback and free it there.


Cheers,

-- 
Saúl Ibarra Corretgé
bettercallsaghul.com


-- 
You received this message because you are subscribed to the Google Groups 
"libuv" 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].
Visit this group at https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to