public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "jacob at durbatuluk dot us" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug exp/11803] New: TLS (__thread) on static class member variable trips assert
Date: Fri, 09 Jul 2010 20:44:00 -0000	[thread overview]
Message-ID: <20100709204412.11803.jacob@durbatuluk.us> (raw)

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.


             reply	other threads:[~2010-07-09 20:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-09 20:44 jacob at durbatuluk dot us [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100709204412.11803.jacob@durbatuluk.us \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).