This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
Re: threads/1484: Sol9/x86 problem attaching to process with exited/unjoinedthread
- From: Jeff Trawick <trawick at attglobal dot net>
- To: kettenis at gnu dot org
- Cc: gdb-prs at sources dot redhat dot com,
- Date: 16 Jan 2004 14:58:00 -0000
- Subject: Re: threads/1484: Sol9/x86 problem attaching to process with exited/unjoinedthread
- Reply-to: Jeff Trawick <trawick at attglobal dot net>
The following reply was made to PR threads/1484; it has been noted by GNATS.
From: Jeff Trawick <trawick@attglobal.net>
To: gdb-gnats@sources.redhat.com
Cc:
Subject: Re: threads/1484: Sol9/x86 problem attaching to process with exited/unjoined
thread
Date: Fri, 16 Jan 2004 09:53:31 -0500
This is a multi-part message in MIME format.
--------------030502070809030002030003
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Attached is a simple testcase for testing the problem. The way I built
it is in a comment at the top of the file. There are two ways to run it:
a) ./a.out
This creates 4 detached threads that block forever and 1 joinable thread
that exits immediately. This exhibits the reported problem.
Here is a sample gdb 6 session trying to get thread info for this flavor
of run:
$ ~/dist/gdb-6.0/gdb/gdb ./a.out 984
GNU gdb 6.0
Copyright 2003 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-pc-solaris2.9"...
Attaching to program
`/export/home/trawick/wrk/port/testtool/platform_test/a.out', process 984
Reading symbols from /usr/lib/libpthread.so.1...done.
Loaded symbols for /usr/lib/libpthread.so.1
Reading symbols from /usr/lib/libc.so.1...done.
Loaded symbols for /usr/lib/libc.so.1
Reading symbols from /usr/lib/libdl.so.1...done.
Loaded symbols for /usr/lib/libdl.so.1
Reading symbols from /usr/lib/libthread.so.1...done.
Loaded symbols for /usr/lib/libthread.so.1
sol-thread active.
Retry #1:
Retry #2:
Retry #3:
Retry #4:
[New LWP 1 ]
[New Thread 1 (LWP 1)]
Symbols already loaded for /usr/lib/libpthread.so.1
Symbols already loaded for /usr/lib/libc.so.1
Symbols already loaded for /usr/lib/libdl.so.1
Symbols already loaded for /usr/lib/libthread.so.1
[Switching to Thread 1 (LWP 1)]
0xddacd2c9 in _poll () from /usr/lib/libc.so.1
(gdb) info thread
11 Thread 3 procfs: couldn't find pid 984 (kernel thread 3)
in procinfo list.
(gdb)
b) ./a.out no_joinable
This creates 4 threads that block forever. This does not exhibit the
problem, as seen by the gdb session below:
$ ~/dist/gdb-6.0/gdb/gdb ./a.out 997
GNU gdb 6.0
Copyright 2003 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-pc-solaris2.9"...
Attaching to program
`/export/home/trawick/wrk/port/testtool/platform_test/a.out', process 997
Reading symbols from /usr/lib/libpthread.so.1...done.
Loaded symbols for /usr/lib/libpthread.so.1
Reading symbols from /usr/lib/libc.so.1...done.
Loaded symbols for /usr/lib/libc.so.1
Reading symbols from /usr/lib/libdl.so.1...done.
Loaded symbols for /usr/lib/libdl.so.1
Reading symbols from /usr/lib/libthread.so.1...done.
Loaded symbols for /usr/lib/libthread.so.1
sol-thread active.
Retry #1:
Retry #2:
Retry #3:
Retry #4:
[New LWP 1 ]
[New Thread 1 (LWP 1)]
Symbols already loaded for /usr/lib/libpthread.so.1
Symbols already loaded for /usr/lib/libc.so.1
Symbols already loaded for /usr/lib/libdl.so.1
Symbols already loaded for /usr/lib/libthread.so.1
[Switching to Thread 1 (LWP 1)]
0xddacd2c9 in _poll () from /usr/lib/libc.so.1
(gdb) info thread
10 Thread 5 (LWP 5) 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
9 Thread 4 (LWP 4) 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
8 Thread 3 (LWP 3) 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
7 Thread 2 (LWP 2) 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
6 LWP 2 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
5 LWP 3 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
4 LWP 4 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
3 LWP 5 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
* 2 Thread 1 (LWP 1) 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
1 LWP 1 0xddacd2c9 in _poll () from /usr/lib/libc.so.1
(gdb)
(Please accept my apologies for my delay in updating the PR with a
simpler testcase than Apache 2. I appreciate the effort it requires to
address these bug reports!!)
--------------030502070809030002030003
Content-Type: text/plain;
name="gdb_attach.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="gdb_attach.c"
/* building: gcc -g -D_REENTRANT gdb_attach.c -lpthread
*/
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <pthread.h>
static void *normalThread(void *arg)
{
do {
poll(NULL, 0, INT_MAX);
} while (errno == EINTR);
assert(1 != 1);
}
static void *joinableThread(void *arg)
{
pthread_exit(NULL);
assert(1 != 1);
}
int main(int argc, char **argv)
{
int rc;
pthread_t tid;
pthread_attr_t normalAttributes;
pthread_attr_t joinableAttributes;
int joinable = 1;
if (argc > 1) {
if (!strcasecmp(argv[1], "no_joinable")) {
joinable = 0;
}
else {
fprintf(stderr, "Usage: %s [no_joinable]\n",
argv[0]);
exit(1);
}
}
rc = pthread_attr_init(&normalAttributes);
assert(rc == 0);
rc = pthread_attr_setdetachstate(&normalAttributes, PTHREAD_CREATE_DETACHED);
assert(rc == 0);
rc = pthread_attr_init(&joinableAttributes);
assert(rc == 0);
rc = pthread_attr_setdetachstate(&joinableAttributes, PTHREAD_CREATE_JOINABLE);
assert(rc == 0);
/* 1: normal thread blocked in poll() */
rc = pthread_create(&tid, &normalAttributes, normalThread, NULL);
assert(rc == 0);
if (joinable) {
/* 2: exited thread that is joinable */
rc = pthread_create(&tid, &joinableAttributes, joinableThread, NULL);
assert(rc == 0);
}
/* 3: normal thread blocked in poll() */
rc = pthread_create(&tid, &normalAttributes, normalThread, NULL);
assert(rc == 0);
/* 4: normal thread blocked in poll() */
rc = pthread_create(&tid, &normalAttributes, normalThread, NULL);
assert(rc == 0);
/* 5: normal thread blocked in poll() */
rc = pthread_create(&tid, &normalAttributes, normalThread, NULL);
assert(rc == 0);
do {
poll(NULL, 0, INT_MAX);
} while (errno == EINTR);
assert(1 != 1);
return 0;
}
--------------030502070809030002030003--