Open bbailey1024 opened 6 years ago
I'm seeing this too w/ 4.1.4
, but at a different spot in the pebbe/zmq4
library. Haven't been able to test w/ 4.1.6
at all. Any ideas on this?
Nevermind... mine was a different issue (stupidity on my part).
I'm getting the same issue with any version of ZeroMQ and Go 1.12 Any ideas?
@antoniomtz any update?
Just a hint, if you are getting segfaults then note that ZeroMQ is not thread-safe:
Don’t share ZeroMQ sockets between threads. ZeroMQ sockets are not threadsafe. Technically it’s possible to migrate a socket from one thread to another but it demands skill. The only place where it’s remotely sane to share sockets between threads are in language bindings that need to do magic like garbage collection on sockets. - https://zguide.zeromq.org/docs/chapter2/#Multithreading-with-ZeroMQ
This constraint is easy to violate if you are using Goroutines. To avoid this, you'll need to either use explicit locking around zmq operations, or, preferably, put all zmq operations in a single goroutine and use channels to send data to/from other goroutines.
Just a hint, if you are getting segfaults then note that ZeroMQ is not thread-safe:
Shouldn't there be like a huge warning on the README then, especially since it's so easy to do non-thread-safe things in Go?
I am currently debugging random crashes involving zeromq and I know now that I'm violating this requirement. So I might have to redesign my application around the requirement that zeromq sockets must be local to one goroutine, locked with runtime.LockOSThread()
.
Currently running Go 1.9 and zeromq-4.1.5 and I'm running into invalid memory address or nil pointer dereference errors.
The following code results in the following errors.
If I upgrade to zeromq 4.1.6, remove and reinstall github.com/pebbe/zmq4 the error goes away and the program works as expected. We currently have 4.1.5 deployed in production and it's not trivial at this time to upgrade to 4.1.6.