9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Latchesar Ionkov <lucho@gmx.net>
To: Russ Cox <russcox@gmail.com>,
	Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] off-topic linux threading bug complaint
Date: Thu, 10 Feb 2005 15:24:59 -0500	[thread overview]
Message-ID: <20050210202459.GA14282@ionkov.net> (raw)
In-Reply-To: <ee9e417a05021010353997a398@mail.gmail.com>

The bug was reported to LKML back in October:

	http://www.ussg.iu.edu/hypermail/linux/kernel/0410.0/1141.html

	Lucho

On Thu, Feb 10, 2005 at 01:35:46PM -0500, Russ Cox said:
> I'm sorry for the off-topic post, but I have no idea
> where to send this and I suspect there are still Linux
> experts lurking here who do.  Please feel free to forward.
>
> 	$ uname -a
> 	Linux t23 2.6.8-1-686 #1 Thu Oct 7 03:15:25 EDT 2004 i686 GNU/Linux
> 	$
>
> This program creates a second pthread and then
> lets the first pthread exit:
>
> 	$ cat x.c
> 	#include <stdio.h>
> 	#include <unistd.h>
> 	#include <pthread.h>
>
> 	void*
> 	sleeper(void *a)
> 	{
> 		for(;;)
> 			sleep(1000);
> 	}
>
> 	int
> 	main(void)
> 	{
> 		pthread_t id;
>
> 		pthread_create(&id, 0, sleeper, 0);
> 		pthread_exit(0);
> 	}
> 	$ gcc x.c -lpthread
> 	$ ./a.out &
> 	[1] 4723
> 	$
>
> Because the first pthread has exited, the ps listing
> makes it look like the process is a zombie, even
> though it's still running:
>
> 	$ ps axwwu|grep a.out |grep -v grep
> 	rsc       4723  0.0  0.0     0    0 pts/2    Z    13:29   0:00
> [a.out] <defunct>
> 	$
>
> The -T and -L flags to ps don't help:
>
> 	$ ps -T axwwu|grep a.out |grep -v grep
> 	$ ps -L axwwu|grep a.out |grep -v grep
> 	$
>
> It's not ps just misdisplaying information: gdb cannot attach either.
>
> 	$ gdb a.out 4723
> 	GNU gdb 6.1-debian
> 	Copyright 2004 Free Software Foundation, Inc.
> 	GDB is free software, covered by the GNU General Public License, and you are
> 	welcome to change it and/or distribute copies of it under certain conditions.
> 	Type "show copying" to see the conditions.
> 	There is absolutely no warranty for GDB.  Type "show warranty" for details.
> 	This GDB was configured as "i386-linux"...Using host libthread_db
> library "/lib/tls/libthread_db.so.1".
>
> 	Attaching to program: /home/rsc/a.out, process 4723
> 	ptrace: Operation not permitted.
> 	/home/rsc/4723: No such file or directory.
> 	(gdb) quit
> 	$
>
> On the other hand, if I guess the process/thread id of the
> second pthread, then I can still look at that:
>
> 	$ gdb a.out 4724
> 	GNU gdb 6.1-debian
> 	Copyright 2004 Free Software Foundation, Inc.
> 	GDB is free software, covered by the GNU General Public License, and you are
> 	welcome to change it and/or distribute copies of it under certain conditions.
> 	Type "show copying" to see the conditions.
> 	There is absolutely no warranty for GDB.  Type "show warranty" for details.
> 	This GDB was configured as "i386-linux"...Using host libthread_db
> library "/lib/tls/libthread_db.so.1".
>
> 	Attaching to program: /home/rsc/a.out, process 4724
> 	Reading symbols from /lib/tls/libpthread.so.0...done.
> 	[Thread debugging using libthread_db enabled]
> 	[New Thread 1083603888 (LWP 4724)]
> 	Loaded symbols for /lib/tls/libpthread.so.0
> 	Reading symbols from /lib/tls/libc.so.6...done.
> 	Loaded symbols for /lib/tls/libc.so.6
> 	Reading symbols from /lib/ld-linux.so.2...done.
> 	Loaded symbols for /lib/ld-linux.so.2
> 	Reading symbols from /lib/libgcc_s.so.1...done.
> 	Loaded symbols for /lib/libgcc_s.so.1
> 	0x400dc5dc in nanosleep () from /lib/tls/libc.so.6
> 	(gdb) quit
> 	The program is running.  Quit anyway (and detach it)? (y or n) y
> 	Detaching from program: /home/rsc/a.out, process 4724
> 	$
>
> But that's stupid.  The process known as 4723 has not
> exited, and it should be debuggable, even though the
> pthread known as 4723 _has_ exited.
>
> Russ


  parent reply	other threads:[~2005-02-10 20:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-10 18:35 Russ Cox
2005-02-10 18:54 ` boyd, rounin
2005-02-10 19:16 ` bs
2005-02-10 19:19   ` Nigel Roles
2005-02-10 19:24     ` bs
2005-02-10 20:24 ` Latchesar Ionkov [this message]
2005-02-11 16:22   ` Ronald G. Minnich
2005-02-10 20:33 ` David Leimbach
2005-02-10 20:58   ` Russ Cox
2005-02-11  1:46 ` Taj Khattra
2005-02-11 16:15 ` Ronald G. Minnich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050210202459.GA14282@ionkov.net \
    --to=lucho@gmx.net \
    --cc=9fans@cse.psu.edu \
    --cc=russcox@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).