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

    <tr>
        <th>Summary</th>
        <td>
            ThreadSanitizer doesn't work with memory overcommit disabled
        </td>
    </tr>

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

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

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

<pre>
    On Linux, if memory overcommit has been disabled (`sysctl -w vm.overcommit_memory=2`), all programs compiled with `-fsanitize=thread` crash on startup with an error message...

```
==363640==ERROR: ThreadSanitizer failed to allocate 0x200000000000 (35184372088832) bytes at address 100000000000 (errno: 12)
FATAL: ThreadSanitizer can not mmap the shadow memory
FATAL: Make sure to compile with -fPIE and to link with -pie.
```

... that indicates ThreadSanitizer attempted to allocate *32 terabytes* of RAM.  That's not a reasonable amount of memory to expect a developer workstation to have.

Please change ThreadSanitizer so that it only allocates shadow memory proportional to the amount of RAM that the program actually uses.  You can probably use `MAP_NORESERVE` to allocate a range of *address space* without also allocating RAM.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsVF2PozYU_TXOy9UgYxMgDzzQJpEq7XRG2VGlPq0ucAnuGBvZJpnsr69M2J3tTCNLQeZ-nHPu4aL36myIKrb9jW33G5zDYF31HdvX66ax3a16MvBFmfmNid9B9TDSaN0N7IVca8dRBRjQQ0NkoFMeG00dMFGynPubb4OGhytcxuQ9_tu9ApN7wXLOxC4WRq1hcvbscPTQ2nFSsc5VhQFYzh96j0YF9Z2Y3IfBEXYs59A69ANYAz6gC_N0j0cD5Jx1MJL3eKYkSRiv48n5enjN5J7JvcxlnvH78-F0ejoxWcPLUv_r2tBBjwuWYCNI22Ig4G-Cv_8iXblNy0wWgpdlKQUTO2hugTxgAOw6R95D-iGFnDM2NkxjPOP1sX6pv_wfghYNGBtgHHGCMBD4ATt7XUfxa-YjvhL42VGEu8p4V-Whf_7jAGgWIlqZ1_V6UpR81IbXSZJAGDCAMp2KlP0nUBgCjVP4oAwTtRQQyOHCn4kabA-n-jEBeBkwMFH4hQuCI_TWRMMAjnY2IUau7goW6G2iNsZ1dCFtJ3Jwte7VBwzKmhgx4IXW0T5rQk_QDmjO9AmqtyuZANbo20-0_r9CRgNO1sXyqGODKPU7tFP9eC8Tr1evArZhRq1vMHvyCcDfdl7GNTnbYHO_jw5-rJ-__fl0Onw9nP46RO_-KhqCW3DbPur3wy9-wpaigHFQdg6A2v9MUua8qLrpKtnt5A43VKVFlmdFUcrdZqg62XaYUl-WEtsiz8pmV2La8jyjRmZ9s1GV4GLLt3wreCa3uwS3_S6VZVnkZSqaQrKM04hKJ1rH79edN8r7mapUltsy3WhsSPtlbQhh6ArLWyZE3CKuikkPzXz2LONa-eDfywQVNFUfh9RZ8oaJIixjvrvz8675sWI2s9PVEMLkmayZODJxPKswzE3S2pGJY2y2_j1Mzv5DbWDiuED0TBxXDpdK_BsAAP__NZ6l_Q">