This is the mail archive of the gdb-prs@sourceware.org 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]
Other format: [Raw text]

[Bug breakpoints/14294] New: Calling function in target result inSIGSEGV returning to breakpoint in not executable memory


http://sourceware.org/bugzilla/show_bug.cgi?id=14294

             Bug #: 14294
           Summary: Calling function in target result in SIGSEGV returning
                    to breakpoint in not executable memory
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
        AssignedTo: unassigned@sourceware.org
        ReportedBy: glaw@undo-software.com
    Classification: Unclassified


This appears to be a recent regression.

With a gdb from HEAD, when calling a function in the target, I get a SIGSEGV at
the end of the execution of the function. I think the problem is that gdb
inserts an "int $3" into the target which the called function returns to, and
it appears to be choosing the stack to do this, only the stack is not
executable. Thus when the target function returns and attempts to execute the
"int $3", rather than generating the SIGTRAP as expected, it gets a SIGSEGV as
the "int $3" instruction is in memory that is not executable.

Transcript showing the problem pasted below:


~ cat test.c
#include <stdio.h>

static void
foo( void)
{
    printf( "Hello world\n");
}

int
main( void)
{
    foo();
    return 0;
}
~ gcc -g test.c
~ ./gdb_cvs_dir/src/gdb/gdb a.out
GNU gdb (GDB) 7.4.50.20120624-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/gregjules/a.out...done.
(gdb) start
Temporary breakpoint 1 at 0x80483a9: file test.c, line 12.
Starting program: /home/gregjules/a.out 

Temporary breakpoint 1, main () at test.c:12
12          foo();
(gdb) call foo()
Hello world

Program received signal SIGSEGV, Segmentation fault.
0x08048397 in foo () at test.c:7
7       }
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(foo) will be abandoned.
When the function is done executing, GDB will silently stop.
(gdb)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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