Skip to content

ASAN reports 'stack-use-after-scope' at seemingly random places after switching to clang15 #58633

@davenger

Description

@davenger

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: ClickHouse/ClickHouse#41500

@vitalybuka @eugenis @itrofimow, we found some recent changes around ASan interceptor and stack size limit
d0751c9
868e1ee
15e9b1d
could this lead to the problem that we are seeing?

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions