Re: SIGTRAP after writing to socket
Re: SIGTRAP after writing to socket
- Subject: Re: SIGTRAP after writing to socket
- From: Quinn <email@hidden>
- Date: Wed, 13 Dec 2006 11:31:34 +0000
At 20:53 +0100 1/12/06, Stefan Werner wrote:
Do I maybe need to take special precautions for catching signals
that come from a subthread of my app?
I doubt this has anything to do with signals (except, maybe, that the
signal delivery is altering the timing of other code, or causing a
EINTR that other code isn't handling properly). Earlier I wrote:
Given that there's no debugger involved, the other place I've seen
these sort of exceptions is when certain pieces of system software
'panic'. For example, CF's HALT macro (used when it detects that
things are completely messed up) expands to a breakpoint instruction
("trap" on PPC, "int3" on Intel). dyld does the same thing.
Usually when this happens you get a message on the console that
explains what happened. Do you see anything like this?
and the stack trace that you posted backs this up. Take a look at
the source for CFRunLoopWakeUp. The following URL is for the 10.4
version in Darwin:
<http://www.opensource.apple.com/darwinsource/10.4/CF-368/RunLoop.subproj/CFRunLoop.c>
[This link requires an APSL <http://www.opensource.apple.com/apsl/>
account.]
It seems that if someone tries to wake up the runloop and the Mach
message send to the wakeup port fails, CF calls HALT, which
translates to a breakpoint instruction and you die with
EXC_BREAKPOINT/SIGTRAP.
This raises a couple of interesting questions:
A. Why is the Mach message send failing?
B. Why is Foundation calling CFRunLoopWakeUp?
I don't have a good answer to A. The best I can suggest is that you
set a breakpoint on CFRunLoopWakeUp and step through it (at the
assembly level, using GDB's "ni" command) and see what the return
value of __CFSendTrivialMachMessage is. My guess is that the wakeup
port has somehow been closed.
With regards point B, I looked this up in the Foundation sources and
it looks like the thread that's executing this code is an internal
thread that's created by Foundation's NSTask to wait for process
termination. This thread starts up and calls _waitForTermination
which waits for a particular child process to terminate (using
<x-man-page://2/wait4>). When that happens, it wakes up (using
CFRunLoopWakeUp) the runloop associated with the NSTask object. It's
this wakeup that's dying with a HALT.
Can you please post the entire crash log associated with this crash.
There are lots of threads flying around here, and a full crash log
will help me understand why threads are which.
S+E
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden