Skip to content

[libc++] AddressSanitizer: alloc-dealloc-mismatch in std::logic_errorΒ #59432

@nejati-deriv

Description

@nejati-deriv

I get AddressSanitizer: alloc-dealloc-mismatch in clang-15 with -stdlib=libc++ -fsanitize=address flags and the whole program is this:

#include <stdexcept>
int main()
{
    std::logic_error{ "" };
}

Sanitizer error:

=================================================================
==79415==ERROR: AddressSanitizer: alloc-dealloc-mismatch (operator new vs free) on 0x603000000040
    #0 0x558fd6293a82 in free (/playground/a.out+0xa3a82) (BuildId: ae9dce31ab7cc3ca9e64b2d1b16f0ba849df934f)
    #1 0x7fce037bd1dc in std::invalid_argument::~invalid_argument() (/lib/x86_64-linux-gnu/libc++abi.so.1+0x251dc) (BuildId: 1a7ce38f20a183a91a0b31e669d05c2496da04fa)
    #2 0x558fd62d0587 in main (/playground/a.out+0xe0587) (BuildId: ae9dce31ab7cc3ca9e64b2d1b16f0ba849df934f)
    #3 0x7fce0346ed8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #4 0x7fce0346ee3f in __libc_start_main csu/../csu/libc-start.c:392:3
    #5 0x558fd620e304 in _start (/playground/a.out+0x1e304) (BuildId: ae9dce31ab7cc3ca9e64b2d1b16f0ba849df934f)

0x603000000040 is located 0 bytes inside of 25-byte region [0x603000000040,0x603000000059)
allocated by thread T0 here:
    #0 0x558fd62cdf0d in operator new(unsigned long) (/playground/a.out+0xddf0d) (BuildId: ae9dce31ab7cc3ca9e64b2d1b16f0ba849df934f)
    #1 0x7fce0381ddff in std::logic_error::logic_error(char const*) (/lib/x86_64-linux-gnu/libc++.so.1+0x4edff) (BuildId: 6dc24a34f4ad0c914eb49741b347bf98939414c9)
    #2 0x7fce0346ed8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

SUMMARY: AddressSanitizer: alloc-dealloc-mismatch (/playground/a.out+0xa3a82) (BuildId: ae9dce31ab7cc3ca9e64b2d1b16f0ba849df934f) in free
==79415==HINT: if you don't care about these errors you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
==79415==ABORTING

It only happens with -stdlib=libc++
Clang's version:

Ubuntu clang version 15.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bi

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.packaging

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions