[gccsdk] GCC4 crash with SDL threading

alan buckley alan_baa at hotmail.com
Tue Jul 8 04:06:23 PDT 2008

> On Mon, 7 Jul 2008 22:48:05 +0100 Alex Waugh wrote:
> alan buckley  wrote:
>> The threading program had a different problem after that where
>> the logic meant a pthread_yield was being called during a KILL signal
>> handler. This reports:
>> pthreads: *** fatal error aborting ***
>> pthread_yield called with context switching disabled.
>> Should this really be a fatal error?
> In most cases yes, as it is indicative of a major failure. Some of the
> pthreads code relies on pthread_yield guaranteeing to cause a context
> switch.

Thanks for the explanation of why it must be this way.

>> If it should, is there anyway I can test for context switching being
>> disabled in C code so I can avoid the call to pthread_yield.
> Normally, context switching cannot be disabled outside of
> unixlib code. However signal handlers are a special case, mostly because
> when you get a serious signal such as a segfault it is hard enough
> already making sure the recovery is robust, without worrying about
> threading problems as well.
> The real solution is to improve the signal handlers to support context
> switching, but in the absense of that, don't try to call pthread_yield
> from a signal handler.

OK. The problem was in imported code using a library function. I was
hoping there was some function I could call in unixlib to check it was
OK to call pthread_yield.

I'll have to look for another solution.

Thanks for the reply,

The John Lewis Clearance - save up to 50% with FREE delivery

More information about the gcc mailing list