gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: abnormal thread termination


From: Riccardo Mottola
Subject: Re: abnormal thread termination
Date: Mon, 13 Jul 2015 20:05:27 +0200
User-agent: Mozilla/5.0 (X11; FreeBSD i386; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33.1

Hi,

Richard Frith-Macdonald wrote:
This message indicates a bug in the program as far as I can tell from looking 
at the source;

It’s generated by the handler set by pthread_key_create() and should only be 
called if the thread exits while the thread-specific data associate with the 
key (ie the NSThread object) is non-null.

When a thread is detached by NSThread, it runs a method and calls +exit when 
the method completes, and +exit destroys the NSThread object and sets the 
thread-specific data to null.
When a non-gnustep thread is used for gnustep code, there are two functions 
provided to register/deregister it (and the latter similarly destroys the 
NSThread instance and nulls-out the thread-specific variable).

So seeing the message means that a thread has somehow exited without cleaning 
up its gnustep related thread-specific data (thus leaking an NSThread instance 
and a presumably other related objects).

I don’t see how that can happen other than by an application level bug (ie some 
code in that thread calls pthread_exit() or something similar).

Of course, I may have missed spotting some race condition or logic error in the 
code

I don't guarantee that my code is correct, I haven't yet tested it on the Mac. The code worked "fine" before I started detaching the method in a separate thread by use of detachNewThreadSelector. The detached method allocates its own autorelease pool.
It actually still appears to work and do everything - except the message.

I really do not do anything at the thread exit and do not manipulate the thread otherwise in the code: I do not hold a reference for it.

I tried running the code in a debugger and set a breakpoint in NSException and don't get any, so the exception is happening in the thread clenanup perhaps? Perhaps a memory problem that is now evident?

The gdb looks like:

[New Thread 2bc0a600 (LWP 100913/GDFCompanion)]
2015-07-13 17:56:43.232 GDFCompanion[2746:100913] name: Aborted, 66
2015-07-13 17:56:43.232 GDFCompanion[2746:100913] name: Failed, 4
WARNING thread 0x2d441e78 terminated without calling +exit!

The two messages between are logs, don't get fooled by the menacious sounding Aborted and Failed names.

I wonder that GDB reports the thread to have a certain ID, the warning message though another! Yet there are no other threads spawned: the main thread and the worker thread.

What could I try to watch besides an exception?

Riccardo





reply via email to

[Prev in Thread] Current Thread [Next in Thread]