Closed biocommando closed 4 years ago
This with a particular version, or HEAD?
It's possibly related to nng_sendmsg semantics where on success NNG takes ownership of the message. But using
will mean it is Dispose'd by the caller- which calls free()
.
The behaviour of ISocket::SendMsg
likely needs to be changed to release ownership of IMessage::NngMsg
if the calls succeeds.
That seems to be it. In Socket.cs change SendMsg
to:
public NngResult<Unit> SendMsg(IMessage message, Defines.NngFlag flags = default)
{
var res = Unit.OkIfZero(nng_sendmsg(NngSocket, message.NngMsg, flags));
if (res.IsOk())
{
var _ = message.Take();
}
return res;
}
Let me know if that works for you. I'll need to check if this is needed elsewhere.
I'm using the (then) latest release version through NuGet (1.2.4-rc0).
When I replace this line reqSocket.SendMsg(msg).Unwrap();
with the code below the application doesn't crash anymore.
var r = reqSocket.SendMsg(msg);
if (r.IsOk()) _ = msg.Take();
r.Unwrap();
So yes, your suggested fix does the job :)
Great I'll go ahead and apply this fix.
Sorry about the nuget package. My code signing cert expired in January and I finally got a new one.
I encountered an issue where I get "malloc(): memory corruption (fast)" or other similar errors (using .NET Core 3.1 on Linux) when using ISendSocket.SendMsg(IMessage). Here's the minimal program that will reproduce the issue: