This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug exp/11803] New: TLS (__thread) on static class member variable trips assert


With GCC 4.4.0 and GDB 7.0, 7.1, and trunk, accessing thread-local static class variables causes an 
internal assert to be tripped.

$ cat mintest.cpp
class A { public: static __thread int num; };
__thread int A::num = 1;
int main() { return 0; }
$ g++ mintest.cpp -g -lpthread
$ ~/gdb-trunk/gdb/gdb ./a.out
GNU gdb (GDB) 7.2.50.20100709-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/jpotter/tls/a.out...done.
(gdb) break main
Breakpoint 1 at 0x400590: file mintest.cpp, line 3.
(gdb) run
Starting program: /home/jpotter/tls/a.out 
[Thread debugging using libthread_db enabled]

Breakpoint 1, main () at mintest.cpp:3
3	int main() { return 0; }
(gdb) print A::num
warning: static field's value depends on the current frame - bad debug info?
findvar.c:427: internal-error: read_var_value: Assertion `frame' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) 


And sure enough, in dwarf2loc.c:

1057 /* Thread-local accesses do require a frame.  */
1058 static CORE_ADDR
1059 needs_frame_tls_address (void *baton, CORE_ADDR offset)
1060 {
1061   struct needs_frame_baton *nf_baton = baton;
1062 
1063   nf_baton->needs_frame = 1;
1064   return 1;
1065 }

It seems that this isn't the case, at least on initial-exec GCC on x86_64, and GCC assumes that no 
frame is needed when producing DWARF info; I'm not familiar enough with DWARF's TLS support to 
know whether that's the actual issue, though.

-- 
           Summary: TLS (__thread) on static class member variable trips
                    assert
           Product: gdb
           Version: 7.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: exp
        AssignedTo: unassigned at sourceware dot org
        ReportedBy: jacob at durbatuluk dot us
                CC: gdb-prs at sourceware dot org


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]