This is the mail archive of the gdb-prs@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gdb/208: malloc'ed memory from GDB command line cannot be free'd from within program



>Number:         208
>Category:       gdb
>Synopsis:       malloc'ed memory from GDB command line cannot be free'd from within program
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 07 03:48:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Andreas Zeller
>Release:        5.0
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
Consider the following program, linked dynamically
against GNU libc:

int main() {
    void *p = 0;
(*) free(p);
}

If I set a breakpoint at (*), run the program and type

    (gdb) print p = malloc(10)
    $1 = (void *) 0x400173a0
    (gdb) continue

the program crashes within `free':

    Program received signal SIGSEGV, Segmentation fault.
    0x40096240 in free () from /lib/libc.so.6

The problem can be resolved by linking the program
statically:

    (gdb) print p = malloc(10)
    $1 = (void *) 0x8099888
    (gdb) cont
    Continuing.
 
    Program exited normally. 

It should be noted that when linked statically, the
command-line invocation of malloc() returns a very different
value.  This is weird - normally, the values should roughly 
be the same.
>How-To-Repeat:
(See above)
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]