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 server/17302] gdbserver function call + detach crashes inferior process


https://sourceware.org/bugzilla/show_bug.cgi?id=17302

--- Comment #2 from Simon Marchi <simon.marchi at ericsson dot com> ---
I found that during the manual call to a function by gdbserver, a segmentation
fault/SIGSEGV is generated. When detaching, gdbserver delivers the pending
SIGSEGV, causing the crash of the detached process.

When preparing the inferior call, gdb starts by expanding a stack a bit. It
then places a breakpoint instruction (0xCC) somewhere in that area. It then
prepares the dummy frame, including writing the return address, which is the
address where the 0xCC is. So when the function ends, execution should go where
the breakpoint and it should stop. However, since stack is generally not
executable, when the processor tries to "execute" the breakpoint instruction, a
segmentation fault/SIGSEGV is generated instead of the normal SIGTRAP.

When making the stack executable, the problem disappears, so I am quite
confident that this is the reason. In order to make the stack executable, I use
execstack (it modifies a flag in the binary):

$ execstack -s binary

I have no idea why this only happens in gdbserver, and not in gdb.

-- 
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]