I hope you don't mind me breaking your program :)
I found that if the tracee calls execve within a thread reverie-ptrace panics.
According to the clone man page (man 2 clone)
If any of the threads in a thread group performs an execve(2),
then all threads other than the thread group leader are termi‐
nated, and the new program is executed in the thread group
leader.
The panic happens due to this
[...]
parent tid -1 created child tid 110665, pid 110665, main thread true
parent tid 110665 created child tid 110667, pid 110665, main thread false
[...]
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidState(Wait(Stopped(Stopped(Pid(110665)), Exec(Pid(110667)))))', ../reverie-ptrace/src/trace/mod.rs:347:54
[...]
From my limited understanding the proper way to handle this situation is discarding all threads of this process and resuming the main thread of the process as the only (new) process. I'm not quite sure if that's even possible in your current architecture.
Also, I realize this is an edge case, you might happily ignore it after all.
For reference, my tracee
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
void *myThreadFun(void *vargp)
{
sleep(0.5);
char* argument_list[] = {"/bin/sh", NULL};
execvp(*argument_list, argument_list);
return NULL;
}
int main()
{
pthread_t thread_id;
pthread_create(&thread_id, NULL, myThreadFun, NULL);
while(1) {};
exit(0);
}
Compile with -lpthread
I hope you don't mind me breaking your program :)
I found that if the tracee calls execve within a thread reverie-ptrace panics.
According to the
cloneman page (man 2 clone)The panic happens due to this
From my limited understanding the proper way to handle this situation is discarding all threads of this process and resuming the main thread of the process as the only (new) process. I'm not quite sure if that's even possible in your current architecture.
Also, I realize this is an edge case, you might happily ignore it after all.
For reference, my tracee
Compile with
-lpthread