You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, I've ran into an issue when working with this project.
Due to an error on my part, I've tried to access the method Sock.Pollin on a sock that was previously destroyed. Doing so resulted in a SIGABRT and a core dump from the underlying czmq lib.
Steps to reproduce
This simple example would result in a similar crash
The czmq lib calls assert (self); in the beginning of each method, which would fail when the sock has been destroyed because resources have been freed. When the assert fails, a SIGABRT is sent, which triggers the core dump.
The goczmq lib does not perform additional verification before calling the C method
// Events returns the current value of the socket's events optionfuncEvents(s*Sock) int {
val:=C.zsock_events(unsafe.Pointer(s.zsockT))
returnint(val)
}
// Pollin returns true if there is a Pollin// event on the socketfunc (s*Sock) Pollin() bool {
returnEvents(s)&Pollin==Pollin
}
Solutions
My fix was to make sure that the case was not possible (so joining all goroutines before destroying the sock), but two solutions would make this approach more robust, as a SIGABRT is not recoverable:
Adding a way to verify that a socket has not been destroyed, as it is not possible at the moment
Adding a verification that the socket has not been destroyed during the function call, before calling the C method
The second solution might modify the Pollin signature with something like func (s *Sock) Pollin() (bool, error) which would make it easy to process errors during the Pollin call
Additional remarks
For now, I'm pretty sure this affects the Pollin and Pollout methods. I suspect that this affects all methods calling directly the C library as well, for instance RecvFrame, but I have not checked that.
The text was updated successfully, but these errors were encountered:
Hi there, I've ran into an issue when working with this project.
Due to an error on my part, I've tried to access the method
Sock.Pollin
on a sock that was previously destroyed. Doing so resulted in aSIGABRT
and a core dump from the underlying czmq lib.Steps to reproduce
This simple example would result in a similar crash
Running this example would result in the following output:
Reason
The czmq lib calls
assert (self);
in the beginning of each method, which would fail when the sock has been destroyed because resources have been freed. When the assert fails, aSIGABRT
is sent, which triggers the core dump.The goczmq lib does not perform additional verification before calling the C method
Solutions
My fix was to make sure that the case was not possible (so joining all goroutines before destroying the sock), but two solutions would make this approach more robust, as a
SIGABRT
is not recoverable:The second solution might modify the Pollin signature with something like
func (s *Sock) Pollin() (bool, error)
which would make it easy to process errors during the Pollin callAdditional remarks
For now, I'm pretty sure this affects the
Pollin
andPollout
methods. I suspect that this affects all methods calling directly the C library as well, for instanceRecvFrame
, but I have not checked that.The text was updated successfully, but these errors were encountered: