Bug 809179 - Global variable nested by another dso shows up incorrectly in gdb
Global variable nested by another dso shows up incorrectly in gdb
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: gdb (Show other bugs)
7.0
All Linux
high Severity medium
: rc
: ---
Assigned To: Sergio Durigan Junior
Miroslav Franc
: Patch, Reopened
Depends On: 745004
Blocks: 1113520 758797
  Show dependency treegraph
 
Reported: 2012-04-02 12:57 EDT by Petr Muller
Modified: 2016-01-31 21:27 EST (History)
10 users (show)

See Also:
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.
Story Points: ---
Clone Of: 745004
Environment:
Last Closed: 2015-03-05 04:23:49 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Comment 2 Petr Muller 2012-04-02 13:05:04 EDT
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 03:38:00 EDT
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 03:53:52 EDT
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 04:57:32 EDT
(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 17:38:01 EDT
Proposed patch for testing the issue (upstream): https://sourceware.org/ml/gdb-patches/2014-09/msg00136.html
Comment 21 errata-xmlrpc 2015-03-05 04:23:49 EST
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.