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

    <tr>
        <th>Summary</th>
        <td>
            [libFuzzer] Shouldn't use STL and inner malloc (which is not async-signal-safe) in signal handler
        </td>
    </tr>

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

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

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

<pre>
    For example, in `void Fuzzer::AlarmCallback()`, it will call [DumpCurrentUnit](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/fuzzer/FuzzerLoop.cpp#L303), and then call [Sha1ToString](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/fuzzer/FuzzerLoop.cpp#L181) which will use [std::string](https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/fuzzer/FuzzerSHA1.cpp#L211) etc. and inner malloc/free.

However, since we already in signal handler, we should only call async-signal-safe functions, and to be detail, we maybe crashed at malloc-like functions. And if there is lock in modified malloc wrapper, we will stuck at lock, and the fuzzer process can never exit.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzElL-SozgQxp9GJF2mhDAYAgKvXdQGzrz3APrTGJ2FRElivJ6nvxJ45qZqoktuEzto9Ve_7u9reAj6ZhE7Uv0g1TnjSxyd7y7oLJ5GtJlw6tn1zgP-5tNskLATaAukpm9OK-iX93f0pDyS8ng03E8nbozg8k5YQ1hLaro2RHhoY0ByY4BUP87LNJ8W79HGv6yOpDoT1owxziEpsZ6w_qbjuIhcuomw3pi3j7_d7N3fKCNhvTBOENZPXFvCeummWRv0O59qRqfSsNGxfsO8ODfncp4JKy8lLRMfOwG3CuKI9pPuOvLil7tGr-3tT6AVTUFYC49Ry3Hb2xIwgYWotk2H_5Xt-vNYfLCxYmXDKPN1cdpa9DBxY5xMnR4xJ_RM6HH7_eke-Ja0ThC0lQgPBG48cvVMMUrh4wZGbpXZXj0QwugWo8BZ89w84eFp5W57uwt8QBgWK6N2Nnwa6EAgKIxcm5fMxJ8CQXoeRlTA44tyZ_T9i0AOxzTGkCLgEXQA4-Q9sU1O6UGjevXBw_N5_oRcfQlxkfcknXq-ZAm2DcLsncQQQHILNu0B8LeOeaa6UrVlyzPsivpQUVqylmVjJw4lbVoUctgrVXFBa9U2chADbWuu9k2mO0ZZSQvWFvt9UbL8UB7KA1P0UJViwKIhe4oT1yZPpufO3zIdwoJdTcu6zgwXaMJ664xZfMBaJIyl0_fdGhSx3ALZU6NDDP-qRB3N-pEwWrxuvjrDdXXKEnaIa0avvy7fUgGENVuUdQDr4nc3U6C-ZSFbvOn-c7bXeQJh_TrvPwEAAP__K_2b6A">