You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Callbacks registered there https://github.com/x64dbg/x64dbgpy/blob/v25/py.cpp#L810 are not thread safe and will produce random memory corruptions if an user script is running at the same time. We can't run python from two different threads at the exact same time.
Trigger the random corruption:
Dummy program to debug: int crash(int a,int b) { int sum = 0; for (int i = 0; i < 0xFFFFFF; i++) sum += a + b; return sum; }
Yeah, the current codebase is not great. The https://github.com/x64dbg/x64dbgpy/tree/v25/scriptapi project uses pybind11, which can work around these threading issues but it's currently not in development. Please join the x64dbg chat to discuss if you would like to collaborate on it.
Hello,
Callbacks registered there https://github.com/x64dbg/x64dbgpy/blob/v25/py.cpp#L810 are not thread safe and will produce random memory corruptions if an user script is running at the same time. We can't run python from two different threads at the exact same time.
Trigger the random corruption:
Dummy program to debug:
int crash(int a,int b) { int sum = 0; for (int i = 0; i < 0xFFFFFF; i++) sum += a + b; return sum; }
Dummy script:
`import x64dbgpy
def loop():
print("inside loop")
x64dbgpy.pluginsdk.Run()
def outloop():
print("loop finished")
x64dbgpy.pluginsdk.Run()
x64dbgpy.Breakpoint.add(0x140001036,loop)
x64dbgpy.Breakpoint.add(0x140001048,outloop)
x64dbgpy.pluginsdk.Run()`
Then enjoy random memory corruptions, you may need to run several times to crash or reload binary etc ...
So we need to use GIL lock related functions or maybe use async functions like PyThreadState_SetAsyncExc/Py_AddPendingCall.
The text was updated successfully, but these errors were encountered: