<div dir="ltr"><div>Hmm, it turns out that the issue actually lies in CodeModel. If CodeModel::Small is specified, it seems like LLJIT assumes the data symbol lies in first 2GB memory. It then silently truncates the address of the constant string to a 32-bit pointer, without reporting any error. That's why the address becomes invalid (the actual address for the string is at something like  0x<span style="color:rgb(255,0,0)">7fff</span>f7fab054). <br></div><div><br></div><div>Given that LLJIT never attempts to allocate its executable code in first 2GB memory (I grepped 'MAP_32BIT' in LLVM and found nothing), is it error prone to allow CodeModel::Small to be specified?</div><div><br></div><div>Best,</div><div>Haoran</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Haoran Xu <<a href="mailto:haoranxu510@gmail.com">haoranxu510@gmail.com</a>> 于2020年11月4日周三 下午8:57写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>Recently I hit an issue that LLJIT crashes when CodeGenOpt::Less or higher is given. <br></div><div>After investigation, it turned out that the issue is some global constant string in the IR, like</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>@.str.117 = private unnamed_addr constant [9 x i8] c"lineitem\00", align 1</div></blockquote><div>becomes an invalid pointer in the generated code. <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>$1 = 0xf7fab054 <error: Cannot access memory at address 0xf7fab054></div></blockquote><div><br></div><div>The issue doesn't show up when CodeGenOpt::None is given. It also doesn't show up when the host program (which uses the LLVM library) is compiled with "-O0". So it looks like some kind of use-after-free issue.</div><div><br></div><div>Does any one have seen similar issues before, or have some idea on how to fix this?</div><div>Thanks!<br></div><div><br></div><div>Best,</div><div>Haoran<br></div><div><br></div></div>
</blockquote></div>