Re: Crash in CFReadStreamOpen
Re: Crash in CFReadStreamOpen
- Subject: Re: Crash in CFReadStreamOpen
- From: Benoit Foucher <email@hidden>
- Date: Wed, 27 May 2009 00:12:25 +0200
On May 26, 2009, at 11:35 PM, Jens Alfke wrote:
On May 26, 2009, at 1:42 PM, Benoit Foucher wrote:
I'm getting an EXC_BAD_ACCESS crash in CFReadSreamOpen and I don't
understand why. The code only fails with OS X 10.5.7. It works fine
on 10.5.6. I wonder if this is perhaps because I add the stream to
another thread's run loop from the main thread. However, I didn't
see any mention of this not being thread safe -- on the contrary
the documentation seems to indicate that CF run loop functions are
thread safe...
I've had trouble in the past with thread-safety of CFRunLoop,
regardless of what the docs say.
Scheduling something on a different thread's runloop is a really
unusual thing. Ordinarily you'd do the setup and scheduling (i.e.
opening the stream) on the same thread that will be handling the
events. What's your code trying to do?
It's trying to open the stream's connection without blocking and get a
notification through a callback when the stream is opened. I have a
dedicated thread for running the run loop and I register the stream
with this dedicated thread's run loop from the calling thread (the
calling thread is busy doing something else after that -- it can't run
a run loop). So far, it worked well. I'll try to change my code to do
the registration with the run loop from the thread that is running it
and see if this solves the crash. Thanks for your help.
Cheers,
Benoit.
—Jens
_______________________________________________
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