Open smalik007 opened 1 year ago
You shouldn't get SIGPIPEs as there is a call to
signal(SIGPIPE, SIG_IGN);
in Socket_outInitialize. The return from this call isn't currently checked, but on your (ARM?) platform it looks like it might have failed? There is another call to ignore these signals in Socket_new, triggered by the NOSIGPIPE compile definition.
Yes I also thought so, it should be ignored, but sadly it's not. So if I define NOSIGPIPE then it should be correctly ignored right ?
If the system call works, yes. I would check the error return from the signal(SIGPIPE, SIG_IGN); call to see if that provides any useful information.
I tried with defining NOSIGPIPE but the crash is still reproducible.
You need to look at the return values from
signal(SIGPIPE, SIG_IGN);
and
setsockopt(sock, SOL_SOCKET, SO_NOSIGPIPE, (void)&opt, sizeof(opt))
and what the errno codes are, if the return value is -1. I'm thinking they must fail to result in this behaviour. I don't have your environment to try it out.
I ran into the same problem with paho.mqtt.c version 1.3.13.
Looks like _signal(SIGPIPE, SIGIGN) doesn't really prevent to broken pipe signal when socket write or send is called and connection is just closing/closed.
Workaround for this might be to use send -method instead with MSG_NOSIGNAL -flag. I already made a fork testing pusposes to fix our system https://github.com/eclipse/paho.mqtt.c/compare/master...bulpper:paho.mqtt.c:sigpipefix
Describe the bug I am using paho.mqtt.cpp library that uses the c sdk, I am experiencing crashes from the c-sdk side. paho.mqtt.cpp version : v1.2.0 paho.mqtt.c version : v1.3.12 I am using MQTTAsync publisher/subcriber. The library is dyncamically linked with the application.
More Details The application is using two client,
Platform details Machine : aarch64 OS: ubuntu 18.04
To Reproduce The issue is random and usually occurs when mqtt client lost the connection and tries to reconnect.
Log files Crash 1 : SIGPIPE, Broken pipe