Open elmerjfudd opened 3 years ago
Looks like this data race has similar side effects as #930. Maybe the root causes are related?
EDIT: Just to clarify, it looks like #933 does not address the root cause of this issue.
This issue still occurs with the most recent commit, i.e., d934760 I was wondering if there is any fix currently in the works.
Facing the same issue on Xamarin.iOS, and Xamasrin.Android.
Just checking in, because it looks like this is still happening in the latest stable version.
I'm still facing this issue in the latest version. Edit: is it really necessary to throw an exception when Close is invoked on an uninitialized Msg?
Please!!!! need help on this!!!!! ANY IDEAS?
I'm still facing this issue in the latest version.
Same...
I have been using pub and sub in a same thread <-- this caused "Cannot close an uninitialised Msg" sometimes.
Now I run subscriber and publisher on different thread. I have no longer seen such error.
something like this (ran on unity), hope this helps
// sockets
public PublisherSocket _pubSocket;
public SubscriberSocket _subSocket;
private readonly ConcurrentQueue<ZmqMsg> _msgRecvQueue = new ConcurrentQueue<ZmqMsg>();
private BlockingCollection<NetMQMessage> _toSendQueue = new BlockingCollection<NetMQMessage>()
private Thread _subThread;
private Thread _pubThread;
...
// start
AsyncIO.ForceDotNet.Force();
NetMQConfig.Linger = new TimeSpan(0, 0, 0);
_pubThread = new Thread(_PubWorkerThread);
_pubThread.Start();
_subThread = new Thread(_SubWorkerThread);
_subThread.Start();
Still exists in latest version
I can confirm that this still exists in the latest version.
Environment
NetMQ Version: d297a27 Operating System: Windows 10 .NET Version: net47
Expected behaviour
NetMQ.Tests.NetMQQueueTests.EnqueueShouldNotBlockWhenCapacityIsZero
passes without triggering any assert operations.Actual behaviour
We observe the following exception when running
NetMQ.Tests.NetMQQueueTests.EnqueueShouldNotBlockWhenCapacityIsZero
:Poking around, looks like a race between
NetMQ.NetMQQueue.Dispose()
andNetMQ.NetMQQueue.Dequeue()
. Most likely,NetMQ.Msg.Close()
is called twice onm_dequeueMsg
.Steps to reproduce the behaviour
Originally, the bug was happeneing spuriously, but we can enhance the issue by slightly modifying the original test in
NetMQQueueTests.cs
(changes marked as comments below):