<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/104505>104505</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            UBSAN + OrcJIT crashes when code is placed at beginning of page
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            compiler-rt:asan,
            orcjit
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          MatzeB
      </td>
    </tr>
</table>

<pre>
    UBSAN from LLVM >= 17.x reads 8 bytes in front of a function to look for markers. This fails when a JIT compiler like ORC-Jit places code immediately at the beginning of an `mmap`ed section (so reading 8 byte upfront ends up in unmapped memory and crashes).

See also https://reviews.llvm.org/D148665 and the similar discussion in https://github.com/llvm/llvm-project/issues/65253

Not sure if ORC should/wants to do something generic to avoid users running into this. For the time being I added this workaround to one of our porjects to unblock our codebase: https://github.com/pytorch/pytorch/pull/133623/files


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyck0-TozYQxT-NuHSNCwvkgQMHzzpU7db-qcpucheoMVoLNaWWZuJ8-pRgkuzkkMNebBBdrV-_108z26tH7IR6EupS6BRnCt0nHf_Ep2Igc-9-e_p6_gxToAU-fvz9E4jqF1Fd4Ph4-AMCasPQwHCPyGB9LvMRaAINU_JjtOQhEjiiG0wUYNHhhoEP8G22DJO2juFlRg8aPrz_BiMtq3UYwNkbwpdf3z18sBFWp0dkGMkg2GVBY3VEdwcdIc4IA16t99Zft3s9iFO5LHoVpxINMO4QQjZMG28u3IkhrTsvesOQ1jxA8oteVzSw4ELhDtobGIPmGVnI9iDKiyjP--9XRNCOCeYYVxbVWcheyD7gs8UXPjj3vBwoXIXsL8e6OZ3U1iwTs12s0wGM5TExZz7r_9PmauOchsNIi5B97vX697AG-o5jFLK3zClj9SclVfUj2meKwCkg2CmrCDxTckbI_kX7yNkRQ8C0YJyzHFf0GOyYz_UzWQOJMTCEtMtqfSSIs-UD9BS2CaJdsvD563vQxqDZCuCFwk0HSnlQAvKYPaEUYKWQqbe7kx8cjbftPJs6aEZRnf9PgPUeKYzz26fknJD9sapOshKyn6xD_lGFwnSVaatWF9gdH2X1qJRqVTF3ZWuaY4m1OjatbGQ9qVMzVY_DhKeyqaQpbCdLWZfNUclStUodcBpRV1Wr2masG1WLusRFW_ePy8VmRncsa1WqwukBHW-hkvLvpX4IUVRnzdoLKYV8J6SkMH63Mb-qSxG6zd8hXVnUpbMc_12iItro8DWLQj7BlzBugdlXc8_QHhDe82JyPN5EY9VXLFJw3c8v2ut4z538KwAA___DzGQW">