public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug threads/13448] New: char[] thread local variables displayed incorrectly
@ 2011-11-29 12:29 ben.cohen at kognitio dot com
  2011-11-29 14:50 ` [Bug threads/13448] " ben.cohen at kognitio dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ben.cohen at kognitio dot com @ 2011-11-29 12:29 UTC (permalink / raw)
  To: gdb-prs

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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug threads/13448] char[] thread local variables displayed incorrectly
  2011-11-29 12:29 [Bug threads/13448] New: char[] thread local variables displayed incorrectly ben.cohen at kognitio dot com
@ 2011-11-29 14:50 ` ben.cohen at kognitio dot com
  2011-11-29 14:51 ` ben.cohen at kognitio dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ben.cohen at kognitio dot com @ 2011-11-29 14:50 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13448

Ben Cohen <ben.cohen at kognitio dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|7.3                         |HEAD

--- Comment #1 from Ben Cohen <ben.cohen at kognitio dot com> 2011-11-29 14:49:51 UTC ---
I've just tried the gdb-7.3.50.20111129 snapshot and that still has the bug.

-- 
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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug threads/13448] char[] thread local variables displayed incorrectly
  2011-11-29 12:29 [Bug threads/13448] New: char[] thread local variables displayed incorrectly ben.cohen at kognitio dot com
  2011-11-29 14:50 ` [Bug threads/13448] " ben.cohen at kognitio dot com
@ 2011-11-29 14:51 ` ben.cohen at kognitio dot com
  2011-11-29 18:14 ` tromey at redhat dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ben.cohen at kognitio dot com @ 2011-11-29 14:51 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13448

Ben Cohen <ben.cohen at kognitio dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ben.cohen at kognitio dot
                   |                            |com

--- Comment #2 from Ben Cohen <ben.cohen at kognitio dot com> 2011-11-29 14:51:10 UTC ---
I've just tried the gdb-7.3.50.20111129 snapshot and that still has the bug.

-- 
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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug threads/13448] char[] thread local variables displayed incorrectly
  2011-11-29 12:29 [Bug threads/13448] New: char[] thread local variables displayed incorrectly ben.cohen at kognitio dot com
  2011-11-29 14:50 ` [Bug threads/13448] " ben.cohen at kognitio dot com
  2011-11-29 14:51 ` ben.cohen at kognitio dot com
@ 2011-11-29 18:14 ` tromey at redhat dot com
  2011-11-29 23:15 ` jan.kratochvil at redhat dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at redhat dot com @ 2011-11-29 18:14 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13448

Tom Tromey <tromey at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com

--- Comment #3 from Tom Tromey <tromey at redhat dot com> 2011-11-29 18:13:24 UTC ---
I am not sure what changed since 7.2, but the bug is that
decode_locdesc (ugh) returns 0 for "myname", because it has
a non-trivial DW_AT_location.  This leaves it out of the psymtab,
so "print myname" finds the minimal symbol, which doesn't have a type.
A "bt" causes full symbols to be read, making this work again.

-- 
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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug threads/13448] char[] thread local variables displayed incorrectly
  2011-11-29 12:29 [Bug threads/13448] New: char[] thread local variables displayed incorrectly ben.cohen at kognitio dot com
                   ` (2 preceding siblings ...)
  2011-11-29 18:14 ` tromey at redhat dot com
@ 2011-11-29 23:15 ` jan.kratochvil at redhat dot com
  2011-12-01  2:34 ` jan.kratochvil at redhat dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-11-29 23:15 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13448

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jan.kratochvil at redhat
                   |                            |dot com

--- Comment #4 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-11-29 23:14:14 UTC ---
9602d20e52e1a2291bd9edbdf98e4d82995a385e is the first bad commit
commit 9602d20e52e1a2291bd9edbdf98e4d82995a385e
Author: Jerome Guitton <guitton@adacore.com>
Date:   Mon Jul 26 09:29:59 2010 +0000

    gdb/
        * dwarf2read.c (add_partial_symbol): Do not add a global variable if
        its adress is null. Add comment to explain why.
        (new_symbol): Ditto.

-- 
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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug threads/13448] char[] thread local variables displayed incorrectly
  2011-11-29 12:29 [Bug threads/13448] New: char[] thread local variables displayed incorrectly ben.cohen at kognitio dot com
                   ` (3 preceding siblings ...)
  2011-11-29 23:15 ` jan.kratochvil at redhat dot com
@ 2011-12-01  2:34 ` jan.kratochvil at redhat dot com
  2011-12-02  1:09 ` jan.kratochvil at redhat dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-12-01  2:34 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13448

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at sourceware    |jan.kratochvil at redhat
                   |dot org                     |dot com

