Skip to content

Assertion failure in operator delete of llvm::User #129900

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

Closed
marcauberer opened this issue Mar 5, 2025 · 0 comments · Fixed by #129914
Closed

Assertion failure in operator delete of llvm::User #129900

marcauberer opened this issue Mar 5, 2025 · 0 comments · Fixed by #129914
Assignees
Labels

Comments

@marcauberer
Copy link
Member

marcauberer commented Mar 5, 2025

Commit e3f936e introduces a functional regression. If the constructor after operator new fails, and then operator delete is called, we run into the following assertion. This was caught by malfunction tests:

https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/User.cpp#L190

Reverting the removal of:

Obj->NumUserOperands = Us;
Obj->HasHungOffUses = false;
Obj->HasDescriptor = DescBytes != 0;

respecively

Obj->NumUserOperands = 0;
Obj->HasHungOffUses = true;
Obj->HasDescriptor = false;

helps.

I will prepare a patch for that.

@marcauberer marcauberer self-assigned this Mar 5, 2025
swift-ci pushed a commit to swiftlang/llvm-project that referenced this issue Apr 11, 2025
Fixes llvm#129900

If `operator delete` was called after an unsuccessful constructor call
after `operator new`, we ran into undefined behaviour.
This was discovered by our malfunction tests while preparing an upgrade
to LLVM 20, that explicitly check for such kind of bugs.

(cherry picked from commit 8d38906)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant