This is an archive of the discontinued LLVM Phabricator instance.

Fix an issue where backend crashes after frontend emits an error message
ClosedPublic

Authored by manmanren on Jan 25 2016, 4:48 PM.

Details

Summary

It can happen that frontend emits error message when releasing the builder. When that happens, we emit the error message and continue to invoke backend.
Backend will then crash.

The fix is quite simple, we check for errors after releasing the builder.

Diff Detail

Event Timeline

manmanren updated this revision to Diff 45931.Jan 25 2016, 4:48 PM
manmanren retitled this revision from to Fix an issue where backend crashes after frontend emits an error message.
manmanren updated this object.
manmanren added a subscriber: cfe-commits.
ahatanak added inline comments.Jan 26 2016, 5:08 PM
lib/CodeGen/ModuleBuilder.cpp
214

Is it possible to avoid the code duplication if the condition is inverted as shown below?

if (!Diags.hasErrorOccurred())

// call Builder->Release()

if (!Diags.hasErrorOccurred())

return;

// Clear Builder and reset M

manmanren updated this revision to Diff 46301.Jan 28 2016, 11:36 AM

Addressing comments from Akira and Justin.

echristo accepted this revision.Jan 28 2016, 2:41 PM
echristo edited edge metadata.

Seems like a weird place to handle this, but it's been there for a long time. That said, I see how we can get there now, thanks!

-eric

This revision is now accepted and ready to land.Jan 28 2016, 2:41 PM
This revision was automatically updated to reflect the committed changes.