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

    <tr>
        <th>Summary</th>
        <td>
            In-process unwinding does not work with -fsanitize=memtag-stack
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libunwind,
            backend:AArch64
      </td>
    </tr>

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

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

<pre>
    In-process unwinding using `libunwind.h` cannot be used with `-fsanitize=memtag-stack`, because it does not clear the allocation tags from the stack, which can cause a fault in later code, which can assume that the stack memory below SP has tags matching SP. For exception unwinding, it is the stage 2 unwind which clears the allocation tags, but that is not done for in-process unwinding.

I don't think clearing the tags in `unw_step`  when doing in-process unwinding would work, because that could result in clearing the tags of the currently executing function, which would also cause a fault. This would also break users who want to use the unwinder to examine the stack contents, but don't call `unw_resume`. The only solution I can think of is to clear the tags in `__libunwind_Registers_arm64_jumpto`, immediately before resuming execution outside the unwinder.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VEFvqzgQ_jXmMioCk0Bz4JB9VaTenvbtPRrMAH4xdmSPl3Z__cqQpqm2ezHIM8w33_cNgyHo0RK1Yv-H2L9kGHlyvnWB0Vr0fda5_r19tU9X7xSFANEu2vbajhBDOkVdGN1tt_kk6gIUWusYOoIYqIdF85SynoaAVrP-h0T1MtPMOD4FRnURdSHkD-hIYQwEmqF3FCDVUIbQA08EaIxTyNpZYBwDDN7Na2ArIX_AMmk1JXDY6iAMGA2DtmCQyYNyPX1NxBDiTMAT8mctmGl2_h06Mm6BXz9hwrBhzshqSpx__czh5DzQm6Lr2tNdlQSgGXT4KDgSyFv4AzmRCt-xWmWIvDWkNwl6ZwkG50F_40EuihdRHLfzNeUK2aTvtb1sOKndhLQS0DYZEe1yDkzX5BUsE1noXUr7DgAWF00Pi_OXR4_WBtUa8hRuKv8Xzw3ru4rek2XzDvRGKnLKGaJVifenIRsSmuC-GpjDX5MOj-HOE17ScPkAy-RgQcvADrbO6NY9-XRHbzhrSw_2KmeZLN_F_hBNoTEf8iRSM4m6SOAEzpp3CM7E1anXdXY2jd2wWu0eJvVB6fP5_muc_6RRByYfzujnenf-Hecru9vs63mmXiOTSXM3OE-rrnNS6qaZs-AiB91_5ZhnfVv1h-qAGbVl_Vw2si7KQza1WMpGKmqq5oA72jf9c12pQ0MDocL6ucl0KwtZFbuyKYui3h_yQ7VvmlKiouehVFUndgXNqE1uzN9z7vyY6RAitbUsmzoz2JEJ696Q8s5TSCnkDyFlh-pCthfV8Xj0aqp3KbJ_yXybqj11cQxiVxgdOHzWZ82Gvt82952QZnFbKv-7UbLoTTsxX4OojkKehDyNmqfY5crNQp4S3u2RkH6TYiFPK7kg5Gnl928AAAD__8lZxjk">