<div dir="ltr">Hi!<div><br></div><div>I'm trying to run LLVM test suite under AddressSanitizer and get test failures in:</div><div><div>    LLVM :: ExecutionEngine/MCJIT/simpletest-remote.ll</div><div>    LLVM :: ExecutionEngine/MCJIT/test-data-align-remote.ll</div>
<div>    LLVM :: ExecutionEngine/MCJIT/test-fp-no-external-funcs-remote.ll</div><div>    LLVM :: ExecutionEngine/MCJIT/test-global-init-nonzero-remote.ll</div></div><div style><br></div><div style>All of them fail with assertion:</div>
<div style><div>lli: /usr/local/google/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:230: void llvm::RuntimeDyldELF::resolveX86_64Relocation(const llvm::SectionEntry &, uint64_t, uint64_t, uint32_t, int64_t): Assertion `RealOffset <= (2147483647) && RealOffset >= (-2147483647-1)' failed.</div>
<div><br></div><div style>The reason is that AddressSanitizer replaces system malloc with its own allocator, which</div><div style>allocates memory at "unusual" parts of heap and the difference between pointers can be significant</div>
<div style>(and doesn't fit in 32 bytes).</div><div style><br></div><div style>I add debug output to calculation of RealOffset in resolveX86_64Relocation:</div><div style><br></div><div style><div>    uint64_t  FinalAddress = Section.LoadAddress + Offset;<br>
</div><div>    int64_t RealOffset = *Placeholder + Value + Addend - FinalAddress;</div><div>    fprintf(stderr, "%x + %lx + %lx - %lx = %lx\n",</div><div>            *Placeholder, Value, Addend, FinalAddress, RealOffset);</div>
<div>    assert(RealOffset <= INT32_MAX && RealOffset >= INT32_MIN);</div></div><div style><br></div><div style><pre id="TargetResultLogContent" style="margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);line-height:18px">
<span style="color:rgb(34,34,34);font-family:arial;line-height:normal;white-space:normal">This is what I get for system malloc:</span><br></pre><pre id="TargetResultLogContent" style="margin-top:0px;margin-bottom:0px;white-space:pre-wrap;color:rgb(0,0,0);line-height:18px">
0 + 7fec9867a000 + 0 - 7fec9867a040 = ffffffffffffffc0</pre>This is what I get for ASan allocator (which results in assert failure):<pre id="TargetResultLogContent" style="margin-top:0px;margin-bottom:0px"><pre id="TargetResultLogContent" style="color:rgb(0,0,0);line-height:18px;white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
0 + 600c0000a8a0 + 0 - 6018000090a0 = fffffff400001800</pre></pre></div></div><div><br></div><div><div>--<br></div><div>Alexey Samsonov, MSK</div>
</div></div>