Skip to content

[BOLT] Turn non-empty CFI StateStack assert into a warning #102216

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

Conversation

aaupov
Copy link
Contributor

@aaupov aaupov commented Aug 6, 2024

clang-15 can produce binaries with mismatched RememberState/RestoreState
CFIs. This is benign for unwinding, so replace an assert with a warning.

Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2024

@llvm/pr-subscribers-bolt

Author: Amir Ayupov (aaupov)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/102216.diff

1 Files Affected:

  • (modified) bolt/lib/Core/BinaryFunction.cpp (+4-1)
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index ea09371b57e8a..e5c6d551e42a7 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -2502,7 +2502,10 @@ void BinaryFunction::annotateCFIState() {
     }
   }
 
-  assert(StateStack.empty() && "corrupt CFI stack");
+  if (!StateStack.empty()) {
+    BC.errs() << "BOLT-WARNING: non-empty CFI stack at the end of " << *this
+              << '\n';
+  }
 }
 
 namespace {

Copy link
Member

@dcci dcci left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. I don't understand CFI enough to comment on the correctness of this, hopefully @rafaelauler can chime in.

As a general point, I'm not entirely sure we should disable this assertion, without understanding.

In particular:

  1. Is this something that the compiler produced that's corrupted?
    Should that be the case, we might consider either:
    a) fixing the compiler
    b) making this an error
    c) allow this to be a warning (if someone passes a flag to override at their own risk)

If 1) doesn't hold, is BOLT corrupting the stack somehow?

Copy link
Contributor

@rafaelauler rafaelauler left a comment

Choose a reason for hiding this comment

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

The opposite, popping more items than pushed, would be a real concern. Since this assertion checks whether the CFI stack is inconsistent because it pushed more items than popped, it should be OK to convert the assertion into a warning.

@dcci
Copy link
Member

dcci commented Aug 6, 2024

Fine with this then. Maybe add a description/improve the commit message and then it's fine to merge.

@aaupov aaupov merged commit f83a89c into main Aug 7, 2024
8 checks passed
@aaupov aaupov deleted the users/aaupov/spr/bolt-turn-non-empty-cfi-statestack-assert-into-a-warning branch August 7, 2024 00:23
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 this pull request may close these issues.

4 participants