Bug 228744 - gdb unexplained memory access at 0x0
gdb unexplained memory access at 0x0
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
9
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Alexandre Oliva
bzcl34nup
:
: 250414 (view as bug list)
Depends On:
Blocks: 173278
  Show dependency treegraph
 
Reported: 2007-02-14 14:18 EST by Tom Stevelt
Modified: 2008-10-13 11:02 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-10-13 11:02:51 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
GNU Compiler Collection 29628 None None None Never

  None (edit)
Description Tom Stevelt 2007-02-14 14:18:41 EST
GDB throws an unexplained "cannot access memory at 0x0"
after accessing argc or argv[] in a subsidary function.

gdb-6.5-15.fc6.src.rpm

How reproducible: always


Steps to Reproduce:

1. run attached program using gdb.
2. set a breakpoint on line 6  ( getargs: printf ... argc )
3. run, giving the name of any existing file
4. at breakpoint, execute bt (backtrace) and examine the
   output, which looks normal.
5. execute n (next) 
6. execute another bt and see the messed up output which 
   includes "cannot access memeory at 0x0".  

Actual results:

(gdb) bt
#0  getargs (argc=2, argv=0xbfe1a7b4) at foo6.c:7
#1  0x080483e5 in main (argc=Cannot access memory at address 0x0
) at foo6.c:17

Expected results:

(gdb) bt
#0  getargs (argc=2, argv=0xbfe1a7b4) at foo6.c:6
#1  0x080483e5 in main (argc=2, argv=0xbfe1a7b4) at foo6.c:17


Additional info:

Problem occures wiht either argc or argv.

If you uncomment either of the printf statements in
main(), then the problem in getargs goes away.

Here is the source code.


#include	<stdio.h>

void getargs ( int argc, char *argv[] )
{
  printf ( "argc %d\n", argc );        /* set breakpoint here */
  printf ( "filename %s\n", argv[1] );
  printf ( "hello world\n" );
}

int main ( int argc, char *argv[] )
{
  // printf ( "argc %d\n", argc );
  // printf ( "filename %s\n", argv[1] );
  getargs ( argc, argv );
  return ( 0 );
}
Comment 1 Jan Kratochvil 2007-02-16 20:32:27 EST
Yes, you are right.
It is a GCC Bug, though, regarding its DWARF generation.
ECX is a volatile (callee unsaved) register which currently gets referenced:
 <2><162>: Abbrev Number: 6 (DW_TAG_formal_parameter)
     DW_AT_name        : argc
     DW_AT_location    : 2 byte block: 71 0     (DW_OP_breg1: 0)
 <2><171>: Abbrev Number: 6 (DW_TAG_formal_parameter)
     DW_AT_name        : argv
     DW_AT_location    : 2 byte block: 71 4     (DW_OP_breg1: 4)

(breg1==ECX)

Fortunately if you use argc/argv more in main() it gets saved more persistently
and the bug gets no longer exposed.

Related Bug / Jakub's comment upstream:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29628#c1
Comment 3 Jan Kratochvil 2007-08-01 10:01:37 EDT
*** Bug 250414 has been marked as a duplicate of this bug. ***
Comment 4 Bug Zapper 2008-04-03 15:09:07 EDT
Based on the date this bug was created, it appears to have been reported
against rawhide during the development of a Fedora release that is no
longer maintained. In order to refocus our efforts as a project we are
flagging all of the open bugs for releases which are no longer
maintained. If this bug remains in NEEDINFO thirty (30) days from now,
we will automatically close it.

If you can reproduce this bug in a maintained Fedora version (7, 8, or
rawhide), please change this bug to the respective version and change
the status to ASSIGNED. (If you're unable to change the bug's version
or status, add a comment to the bug and someone will change it for you.)

Thanks for your help, and we apologize again that we haven't handled
these issues to this point.

The process we're following is outlined here:
http://fedoraproject.org/wiki/BugZappers/F9CleanUp

We will be following the process here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping to ensure this
doesn't happen again.
Comment 5 Luciano Rocha 2008-04-07 12:11:01 EDT
I still have the same problem, that I reported in #250414.

Fedora 8:
glibc-2.7-2
gcc-4.1.2-33
gdb-6.6-45.fc8
Comment 6 Luciano Rocha 2008-04-07 12:18:26 EDT
Note that the bug I reported, closed as duplicate of this one, was reported for
Fedora 7, not yet EOL.
Comment 7 Luciano Rocha 2008-05-07 06:40:05 EDT
Same problem with fedora 9 preview:
glibc-2.8-3.i686
gcc-4.3.0-8.i386
gdb-6.8-1.fc9.i386
Comment 8 Bug Zapper 2008-05-13 22:37:10 EDT
Changing version to '9' as part of upcoming Fedora 9 GA.
More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 9 Jan Kratochvil 2008-10-13 11:02:51 EDT
It is fixed in the current upstream snapshot:
GNU C (GCC) version 4.4.0 20081007 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.4.0 20081007 (experimental), GMP version 4.2.2, MPFR version 2.3.1.

Breakpoint 1, getargs (argc=1, argv=0xffffc514) at rh228744.c:5
5	  printf ( "argc %d\n", argc );        /* set breakpoint here */
Missing separate debuginfos, use: debuginfo-install glibc.i686
(gdb) bt
#0  getargs (argc=1, argv=0xffffc514) at rh228744.c:5
#1  0x0804844e in main (argc=1, argv=0xffffc514) at rh228744.c:14
(gdb) n
argc 1
6	  printf ( "filename %s\n", argv[1] );
(gdb) bt
#0  getargs (argc=1, argv=0xffffc514) at rh228744.c:6
#1  0x0804844e in main (argc=1, argv=0xffffc514) at rh228744.c:14

Closing this Bug as not so serious while it should be present in Fedora gcc-4.4.

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