ndrewh / pyda

Write dynamic binary analysis tools in Python
Other
7 stars 0 forks source link

feat: multithread #10

Closed ndrewh closed 2 months ago

ndrewh commented 3 months ago

The way multithreading is supposed to work is that all of the threads share the same python interpreter state (and all of its globals). I've already added a thread_init hook that users can do initial setup (e.g. updating of hooks) or thread accounting.

Generally, I expect there to be very little that users want to do when a new thread spawns. All of the hooks are global to all threads by default, and you can check p.tid to see what thread you're on.

Right now multithreading is broken. There are likely multiple issues, but the most pressing one is we don't have a way to instrument the thread entrypoint (so we can have the target thread block while the thread init hook runs in python). For the main thread we were just using the module entrypoint, but that's not right here.

ndrewh commented 2 months ago

done in https://github.com/ndrewh/pyda/commit/51adc166a3b810c38f655e931d8dd2eb8b61a482, this required a ton of cursed hacks, see the commit message

will make separate issue for providing RIP in thread entry hook.