Red Hat Bugzilla – Bug 171323
insufficent ptrace status when a thread calls exec
Last modified: 2015-01-04 17:22:38 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.0.7-1.1.fc4 Firefox/1.0.7
Description of problem:
In the somewhat bizarre case of a thread in a multi-threaded program
doing an exec() call, the status information a debugger this is debugging
this strange program gets back is, to say the least, confusing. The thread
that did the exec() call just sort of disappears and the main thread first
says it is about to exit, then says it exec()ed.
It would be much simpler on the poor old debugger if instead of getting
an about to exit extended status (PTRACE_EVENT_EXIT) we could invent a
new extended status just for this strange case (maybe PTRACE_THREAD_EXEC).
I'll attach my test program that demos the confusion.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. gcc -o thread-exec-bug -g thread-exec-bug.c -lpthread
Actual Results: The main thread first gets an "about to exit" status, then later instead
of exiting, gets an exec()ed status.
The thread that actually does the exec() call just disappears. No additional
status ever shows up for it (as far as the debugger knows, it is still running).
Expected Results: Good question, but the simplest thing for the debugger would probably be
a new extended status code to explicitly tell me a thread did an exec
and therefore all the other threads will disappear and I should expect
to see the actual exec show up in the main thread real soon now.
Created attachment 120204 [details]
test program to show the status debuggers get in this case
2.6.14-1.1637_FC4 has been released as an update for FC4.
Please retest with this update, as a large amount of code has been changed in
this release, which may have fixed your problem.
Tried test prog on new 1637 kernel - still behaves the same way. The thread
that calls exec() just completely disappears with no status reported to debugger
and the main thread still gets an "about to exit" status, then doesn't exit,
but instead exec()s.
I recommend bringing this up upstream at firstname.lastname@example.org as any
behavioural change needed here is going to have to be something that is
universally acceptable (or we get "this only works on Red Hat kernels", which is
never a good thing).