Skip to content

[CIR][CodeGen] Fix crash during exception cleanup #1566

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

Merged
merged 1 commit into from
Apr 17, 2025

Conversation

bruteforceboy
Copy link
Contributor

Currently, the following code snippet fails with a crash during CodeGen

class C {
public:
  ~C();
  void operator=(C);
};

void d() {
  C a, b;
  a = b;
}

with error:

mlir::Block* clang::CIRGen::CIRGenFunction::getEHResumeBlock(bool, cir::TryOp): Assertion `tryOp && "expected available cir.try"' failed.

in CIRGenCleanup these lines don't check if there is a TryOp when at the end of the scope chain before getEHResumeBlock is called causing the crash, because it contains an assertion.

This PR fixes this and adds a simple test for a case like this.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Great, LGTM!

@bcardosolopes bcardosolopes merged commit 9f6742f into llvm:main Apr 17, 2025
10 checks passed
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