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.
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.