Skip to content

Fix unwinding when throw is directly before catch #4191

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

WojciechMazur
Copy link
Contributor

@WojciechMazur WojciechMazur commented Jan 31, 2025

During LTO we were able to get into scenarios where we're throwing exception for which the catch handler is defined as a next instruction. Such cases were not handled before, but are handled by C++ exceptions handling.

The most impacting change include additional condition for pcOffset == landingPad meaning that if we're inside handler we should use it.
This fixes problems where try-finally block executing object.exitMonitor routine was skipped leading to deadlocks

Initially this PR was fixing fixing #4190 on my MacOS AArch64 machine, however it did not worked on Linux. After further inspection the change to check if we're at the start of next landing pad was leading in infinite loop in this test case #4190 (comment) becouse of that is should be right now treated as a refactor rather then a fix

…truction is directlly followed by catch. These can happen when LTO is enabled. Previously a finally block could have been not executed
…re uniqnes by unwinding point instead full identity
@@ -42,6 +42,9 @@ private[monitor] class ObjectMonitor() {
*/
@volatile private var enterQueue: WaiterNode = _

override def toString(): String =
s"ObjectMonitor(owner=$ownerThread),waiting=$waiting,recursion=$recursion)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default toString don't return the parameter names but usually just ClassName(param1,param2,param3)

@lolgab
Copy link
Contributor

lolgab commented Jan 31, 2025

I see you changed the code reading LSDA to read some DWARF data. Is DWARF always available? How does it work?

@WojciechMazur
Copy link
Contributor Author

I see you changed the code reading LSDA to read some DWARF data. Is DWARF always available? How does it work?

Not really, so far I have not observed them locally, but I've added the checks based on LLVM cxx_personality logic
https://github.com/llvm/llvm-project/blob/77d3f8a92564b533a3c60a8c8e0657c38fd88ba1/libcxxabi/src/cxa_personality.cpp#L663-L665

In theory at least lpBase can be used to have a correct landing pad but beside that I seems to not improve much

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

Successfully merging this pull request may close these issues.

2 participants