Skip to content

Conversation

@beccadax
Copy link

@beccadax beccadax commented Jan 26, 2022

There's an assertion in ASTWriter::getSubmoduleID() that's relatively easy to hit when inputs are malformed in the right way, but doesn't really really give you any useful information about the problem when you do. Switch to report_fatal_error() so we can embed a module name in the message, and add some PrettyStackTraces to include useful details in this and other crashes.

This change is NFC because report_fatal_error() is still only called in compilers built with assertions.

(I plan to merge upstream of this branch; I just wanted to get some opinions before I took the time to do that.)

There's an assertion in `ASTWriter::getSubmoduleID()` that's relatively easy to hit when inputs are malformed in the right way, but doesn't really really give you any useful information about the problem when you do. Switch to `report_fatal_error()` so we can embed a module name in the message, and add some PrettyStackTraces to include useful details in this and other crashes.

This change is NFC because `report_fatal_error()` is still only called in compilers built with assertions.

for (const FrontendInputFile &FIF : getFrontendOpts().Inputs) {
std::string filename = FIF.getFile().str();
llvm::PrettyStackTraceFormat trace("Acting on file '%s'", filename.c_str());

Choose a reason for hiding this comment

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

Nit: to avoid an allocation, could you use %.* and pass in the length? It already gets copied internally, so the lifetime of what you pass in doesn't matter (although FIF.File is probably not modified here regardless).

Untested:

llvm::PrettyStackTraceFormat trace("Acting on file '%.*s'", FIF.getFile().size(), FIF.getFile().data());

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