Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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

Summary: [RHEL6] Can't access TLS variables in statically linked binaries
Product: Red Hat Enterprise Linux 6 Reporter: Ben Woodard <woodard>
Component: gdbAssignee: Sergio Durigan Junior <sergiodj>
Status: CLOSED ERRATA QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.6CC: jan.kratochvil, mcermak, mfranc, patrickm, tgummels
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
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.
Story Points: ---
Clone Of:
: 1080657 1080660 (view as bug list) Environment:
Last Closed: 2014-10-14 07:28:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1005265    
Attachments:
Description Flags
reproducer none

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