<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Consolas","serif";}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Alexey,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I think the most likely way to resolve this is to have the RecordingMemoryManager do something more complex to manage its allocations in such a way as to guarantee
that they are all within proximity of one another. The code that is asserting is handling a relocation where code was generated to use a 32-bit relative offset in 64-bit code. If the two sections involved really are more than a 32-bit offset apart then the
generated code will not work.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Alternatively, we could have MCJIT use whatever code generation option will prevent 32-bit relative relocations from being generated in the first place. That
would probably be preferable, but I haven’t had success trying to do that in limited efforts up to now.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">As it happens, I’m working with the ‘-use-remote’ option for lli this week trying to add support for actual out-of-process execution. As I do, I’ll take a
look at the allocation scheme in RecordingMemoryManager and see if there is something reasonable I can do there.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">In the meantime, is there any way that you can mark these tests as XFAIL in the sanitizer case?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Alexey Samsonov [mailto:samsonov@google.com]
<br>
<b>Sent:</b> Tuesday, January 29, 2013 3:36 AM<br>
<b>To:</b> LLVM Developers Mailing List<br>
<b>Cc:</b> Kaylor, Andrew<br>
<b>Subject:</b> Assertions in RuntimeDyldELF in ExecutionEngine/MCJIT tests<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi!<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I'm trying to run LLVM test suite under AddressSanitizer and get test failures in:<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> LLVM :: ExecutionEngine/MCJIT/simpletest-remote.ll<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LLVM :: ExecutionEngine/MCJIT/test-data-align-remote.ll<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LLVM :: ExecutionEngine/MCJIT/test-fp-no-external-funcs-remote.ll<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> LLVM :: ExecutionEngine/MCJIT/test-global-init-nonzero-remote.ll<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">All of them fail with assertion:<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The reason is that AddressSanitizer replaces system malloc with its own allocator, which<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">allocates memory at "unusual" parts of heap and the difference between pointers can be significant<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">(and doesn't fit in 32 bytes).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I add debug output to calculation of RealOffset in resolveX86_64Relocation:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> uint64_t FinalAddress = Section.LoadAddress + Offset;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> int64_t RealOffset = *Placeholder + Value + Addend - FinalAddress;<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> fprintf(stderr, "%x + %lx + %lx - %lx = %lx\n",<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> *Placeholder, Value, Addend, FinalAddress, RealOffset);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> assert(RealOffset <= INT32_MAX && RealOffset >= INT32_MIN);<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<pre style="line-height:13.5pt;white-space:pre-wrap" id="TargetResultLogContent"><span style="color:black"><o:p> </o:p></span></pre>
<pre style="line-height:13.5pt"><span style="font-family:"Arial","sans-serif";color:#222222">This is what I get for system malloc:</span><span style="color:black"><o:p></o:p></span></pre>
<pre style="line-height:13.5pt;white-space:pre-wrap" id="TargetResultLogContent"><span style="color:black"><o:p> </o:p></span></pre>
<pre style="line-height:13.5pt"><span style="color:black">0 + 7fec9867a000 + 0 - 7fec9867a040 = ffffffffffffffc0<o:p></o:p></span></pre>
<p class="MsoNormal">This is what I get for ASan allocator (which results in assert failure):<o:p></o:p></p>
<pre style="line-height:13.5pt;white-space:pre-wrap" id="TargetResultLogContent"><span style="color:black"><o:p> </o:p></span></pre>
<pre style="line-height:13.5pt"><span style="color:black">0 + 600c0000a8a0 + 0 - 6018000090a0 = fffffff400001800<o:p></o:p></span></pre>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Alexey Samsonov, MSK<o:p></o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>