--- Comment #5 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-12-01 02:34:05 UTC ---
Created attachment 6081
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6081
Fix+testcase and a testcase for the patch which regressed it.

Not regression tested yet.

-- 
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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug threads/13448] char[] thread local variables displayed incorrectly
  2011-11-29 12:29 [Bug threads/13448] New: char[] thread local variables displayed incorrectly ben.cohen at kognitio dot com
                   ` (4 preceding siblings ...)
  2011-12-01  2:34 ` jan.kratochvil at redhat dot com
@ 2011-12-02  1:09 ` jan.kratochvil at redhat dot com
  2011-12-02 17:02 ` cvs-commit at gcc dot gnu.org
  2011-12-02 17:03 ` jan.kratochvil at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-12-02  1:09 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13448

--- Comment #6 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-12-02 01:08:51 UTC ---
[patch] Regressed TLS variables type (PR 13448)
http://sourceware.org/ml/gdb-patches/2011-12/msg00030.html

-- 
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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug threads/13448] char[] thread local variables displayed incorrectly
  2011-11-29 12:29 [Bug threads/13448] New: char[] thread local variables displayed incorrectly ben.cohen at kognitio dot com
                   ` (5 preceding siblings ...)
  2011-12-02  1:09 ` jan.kratochvil at redhat dot com
@ 2011-12-02 17:02 ` cvs-commit at gcc dot gnu.org
  2011-12-02 17:03 ` jan.kratochvil at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2011-12-02 17:02 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13448

--- Comment #7 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> 2011-12-02 17:01:25 UTC ---
CVSROOT:    /cvs/src
Module name:    src
Changes by:    jkratoch@sourceware.org    2011-12-02 17:01:21

Modified files:
    gdb            : ChangeLog dwarf2read.c 
    gdb/testsuite  : ChangeLog 
Added files:
    gdb/testsuite/gdb.dwarf2: dw2-var-zero-addr.S 
                              dw2-var-zero-addr.exp 
    gdb/testsuite/gdb.threads: tls-var-main.c tls-var.c tls-var.exp 

Log message:
    gdb/
    PR threads/13448
    * dwarf2read.c (decode_locdesc): Handle DW_OP_const8u.
    For DW_OP_GNU_push_tls_address increment the value, new comment for it.

    gdb/testsuite/
    PR threads/13448
    * gdb.dwarf2/dw2-var-zero-addr.S: New file.
    * gdb.dwarf2/dw2-var-zero-addr.exp: New file.
    * gdb.threads/tls-var-main.c: New file.
    * gdb.threads/tls-var.c: New file.
    * gdb.threads/tls-var.exp: New file.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.13567&r2=1.13568
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/dwarf2read.c.diff?cvsroot=src&r1=1.583&r2=1.584
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2956&r2=1.2957
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.S.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.threads/tls-var-main.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.threads/tls-var.c.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.threads/tls-var.exp.diff?cvsroot=src&r1=NONE&r2=1.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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug threads/13448] char[] thread local variables displayed incorrectly
  2011-11-29 12:29 [Bug threads/13448] New: char[] thread local variables displayed incorrectly ben.cohen at kognitio dot com
                   ` (6 preceding siblings ...)
  2011-12-02 17:02 ` cvs-commit at gcc dot gnu.org
@ 2011-12-02 17:03 ` jan.kratochvil at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: jan.kratochvil at redhat dot com @ 2011-12-02 17:03 UTC (permalink / raw)
  To: gdb-prs

http://sourceware.org/bugzilla/show_bug.cgi?id=13448

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #8 from Jan Kratochvil <jan.kratochvil at redhat dot com> 2011-12-02 17:02:10 UTC ---
Checked in.

-- 
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.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-12-02 17:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-29 12:29 [Bug threads/13448] New: char[] thread local variables displayed incorrectly ben.cohen at kognitio dot com
2011-11-29 14:50 ` [Bug threads/13448] " ben.cohen at kognitio dot com
2011-11-29 14:51 ` ben.cohen at kognitio dot com
2011-11-29 18:14 ` tromey at redhat dot com
2011-11-29 23:15 ` jan.kratochvil at redhat dot com
2011-12-01  2:34 ` jan.kratochvil at redhat dot com
2011-12-02  1:09 ` jan.kratochvil at redhat dot com
2011-12-02 17:02 ` cvs-commit at gcc dot gnu.org
2011-12-02 17:03 ` jan.kratochvil at redhat dot com

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 read-only IMAP folder(s) and NNTP newsgroup(s).