New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pthread app under debugger has __nptl_create_event int3 copied into code cache #490

Open
derekbruening opened this Issue Nov 28, 2014 · 1 comment

Comments

Projects
None yet
1 participant
@derekbruening
Contributor

derekbruening commented Nov 28, 2014

From bruen...@google.com on June 08, 2011 08:30:50

the __nptl_create_event routine, AFAICT, is used as part of the
communication between pthreads and gdb. gdb seems to set a hidden
breakpoint there. DR then decodes an int3 prior to ret (0xcc 0xc3) and
puts it into the code cache. the debugger then hits a trap on every
pthread_create or other place which calls __nptl_create_event. at
that point, the app code is 0xf3 0xc3 (repz ret) and the int3 is no longer
there, but DR has no way of detecting this change made by the debugger via
the kernel. the debugger handles these traps so this is just an annoyance
at this point but worth documenting.

interp: start_pc = 0x00007f21ada9e483
0x00007f21ada9e483 e8 48 e5 ff ff call $0x00007f21ada9c9d0 %rsp -> %rsp 0xfffffff8(%rsp)
0x00007f21ada9c9d0 cc int3
0x00007f21ada9c9d1 c3 ret %rsp (%rsp) -> %rsp
end_pc = 0x00007f21ada9c9d2

Program received signal SIGTRAP, Trace/breakpoint trap.

(gdb) x/5i 0x00007f21ada9e483
0x7f21ada9e483 <__pthread_create_2_1+1827>: callq 0x7f21ada9c9d0 <__nptl_create_event>

(gdb) disas __nptl_create_event
Dump of assembler code for function __nptl_create_event:
0x00007f21ada9c9d0 <+0>: repz retq
End of assembler dump.
(gdb) x/5bx 0x7f21ada9c9d0
0x7f21ada9c9d0 <__nptl_create_event>: 0xf3 0xc3 0x66 0x66 0x66

this is inside libpthread.so.0

Original issue: http://code.google.com/p/dynamorio/issues/detail?id=490

@derekbruening

This comment has been minimized.

Show comment
Hide comment
@derekbruening

derekbruening Nov 28, 2014

Contributor

From qin.zhao@gmail.com on June 08, 2011 08:20:25

Yes this is an annoying feature caused by GDB, I have seen many times whenever debugging a multithreaded application. Better document it somewhere.
Other than that, sometimes GDB inserts many int3 which causes a trap on every instruction execution and makes the debugging impossible.

Contributor

derekbruening commented Nov 28, 2014

From qin.zhao@gmail.com on June 08, 2011 08:20:25

Yes this is an annoying feature caused by GDB, I have seen many times whenever debugging a multithreaded application. Better document it somewhere.
Other than that, sometimes GDB inserts many int3 which causes a trap on every instruction execution and makes the debugging impossible.

@derekbruening derekbruening removed the Type-Bug label Apr 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment