Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-threaded breakpoint program crashes #2168

Closed
armasm opened this issue May 9, 2019 · 6 comments
Closed

Multi-threaded breakpoint program crashes #2168

armasm opened this issue May 9, 2019 · 6 comments

Comments

@armasm
Copy link

armasm commented May 9, 2019

Write a simple program:
QR4E V4T7M86DGLWSJRCMCQ

Set breakpoints for thread1 and thread2
V25XG03H 48HQ{3Q%R~0HCF

Ignore all exceptions:
VD_L(N$LCO@EW`8BNX3$Y E

Repeated F9 run program
program crash
MJ(U8U 4 QGHO1D@5_U~(`E

the reason:
When I press f9 to continue running, the debugger first accepts the EXCEPTION_SINGLE_STEP of the next instruction of the breakpoint, and then continues to run.

KM0C8VEY}$ACXV{C@UG3B03

The tf of the previous breakpoint has not yet entered, and another breakpoint is interrupted. Then the TF of the previous breakpoint is considered an illegal exception to be handed over to the application for processing, and the program crashes.

@flarejune
Copy link

Thread concurrency,This bug always exists.To avoid this bug, use hardware breakpoints.

@mrexodia
Copy link
Member

Unfortunately hardware breakpoints do not solve this issue iirc.

Anyway, closing this issue as a duplicate of #1764. Your explanation is really good though so it's very useful thanks :)

@ShiaoQuR
Copy link

Unfortunately hardware breakpoints do not solve this issue iirc.

Anyway, closing this issue as a duplicate of #1764. Your explanation is really good though so it's very useful thanks :)

If the code is reentrant, hardware breakpoint + exception filters may be a mitigation.
Let the debugger handles the exceptions and "do not break" when EXCEPTION_SINGLE_STEP(80000004) is triggered.

@mrexodia
Copy link
Member

The problem is that once you remove the hardware breakpoint to step over the instruction you immediately create a race condition (because other threads can start running).

@ShiaoQuR
Copy link

ShiaoQuR commented Feb 28, 2022

Yeah...I mean this method somehow reduces the probability (the filter performs like a buffer). It doesn't solve the problem.

Looks like .bpsync suspends all other threads, and marks them as "frozen" for debugger (https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/controlling-processes-and-threads). Is it possible to temporarily ignore events from another threads until they defrost?

@mrexodia
Copy link
Member

mrexodia commented Feb 28, 2022

Yes, this issue has already been fixed in TitanEngine. But the updated TitanEngine is not yet in releases because it also messes up the suspend count. I’m looking into using the new thread freezing APIs to improve performance, but my time is unfortunately limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants