Bug 809179 - Global variable nested by another dso shows up incorrectly in gdb
Summary: Global variable nested by another dso shows up incorrectly in gdb
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: gdb
Version: 7.0
Hardware: All
OS: Linux
high
medium
Target Milestone: rc
: ---
Assignee: Sergio Durigan Junior
QA Contact: Miroslav Franc
URL:
Whiteboard:
Depends On: 745004
Blocks: 1113520 758797
TreeView+ depends on / blocked
 
Reported: 2012-04-02 16:57 UTC by Petr Muller
Modified: 2019-03-25 01:01 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: GDB was not correctly handling shared objects that contained identical global variables being exported. Consequence: When the user tried to inspect the global variable being exported by both shared objects, GDB would display an incorrect value for it. Fix: GDB now handles correctly different shared objects that export the same global variable. Result: The user can inspect the global variable without problems.
Clone Of: 745004
Environment:
Last Closed: 2015-03-05 09:23:49 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0404 normal SHIPPED_LIVE gdb bug fix and enhancement update 2015-03-05 14:17:37 UTC

Comment 2 Petr Muller 2012-04-02 17:05:04 UTC
This bug reappeared when compiled with a toolset gcc. Additionally, the toolset gcc toolset does not like the empty (if you supply something then it compiles) -Wl options in the original testcase:

$ scl enable devtoolset-1.0 'sh ./mk.sh'
gcc: error: unrecognized command line option ‘-Wl’
gcc: error: unrecognized command line option ‘-Wl’
gcc: error: unrecognized command line option ‘-Wl’

But when you remove them, you get the gdb behavior described in the bug. Both system (RHEL5+6) and Toolset gdb shows '$1 = 0' in the output.

Comment 3 Jakub Jelinek 2012-04-03 07:38:00 UTC
1) the rejection of bogus options passed to gcc driver when linking is documented: http://gcc.gnu.org/gcc-4.7/porting_to.html

2) I don't see how this testcase is related to PR39563, that PR was about block scope extern decls, there are none in the testcase

3) gcc generates the same debug info (and comparable code) in all versions I've tried (4.1/4.4/4.7/4.8), so if this worked, it would be a gdb change.  Try /usr/bin/gdb instead of gdb ?

Comment 4 Jan Kratochvil 2012-04-03 07:53:52 UTC
GDB does not support properly copy-relocations and conflicting names.

This is:
        common/.bss variables from shared libraries not displayed correctly
        http://sourceware.org/bugzilla/show_bug.cgi?id=11717

The possibilities how to fix it were discussed at:
        gfortran invalid DW_AT_location for overridable variables
        http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40040

You may get random result depending on which order GDB expands symtabs etc.

This is DTS-unrelated, it is a general GDB Bug/FEAT to fix.

Comment 5 Petr Muller 2012-04-03 08:57:32 UTC
(In reply to comment #3)
> 2) I don't see how this testcase is related to PR39563, that PR was about block
> scope extern decls, there are none in the testcase

I admit I just used the testcase, saw the reported behavior and reported it for DTS. Sorry. 

> 
> 3) gcc generates the same debug info (and comparable code) in all versions I've
> tried (4.1/4.4/4.7/4.8), so if this worked, it would be a gdb change.  Try
> /usr/bin/gdb instead of gdb ?

That is weird, because the factor is actually whether I use Toolset gcc or not.

If I compile with Toolset gcc, I get '$1 = 0' with both system and Toolset gdb
If I compile with system gcc, I get '$1 = 42' with both system and Toolset gdb

(In reply to comment #4)
> GDB does not support properly copy-relocations and conflicting names.
> 
> This is:
>         common/.bss variables from shared libraries not displayed correctly
>         http://sourceware.org/bugzilla/show_bug.cgi?id=11717
> 
> The possibilities how to fix it were discussed at:
>         gfortran invalid DW_AT_location for overridable variables
>         http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40040
> 
> You may get random result depending on which order GDB expands symtabs etc.
> 
> This is DTS-unrelated, it is a general GDB Bug/FEAT to fix.

Not sure if this is true - it seems to me that RHEL5/RHEL6 gdb/gcc (or whatever is the cause) is better than the Toolset one.

Comment 16 Sergio Durigan Junior 2014-09-04 21:38:01 UTC
Proposed patch for testing the issue (upstream): https://sourceware.org/ml/gdb-patches/2014-09/msg00136.html

Comment 21 errata-xmlrpc 2015-03-05 09:23:49 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.

https://rhn.redhat.com/errata/RHBA-2015-0404.html


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