This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Avoid unhandled Error in TypeSystemMap::GetTypeSystemForLanguage
ClosedPublic

Authored by dim on Aug 15 2021, 9:01 AM.

Details

Summary

When assertions are turned off, the llvm::Error value created at the
start of this function is overwritten using the move-assignment
operator, but the success value is never checked. Whenever a TypeSystem
cannot be found or created, this can lead to lldb core dumping with:

Program aborted due to an unhandled Error:
Error value was Success. (Note: Success values must still be checked prior to being destroyed).

Fix this by not creating a llvm::Error value in advance, and directly
returning the result of llvm::make_error instead, whenever an error is
encountered.

See also: https://bugs.freebsd.org/253881 and
https://bugs.freebsd.org/257829.

Diff Detail

Event Timeline

dim created this revision.Aug 15 2021, 9:01 AM
dim requested review of this revision.Aug 15 2021, 9:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2021, 9:01 AM
teemperor accepted this revision.Aug 16 2021, 4:53 AM

Thanks for fixing this (and cleaning up the code), LGTM. I wrote some regression tests for this in D108121 that I'll land as a follow-up.

This revision is now accepted and ready to land.Aug 16 2021, 4:53 AM
This revision was landed with ongoing or failed builds.Aug 16 2021, 8:38 AM
This revision was automatically updated to reflect the committed changes.