[llvm-bugs] [Bug 50092] New: llvm::parseIR does not handle extractValue correctly

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 23 02:53:23 PDT 2021


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

            Bug ID: 50092
           Summary: llvm::parseIR does not handle extractValue correctly
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Bitcode Reader
          Assignee: unassignedbugs at nondot.org
          Reporter: aanderso at tcd.ie
                CC: llvm-bugs at lists.llvm.org

Created attachment 24796
  --> https://bugs.llvm.org/attachment.cgi?id=24796&action=edit
minimized test case

I have seen #3465 (https://bugs.llvm.org/show_bug.cgi?id=3465) -- this bug is
not that bug.

The attached simple module is handled fine by llvm-as but causes a signal to be
raised when parsed via llvm::parseIR. No parse error message is returned in the
user-supplied char**, we just go straight to throwing an exception. I can't see
a throw in the code in llvm::parseIR so I assume it is coming from deeper in
the machinery.

I am calling llvm::parseIR via LLVMParseIRInContext in the C interface.

It handles many other instructions just fine -- this specific case is the one
breaking. It also handle parse *failures* of other instructions just fine -- we
get an error message describing what went wrong in the user-supplied char**. In
the case of extractValue, we get no error message -- just a crash.

This attached IR fragment is actually from the extractValue description in the
LLVM language reference. If any fragment should parse successfully, I'd think
it should be that one :)

I'm one of the maintainers of the downstream LLVM Haskell bindings
(https://github.com/llvm-hs/llvm-hs), and we have been tracking this problem
since LLVM 3.2 according to one of our commented-out test cases. It would be
great to see a fix so we can test our generation of extractValue instructions
properly.

Any fix can be tested as follows:

Check out llvm-hs from github (you'll have to uncomment the crashing test here:
https://github.com/llvm-hs/llvm-hs/blob/llvm-9/llvm-hs/test/LLVM/Test/Constants.hs#L158)

cd llvm-hs 

LD_LIBRARY_PATH=$(realpath ../llvm-9.0.1-root/lib) PATH=$(realpath
../llvm-9.0.1-root/bin):$PATH stack test

replacing those settings for PATH and LD_LIBRARY_PATH appropriately.

-- 
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/20210423/df6022fa/attachment.html>


More information about the llvm-bugs mailing list