RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1080656 - [RHEL6] Can't access TLS variables in statically linked binaries
Summary: [RHEL6] Can't access TLS variables in statically linked binaries
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: gdb
Version: 6.6
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Sergio Durigan Junior
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks: 1005265
TreeView+ depends on / blocked
 
Reported: 2014-03-25 21:37 UTC by Ben Woodard
Modified: 2014-10-14 07:28 UTC (History)
5 users (show)

Fixed In Version: gdb-7.2-72.el6
Doc Type: Bug Fix
Doc Text:
Cause: GDB could not correctly access TLS (Thread Local Storage) data on statically linked binaries. Consequence: The user was not able to inspect TLS data on the program being debugged, if this program was linked statically. Fix: GDB now correctly accesses TLS data on statically linked binaries. Result: The user can now inspect the TLS data on a statically linked binary.
Clone Of:
: 1080657 1080660 (view as bug list)
Environment:
Last Closed: 2014-10-14 07:28:13 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
reproducer (656 bytes, text/x-csrc)
2014-03-25 21:40 UTC, Ben Woodard
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1534 0 normal SHIPPED_LIVE gdb bug fix and enhancement update 2014-10-14 01:21:50 UTC

Description Ben Woodard 2014-03-25 21:37:39 UTC
Description of problem:
When you have a statically linked binary you can't access the tls data through gdb

Version-Release number of selected component (if applicable):
All. This problem exists in 6.4, 6.5, rhel7, F20 and even the upstream trunk version GDB

How reproducible:
always everywhere


Steps to Reproduce:
sierra648{jdelsign}82: gcc -g -o tls tls.c -pthread -static
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libpthread.a(libpthread.o): In function `sem_open':
(.text+0x764d): warning: the use of `mktemp' is dangerous, better use `mkstemp'
sierra648{jdelsign}83: gdb tls
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
...
Reading symbols from /g/g0/jdelsign/tls...done.
(gdb) b 12
Breakpoint 1 at 0x400511: file tls.c, line 12.
(gdb) run
Starting program: /g/g0/jdelsign/tls 
[Thread debugging using libthread_db enabled]
[New Thread 0x2aaaaacac700 (LWP 6735)]
thread_local_p: & == 00002aaaaacac6c0, . == 00002aaaaacabd1c, * == 1
[Switching to Thread 0x2aaaaacac700 (LWP 6735)]

Breakpoint 1, start_routine (arg=0x1) at tls.c:12
12        return arg;

Actual results:
(gdb) p thread_local_p
Cannot find executable file `/g/g0/jdelsign/tls' in dynamic linker's load module list

Expected results:
It print's the variable

Additional info:

Comment 1 Ben Woodard 2014-03-25 21:40:32 UTC
Created attachment 878704 [details]
reproducer

Comment 3 Ben Woodard 2014-03-26 11:52:08 UTC
The way that we arrived at this problem was trying to diagnose a suspected problem with libthread_db's calculation of the address to TLS for OpenMP C/C++ threadprivate variables in statically linked binaries. Therefore, once GDB is able to properly load libthread_db there may be another problem with libthread_db's ability to return a correct address.

Comment 4 Jan Kratochvil 2014-03-26 19:02:01 UTC
glibc-RFC patch for GDB:
TLS variables access for -static -lpthread executables
https://sourceware.org/ml/libc-help/2014-03/msg00024.html

Comment 5 Jan Kratochvil 2014-04-10 11:54:45 UTC
[patch] Fix gdbserver qGetTLSAddr for x86_64 -m32
https://sourceware.org/ml/gdb-patches/2014-04/msg00154.html
Message-ID: <20140410114901.GA16411.net>

[patch] Fix TLS access for -static -pthread
https://sourceware.org/ml/gdb-patches/2014-04/msg00155.html
Message-ID: <20140410115204.GB16411.net>

Comment 6 Jan Kratochvil 2014-05-23 10:36:15 UTC
commit 9e0aa64f5510861b2517c5841b59adde8e423540
Author: Jan Kratochvil <jan.kratochvil>
    Fix gdbserver qGetTLSAddr for x86_64 -m32

commit 5876f5032f60c45c4bd19e7ea7d0c14d0346b93e
Author: Jan Kratochvil <jan.kratochvil>
    Fix TLS access for -static -pthread

Comment 11 errata-xmlrpc 2014-10-14 07:28:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1534.html


Note You need to log in before you can comment on or make changes to this bug.