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

    <tr>
        <th>Summary</th>
        <td>
            ASAN reports 'stack-use-after-scope' at seemingly random places after switching to clang15
        </td>
    </tr>

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

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

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

<pre>
    We recently switched to building ClickHouse with clang15 and started seeing 'stack-use-after-scope' at seemingly random places that look like false positives. Here is one example: asan reports problem in memcpy() called from realloc() to copy old data to a new buffer. From the code the new buffer cannot be on the stack. Also the reported address is 0x7f16fbf4f4f0 which is about 8GB apart from BP register (0x7f151225d980). So it doesn't look like it is on the stack.
```
=================================================================
==646==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7f151225d980 at pc 0x00000dfc05aa bp 0x7f16fbf4f4f0 sp 0x7f16fbf4ecc0
WRITE of size 33554432 at 0x7f151225d980 thread T994 (QueryPipelineEx)
    #0 0xdfc05a9 in __asan_memcpy (/usr/bin/clickhouse+0xdfc05a9) (BuildId: e2f3e57c9d5750229244e6ee26377f571bcec5b8)
    #1 0x1ea29560 in Allocator<false, false>::realloc(void*, unsigned long, unsigned long, unsigned long) build_docker/../src/Common/Allocator.h:172:13
...
```

Here we have some more examples of these reports: https://github.com/ClickHouse/ClickHouse/issues/41500

@vitalybuka @eugenis @itrofimow, we found some recent changes around asan interceptor and stack size limit
https://github.com/llvm/llvm-project/commit/d0751c9725aab1dad3d86481e13a4628356e7422
https://github.com/llvm/llvm-project/commit/868e1ee1d02c153d867a9f4e2b7e35df7d0701df
https://github.com/llvm/llvm-project/commit/15e9b1d0c0bea607fc0aad4a851ddd32b5736c80
could this lead to the problem that we are seeing?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVU1zpDYQ_TXMRWVKCITg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