[llvm-commits] Error-handling fixes for the x86 disassembler

Nick Lewycky nicholas at mxc.ca
Wed Mar 31 22:50:52 PDT 2010


Sean Callanan wrote:
> The attached patch fixes error handling for the x86 disassembler, eliminating llvm_unreachable() and assert() in favor of using the legitimate error-handling mechanism.  The rationale is to allow clients of libEnhancedDisassembly to handle errors themselves, rather than forcing them to crash.
>
> The difference is that now assert() and llvm_unreachable() will never be called (even before, this was extremely unlikely), and the proper error-handling mechanism is used instead.  Further diagnostic information is printed to stderr.

Your new error() method and assert/llvm_unreachable are not 
interchangeable. An assert() or llvm_unreachable() are likely to be the 
last thing run before undefined behaviour.

To do this properly please add llvm_recoverable_error() to 
llvm/Support/ErrorHandling.h and update every caller you want to be able 
to report a severe but optionally fatal error to use it. Then your 
client can install an error handler for the recoverable errors. Don't 
forget to audit all the calls you change to make sure that the program 
is correct even when it doesn't terminate at those points.

Nick

> Please let me know what you think.
>
> Sean
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list