FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian GCC

 
 
LinkBack Thread Tools
 
Old 05-15-2010, 01:48 AM
Daniel Gibson
 
Default Bug#581700: Not started Threads cause Segfault on exit

Package: libphobos-4.1-dev
Version: 0.25-4.1.2-27
Severity: normal


Hi,

While trying to narrow down another bug (#581698) I noticed that my
program segfaults on exit, if there are Thread-objects that haven't
been start()ed.
While it probably doesn't make much sense to create Threads and not
start them, this shouldn't happen.
I ran it with gdb and got the following backtrace:

Program received signal SIGSEGV, Segmentation fault.
0xb7f6292b in pthread_detach () from /lib/i686/cmov/libpthread.so.0
(gdb) bt
#0 0xb7f6292b in pthread_detach () from /lib/i686/cmov/libpthread.so.0
#1 0x0805ad93 in _d_callfinalizer ()
#2 0x0805c5a6 in _D3gcx3Gcx11fullcollectMFPvZk ()
#3 0x0805ca54 in _D3gcx3Gcx16fullcollectshellMFZk ()
#4 0x0805cd8c in _D3gcx2GC18fullCollectNoStackMFZv ()
#5 0x0805a203 in gc_term ()
#6 0x0806166a in _d_run_main ()
#7 0x0805e33a in main ()

I think (but haven't tried to fix that yet) that the error is in
Thread's destructor (std/thread.d line 589/590):

if (state != TS.FINISHED)
pthread_detach(id);

The status of an unstarted Thread is TS.INITIAL - I don't know if it
is necessary to pthread_detach() a thread that hasn't run,
but if it isn't I'd suggest to change this to

if(state != TS.FINISHED && state != TS.INITIAL)
pthread_detach(id);

This Bug also applies gdc-4.3 and Digitalmars dmd.
I've attached a simple example to demonstrate the bug.

Cheers,
- Daniel


--- System information. ---
Architecture: i386
Kernel: Linux 2.6.32-3-686

Debian Release: squeeze/sid
500 testing security.debian.org
500 testing ftp.de.debian.org

--- Package information. ---
Depends (Version) | Installed
================================-+-==================
gdc-4.1 (= 0.25-4.1.2-27) | 0.25-4.1.2-27
zlib1g-dev (>= 1:1.2.3.3) | 1:1.2.3.4.dfsg-3


Package's Recommends field is empty.

Package's Suggests field is empty.
 
Old 05-15-2010, 07:46 PM
Iain Buclaw
 
Default Bug#581700: Not started Threads cause Segfault on exit

On 15 May 2010 02:48, Daniel Gibson <metalcaedes@gmail.com> wrote:

Package: libphobos-4.1-dev

Version: 0.25-4.1.2-27

Severity: normal





Hi,



While trying to narrow down another bug (#581698) I noticed that my

program segfaults on exit, if there are Thread-objects that haven't

been start()ed.

While it probably doesn't make much sense to create Threads and not

start them, this shouldn't happen.

I ran it with gdb and got the following backtrace:



Program received signal SIGSEGV, Segmentation fault.

0xb7f6292b in pthread_detach () from /lib/i686/cmov/libpthread.so.0

(gdb) bt

#0 *0xb7f6292b in pthread_detach () from /lib/i686/cmov/libpthread.so.0

#1 *0x0805ad93 in _d_callfinalizer ()

#2 *0x0805c5a6 in _D3gcx3Gcx11fullcollectMFPvZk ()

#3 *0x0805ca54 in _D3gcx3Gcx16fullcollectshellMFZk ()

#4 *0x0805cd8c in _D3gcx2GC18fullCollectNoStackMFZv ()

#5 *0x0805a203 in gc_term ()

#6 *0x0806166a in _d_run_main ()

#7 *0x0805e33a in main ()



I think (but haven't tried to fix that yet) that the error is in

Thread's destructor (std/thread.d line 589/590):



if (state != TS.FINISHED)

* *pthread_detach(id);



The status of an unstarted Thread is TS.INITIAL - I don't know if it

is necessary to pthread_detach() a thread that hasn't run,

but if it isn't I'd suggest to change this to



if(state != TS.FINISHED && state != TS.INITIAL)

* *pthread_detach(id);



Thanks for your bug report. I didn't actually notice you came up with a fix first time I read your message, but I came to the same conclusion whilst having a quick 5 minute look at it.

I'll see if a bug is raised upstream, but will include your small resolution in the next version gdc version.
Thanks Daniel.
Regards

--
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
 
Old 05-15-2010, 08:07 PM
Iain Buclaw
 
Default Bug#581700: Not started Threads cause Segfault on exit

Upstream bug is�http://d.puremagic.com/issues/show_bug.cgi?id=1960


--
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
 

Thread Tools




All times are GMT. The time now is 03:17 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org