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

    <tr>
        <th>Summary</th>
        <td>
            lld 16 appears to have memory leaks on Android AArch64
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    I see random crashes when linking, that always go away if I run the same command again, ie it's usually not repeatable. This is only since the LLVM 16 update, LLVM 15 worked well, as noted in termux/termux-packages#15867.

Sometimes, it'll just segfault:
```
error: link command failed with exit code 1 (use -v to see invocation)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /data/data/com.termux/files/usr/bin/ld.lld --sysroot=/data/data/com.termux/files -pie -EL --fix-cortex-a53-843419 -z now -z relro -z max-page-size=4096 --hash-style=gnu -rpath=/data/data/com.termux/files/usr/lib --eh-frame-hdr -m aarch64linux -dynamic-linker /system/bin/linker64 -o ...
clang-16: error: unable to execute command: Segmentation fault
clang-16: error: linker command failed due to signal (use -v to see invocation)
```
Other times, it'll claim issues with memory tagging:
```
error: link command failed with exit code 1 (use -v to see invocation)
Pointer tag for 0xe2a9a7d900000000 was truncated, see 'https://source.android.com/devices/tech/debug/tagged-pointers'.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
clang-16: error: unable to execute command: Aborted
clang-16: error: linker command failed due to signal (use -v to see invocation)
```
Most likely, this is a memory leak that sometimes causes segfaults.

I tried to reproduce [on Ubuntu 20.04 x86_64 by building a Swift package repeatedly with the official clang 16.0.0 build on github Actions](https://github.com/buttaface/swift-android-sdk/blob/a752d8c20d0ef539c0db8c554440f65ee6906e6c/.github/workflows/sdks.yml), but [could not](https://github.com/buttaface/swift-android-sdk/actions/runs/4713291773) after [50+ builds of a couple Swift packages](https://github.com/buttaface/swift-android-sdk/actions/runs/4713675851), implying this is an issue only on AArch64 or some Bionic interaction.

If someone could test lld 16 on linux AArch64 and report their results, should help narrow this down, may be related to prior lld issues #58056 or #60456.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVl1v67gR_TX0y0CCRH3YfvBDcnMNXCCLLpC2r8WIHElcU6TAj9jaX19Qcnyb7Qduu8DWCEKblIaHZ86cIXqvBkN0Ys0za152GMNo3amLIWCPgnadlcvpG3gicGiknUA49CN5uI5kQCtzUWZg_AuEEQOgvuLiYbCAV1xA9fANXDQQRgKPE4Gw04RGAg6oTHpNEajA-N5D9BG1XsDYAI5mwoCdphz-PCoPyoM1egGvjKA13OvrX3-CsoU4SwyUQm0zDVytu5CEK2mdptGnkCRBGQjkpnhj_Lx9yWYUFxzIM16VzaHd56x4YcXT9v_NThTUlFa_bCC1hl-iD-Bp6DHqwKr7o6wt7n_rT3LOOlY9rfw8ztyj0gmXCiPQTQUQVhKUwPgheoLsHYJdmVbm3QoMyhrGj1vEn1-_Pr19BR-7SQVA6OKQSLIupJfGEGafwPAz4-dBhTF2ubAT42et3z-GbHb2FxKB8bPyPqZznSEBU0boKDda1_RCh-ISHAq6E_IWUFxAxml-HLnIYf387OzgcAJ0Q5zIhIQDGD9LDPh9EHbKH-T3Sq-bR-8YP3dJCGctc60lZJlfvLM2sOrlB4JANiuC7OsrZFmvbpmwLtAtw6bKDnVVl0fIfgVjr2lwpJ1NXyZMiR8o8-pXYtVLXRxbyLIR_Zj5sOg0N5gImZsxjD8G5HEarTrIMhqz3uFE2SgdZBMgOjG2tVYm3iCTi8FJiSypg1wiyy8-0PSdjHWhrSGzkOf3HAiNZsjKNvH7EFg0qUiSBuhGIoZHhaXFNxpSRlYlwSbYfx_pDuY3YpVxDZ5cAvUPKfU3pfCnMJKDfyojoVFNsMlwq4iJJusWCDgMyVH-uMqyyoQEEQforYPiRhyPuJfH4v6BK3oILhqBgWQ6R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