Solved A problem with unexpected termination

I am developing a certain service and these days have been testing it using a stress Windows application. Sometimes the service terminates without any message. No core dump. I can reproduce the conditions under which it happens and when I run the service under GDB the latter reports:

Code:
Thread 3 received signal SIGPIPE, Broken pipe.
Sent by kernel.
[Switching to LWP 100162 of process 1359]
_sendto () at _sendto.S:4
warning: 4      _sendto.S: No such file or directory

There isn't a single call to sendto in the service. How do I deal with that? What am I expected to do next?
 
Hard to tell without the source code. You might be using some library function that itself uses sendto(2) to send the data. And it might be sending data to a socket that got closed for whatever reason.

Code:
     [EPIPE]            The socket is unable to send anymore data
                        (SBS_CANTSENDMORE has been set on the socket).  This
                        typically means that the socket is not connected.
 
That's probably a red Herring. SIGPIPE is usually not caught for exiting. But if you run a program in gdb it will trigger the debugger on SIGPIPE.

Code:
handle SIGPIPE nostop pass noprint
 
You might be using some library function that itself uses sendto(2) to send the data.

I only explicitly specify pthread and rt. The service only calls send on accepted connections. For example:

Code:
    else {
        iResult = send(this->kk, http404, sizeof(http404) - 1, 0);
        if (iResult == -1) printf("%x : %d : send 404 failed: %d\n", this->kk, this->pSess->kk, errno);
        else printf("%x : %d : Sent 404\n", this->kk, this->pSess->kk);
    }

    return iResult;
}

I would expect to get -1, not termination.
 
But if you run a program in gdb it will trigger the debugger on SIGPIPE.

That's exactly what I do as is written in my original posting.

And there's worse news. If at this point I shortly press the power button, which usually shuts down the operating system and computer, I get:

Code:
Stopping cron.
Waiting for PIDS: 1274.
Stopping sshd.
Waiting for PIDS: 1299.
Stopping devd.
Waiting for PIDS: 1002.
Writing entropy file: .
Writing early boot entropy file: .
Terminated
.
Nov 12 16:46:15 s17 syslogd: exiting on signal 15

And it hangs...
 
Back
Top