[llvm-bugs] [Bug 26060] New: Empty error string returned by lto_get_error_message()

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 7 02:33:19 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26060

            Bug ID: 26060
           Summary: Empty error string returned by lto_get_error_message()
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: lto
          Assignee: unassignedbugs at nondot.org
          Reporter: petr.pavlu at arm.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Commit r254721 [1] introduced the following regression:
$ cat test.c
#include <stdio.h>
#include "llvm-c/lto.h"

int main(void)
{ 
  lto_module_t m;
  m = lto_module_create("invalid.bc");
  if (m == NULL)
    printf("lto_module_create() failed: %s.\n", lto_get_error_message());
  return 0;
}
$ cc -Illvm/include -Lllvm/build/lib -lLTO test.c
$ touch invalid.bc
$ LD_LIBRARY_PATH=$PWD/llvm/build/lib ./a.out
lto_module_create() failed: .

Previous behaviour:
$ LD_LIBRARY_PATH=$PWD/llvm/build/lib ./a.out
lto_module_create() failed: The file was not recognized as a valid object file.

Previously, tools/lto/lto.cpp:lto_module_create() would pass a sLastErrorString
reference as the ErrMsg parameter to
lib/LTO/LTOModule.cpp:LTOModule::createFromFile() which would pass it further
to lib/LTO/LTOModule.cpp:LTOModule::makeLTOModule() and
lib/LTO/LTOModule.cpp:parseBitcodeFileImpl(). This function would call
lib/Object/IRObjectFile.cpp:IRObjectFile::findBitcodeInMemBuffer() and if it
returned an error it would assign a string representation of it to the received
ErrMsg (aka sLastErrorString).

The commit removed the ErrMsg parameter from these functions and instead
tools/lto/lto.cpp:lto_initialize() registers a diagnostic handler with the
global LLVMContext. The handler then stores any reported errors through this
path to sLastErrorString.

The problem is that
lib/Object/IRObjectFile.cpp:IRObjectFile::findBitcodeInMemBuffer() does not
report errors this way, it only returns object_error::invalid_file_type if the
file is invalid.

[1]
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151130/317272.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160107/0c84020e/attachment.html>


More information about the llvm-bugs mailing list