This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug threads/13448] New: char[] thread local variables displayedincorrectly
- From: "ben.cohen at kognitio dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Tue, 29 Nov 2011 12:29:21 +0000
- Subject: [Bug threads/13448] New: char[] thread local variables displayedincorrectly
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=13448
Bug #: 13448
Summary: char[] thread local variables displayed incorrectly
Product: gdb
Version: 7.3
Status: NEW
Severity: normal
Priority: P2
Component: threads
AssignedTo: unassigned@sourceware.org
ReportedBy: ben.cohen@kognitio.com
Classification: Unclassified
Created attachment 6079
--> http://sourceware.org/bugzilla/attachment.cgi?id=6079
Example of incorrect "print myname" and then correct after bt
Thread-local variables that are of type char[] aren't printed correctly for
some threads.
Compile and run the following file and use gdb to attach or debug a core dump.
Then "print myname" or "thread apply all print myname" prints some unknown
number rather than that variable. See the attached file for an example of the
output.
If you subsequently do for example a backtrace then the same print command will
work after that.
If you change the program so that either of the threads does "while (1) {}"
rather than sleeping then "t a a p myname" works correctly from the start.
Perhaps it is something to do with the threads being in a system call?
If you use for example a char, int or int[] thread local variable this bug
doesn't happen.
This is a bug in 7.3.1 but not in 7.1 or 7.2 (I haven't tried 7.3).
/* thread_local_var.c: Compile with:
* gcc -o thread_local_var thread_local_var.c -pthread -ggdb
*/
#include <string.h>
#include <pthread.h>
__thread char myname[128] = "(unnamed thread)";
void *th(void* x)
{
strcpy(myname, "a new thread");
while(1) sleep(1);
}
main()
{
pthread_t t;
strcpy(myname, "this is the main thread");
pthread_create(&t, NULL, th, NULL);
while(1) sleep(1);
}
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.