[LLVMbugs] [Bug 20722] New: Can't add 16K+ (4*PageSize) object file to MCJIT.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Aug 21 10:13:47 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20722

            Bug ID: 20722
           Summary: Can't add 16K+ (4*PageSize) object file to MCJIT.
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: aleksey.bader at mail.ru
                CC: lhames at gmail.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I'm trying to add an object file created with
object::ObjectFile::createObjectFile to MCJIT using addObjectFile the same way
lli is doing it.
I found that if file size is > 4*PageSize MCJIT crashes with seg. fault trying
to load it.

The problem is that if object file exceeds 4*PageSize MemoryBufferMMapFile is
used to allocate memory and it marks allocated memory as read-only.
MCJIT creates ObjectImage from ObjectFile, but it simply sets internal pointers
to the memory allocated for ObjectFile.
The crash happens during the ObjectImage loading when loader tries to update
emitted ELF section address, which resides in read-only memory.

In order to reproduce the issue almost any ELF object is enough. For instance
lli.o can be used:

bin/lli -use-mcjit -extra-object=./tools/lli/CMakeFiles/lli.dir/lli.cpp.o <
../llvm/test/ExecutionEngine/Interpreter/intrinsics.ll
0  lli             0x0000000000a088e2 llvm::sys::PrintStackTrace(_IO_FILE*) +
34
1  lli             0x0000000000a08494
2  libpthread.so.0 0x00007fd0b2f03340
3  lli             0x0000000000b61365
4  lli             0x0000000000b524e3
llvm::RuntimeDyldImpl::emitSection(llvm::ObjectImage&, llvm::object::SectionRef
const&, bool) + 627
5  lli             0x0000000000b52bc0
llvm::RuntimeDyldImpl::findOrEmitSection(llvm::ObjectImage&,
llvm::object::SectionRef const&, bool, std::map<llvm::object::SectionRef,
unsigned int, std::less<llvm::object::SectionRef>,
std::allocator<std::pair<llvm::object::SectionRef const, unsigned int> > >&) +
176
6  lli             0x0000000000b53674
llvm::RuntimeDyldImpl::loadObject(llvm::ObjectImage*) + 2452
7  lli             0x0000000000b53af3
llvm::RuntimeDyld::loadObject(std::unique_ptr<llvm::object::ObjectFile,
std::default_delete<llvm::object::ObjectFile> >) + 131
8  lli             0x0000000000841bab
llvm::MCJIT::addObjectFile(std::unique_ptr<llvm::object::ObjectFile,
std::default_delete<llvm::object::ObjectFile> >) + 43
9  lli             0x0000000000516a29 main + 2489
10 libc.so.6       0x00007fd0b232eec5 __libc_start_main + 245
11 lli             0x0000000000527230
Stack dump:
0.    Program arguments: bin/lli -use-mcjit
-extra-object=./tools/lli/CMakeFiles/lli.dir/lli.cpp.o 
zsh: segmentation fault (core dumped)  bin/lli -use-mcjit
-extra-object=./tools/lli/CMakeFiles/lli.dir/lli.cpp.o <

-- 
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/20140821/b4dc1178/attachment.html>


More information about the llvm-bugs mailing list