public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug exp/11803] New: TLS (__thread) on static class member variable trips assert
@ 2010-07-09 20:44 jacob at durbatuluk dot us
  2010-07-16 18:02 ` [Bug exp/11803] " tromey at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: jacob at durbatuluk dot us @ 2010-07-09 20:44 UTC (permalink / raw)
  To: gdb-prs

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.


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

* [Bug exp/11803] TLS (__thread) on static class member variable trips assert
  2010-07-09 20:44 [Bug exp/11803] New: TLS (__thread) on static class member variable trips assert jacob at durbatuluk dot us
@ 2010-07-16 18:02 ` tromey at redhat dot com
  2010-09-13 15:41 ` lm at zork dot pl
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: tromey at redhat dot com @ 2010-07-16 18:02 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From tromey at redhat dot com  2010-07-16 18:02 -------
>From what I can tell, TLS needs registers, but not actually a frame
in the gdb internals sense.  Looking through the code paths, I don't
see anything actually using a frame.  And, it seems to me that these
frame checks are actually gdb internal consistency checks.
So, I think it is probably safe to change needs_frame_tls_address.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at redhat dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-07-16 18:02:40
               date|                            |


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.


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

* [Bug exp/11803] TLS (__thread) on static class member variable trips assert
  2010-07-09 20:44 [Bug exp/11803] New: TLS (__thread) on static class member variable trips assert jacob at durbatuluk dot us
  2010-07-16 18:02 ` [Bug exp/11803] " tromey at redhat dot com
@ 2010-09-13 15:41 ` lm at zork dot pl
  2010-09-14  7:33 ` lm at zork dot pl
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: lm at zork dot pl @ 2010-09-13 15:41 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From lm at zork dot pl  2010-09-13 15:41 -------
(In reply to comment #1)
> From what I can tell, TLS needs registers, but not actually a frame
> in the gdb internals sense.  Looking through the code paths, I don't
> see anything actually using a frame.  And, it seems to me that these
> frame checks are actually gdb internal consistency checks.
> So, I think it is probably safe to change needs_frame_tls_address.
> 

I just run into this on i686. I verified test program with gdb 7.2.50.20100913-
cvs and gcc-4.5.1 under linux it breaks in the same way.

In my case this bug breaks all IDE front ends when debugging wxWidgets they try 
to access all local variables when stepping through code, and wxString class has 
thread-local static class variable.

Changing needs_frame_tls_address fixes this problem.


-- 


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.


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

* [Bug exp/11803] TLS (__thread) on static class member variable trips assert
  2010-07-09 20:44 [Bug exp/11803] New: TLS (__thread) on static class member variable trips assert jacob at durbatuluk dot us
  2010-07-16 18:02 ` [Bug exp/11803] " tromey at redhat dot com
  2010-09-13 15:41 ` lm at zork dot pl
@ 2010-09-14  7:33 ` lm at zork dot pl
  2010-09-14 17:47 ` tromey at redhat dot com
  2010-09-14 19:10 ` tromey at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: lm at zork dot pl @ 2010-09-14  7:33 UTC (permalink / raw)
  To: gdb-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lm at zork dot pl


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.


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

* [Bug exp/11803] TLS (__thread) on static class member variable trips assert
  2010-07-09 20:44 [Bug exp/11803] New: TLS (__thread) on static class member variable trips assert jacob at durbatuluk dot us
                   ` (2 preceding siblings ...)
  2010-09-14  7:33 ` lm at zork dot pl
@ 2010-09-14 17:47 ` tromey at redhat dot com
  2010-09-14 19:10 ` tromey at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: tromey at redhat dot com @ 2010-09-14 17:47 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From tromey at redhat dot com  2010-09-14 17:47 -------
Testing a patch.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at sourceware dot|tromey at redhat dot com
                   |org                         |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-07-16 18:02:40         |2010-09-14 17:47:05
               date|                            |


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.


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

* [Bug exp/11803] TLS (__thread) on static class member variable trips assert
  2010-07-09 20:44 [Bug exp/11803] New: TLS (__thread) on static class member variable trips assert jacob at durbatuluk dot us
                   ` (3 preceding siblings ...)
  2010-09-14 17:47 ` tromey at redhat dot com
@ 2010-09-14 19:10 ` tromey at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: tromey at redhat dot com @ 2010-09-14 19:10 UTC (permalink / raw)
  To: gdb-prs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2010-09-14 19:08 -------
Subject: Bug 11803

CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2010-09-14 19:08:30

Modified files:
	gdb            : ChangeLog value.c 
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.threads: tls.c tls.exp 

Log message:
	gdb
	PR exp/11803:
	* value.c (value_static_field): Use value_of_variable.
	gdb/testsuite
	PR exp/11803:
	* gdb.threads/tls.exp: Use C++.
	(check_thread_local): Use K::another_thread_local.
	* gdb.threads/tls.c (class K): New.
	(another_thread_local): Now a member of K.
	(spin): Update.  No longer K&R C.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.12180&r2=1.12181
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/value.c.diff?cvsroot=src&r1=1.111&r2=1.112
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2447&r2=1.2448
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.threads/tls.c.diff?cvsroot=src&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.threads/tls.exp.diff?cvsroot=src&r1=1.12&r2=1.13


------- Additional Comments From tromey at redhat dot com  2010-09-14 19:10 -------
Fix checked in.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|7.1                         |7.3


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.


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

end of thread, other threads:[~2010-09-14 19:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-09 20:44 [Bug exp/11803] New: TLS (__thread) on static class member variable trips assert jacob at durbatuluk dot us
2010-07-16 18:02 ` [Bug exp/11803] " tromey at redhat dot com
2010-09-13 15:41 ` lm at zork dot pl
2010-09-14  7:33 ` lm at zork dot pl
2010-09-14 17:47 ` tromey at redhat dot com
2010-09-14 19:10 ` tromey 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).