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

Assertion failure in PopCleanupBlock compiling catch block #266

Closed
VoxSciurorum opened this issue Aug 28, 2024 · 3 comments · Fixed by #268
Closed

Assertion failure in PopCleanupBlock compiling catch block #266

VoxSciurorum opened this issue Aug 28, 2024 · 3 comments · Fixed by #268
Labels
bug Something isn't working

Comments

@VoxSciurorum
Copy link
Contributor

Assertion failure with attached reproducer:

Assertion failed: (!EHStack.empty() && "cleanup stack is empty!"), function PopCleanupBlock, file /data/Cilk/opencilk-project/clang/lib/CodeGen/CGCleanup.cpp, line 670.

If I remove the _Cilk_sync in the catch block the program compiles but crashes at runtime if an exception is thrown.
grain-eea328.cpp.txt
grain-eea328.sh.txt

@VoxSciurorum VoxSciurorum added the bug Something isn't working label Aug 28, 2024
@VoxSciurorum
Copy link
Contributor Author

Simpler test case:

extern int f();

void g() {
  try {
    f();
  } catch (int x) {
    _Cilk_sync;
  }
}

Compile with clang++ -O1.

@VoxSciurorum
Copy link
Contributor Author

TaskFrameScope::TaskFrameScope pushes a cleanup if CGF.CurSyncRegion is not null. TaskFrameScope::~TaskFrameScope pops a cleanup if CGF.CurSyncRegion is not null. But CGF.CurSyncRegion has changed from null to non-null between construction and destruction. Should the destructor be testing TaskFrame instead of CGF.CurSyncRegion so it pops a cleanup only if one was pushed?

@neboat
Copy link
Collaborator

neboat commented Aug 30, 2024

Yes, that change sounds good to me.

I also managed to reproduce the runtime crash you encountered with the original test case. I'm looking into that crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants