[LLVMdev] [PATCH] Catch NULL return value of ExecutionEngine::create()

Chris Lattner clattner at apple.com
Tue Jul 7 11:32:04 PDT 2009


On Jun 23, 2009, at 12:04 PM, Eric Rannaud wrote:

> ExecutionEngine::create() can return NULL with an empty error message
> (admittedly, it did so because of global variable initialization
> problems). The code currently lets NULL go through if ErrorMsg is  
> empty,
> and segfaults later.
>
> When EE is NULL but ErrorMsg is empty, simply do not try to
> print it and exit.

Nice catch.  Please send patches as attachments so that they don't  
word wrap or get mangled by your mailer.  Since it is small, I  
manually applied this patch here:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20090706/080247.html

Thanks!

-Chris

>
> Index: tools/lli/lli.cpp
> ===================================================================
> --- tools/lli/lli.cpp   (revision 73978)
> +++ tools/lli/lli.cpp   (working copy)
> @@ -144,8 +144,11 @@
>   InitializeNativeTarget();
>
>   EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg, OLvl);
> -  if (!EE && !ErrorMsg.empty()) {
>   -    std::cerr << argv[0] << ":error creating EE: " << ErrorMsg <<
>        "\n";
> +  if (!EE) {
> +    if (!ErrorMsg.empty())
> +      std::cerr << argv[0] << ":error creating EE: " << ErrorMsg <<
> "\n";
> +    else
> +      std::cerr << argv[0] << ":error creating EE\n";
>     exit(1);
>   }
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list