TheDan64 / inkwell

It's a New Kind of Wrapper for Exposing LLVM (Safely)
https://thedan64.github.io/inkwell/
Apache License 2.0
2.34k stars 227 forks source link

`test_object_file::test_symbol_iterator` triggers assert in llvm 10 #199

Open nlewycky opened 4 years ago

nlewycky commented 4 years ago

Describe the Bug LLVMGetSymbolSize gets the common symbol size, which requires that the symbol be a common symbol.

To Reproduce Please provide a simple sample of code which reproduces the issue on your machine.

$ cargo test --features=llvm10-0 test_object_file::test_symbol_iterator
test test_object_file::test_symbol_iterator ... all-0b042a69785d4445: ../include/llvm/Object/ObjectFile.h:295: uint64_t llvm::object::ObjectFile::getCommonSymbolSize(llvm::object::DataRefImpl) const: Assertion `getSymbolFlags(Symb) & SymbolRef::SF_Common' failed.

Expected Behavior I don't see any way with the C API to check whether the type of the symbol (in C++ this is getSymbolFlags(Symbol)). If that's right, we might just have to remove size from the API, or mark it unsafe with a comment that explains the situation.

LLVM Version (please complete the following information):

TheDan64 commented 4 years ago

Agreed - I think marking it unsafe and adding documentation is better than removing it altogether.

TheDan64 commented 4 years ago

Though it's a shame the C API lacks a symbol check