llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.04k stars 11.98k forks source link

[clang] Multiple destructor calls emitted with consteval usage in switch statement #60249

Open deepbluev7 opened 1 year ago

deepbluev7 commented 1 year ago

I have the following source (haven't managed to reduce this further with multiple approaches, so sorry this is a bit long, maybe someone can help me?) which seems to generate the wrong assembly:

namespace {
std::shared_ptr<spdlog::logger> qml_logger    = nullptr;

void
qmlMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
    std::string localMsg = msg.toStdString();
    const char *file     = context.file ? context.file : "";
    const char *function = context.function ? context.function : "";

    if (
      msg.endsWith(QStringLiteral("Both point size and pixel size set. Using pixel size.")))
        return;

    switch (type) {
    case QtDebugMsg:
        nhlog::qml()->debug("{} ({}:{}, {})", localMsg, file, context.line, function);
        break;
    case QtInfoMsg:
        nhlog::qml()->info("{} ({}:{}, {})", localMsg, file, context.line, function);
        break;
    case QtWarningMsg:
        nhlog::qml()->warn("{} ({}:{}, {})", localMsg, file, context.line, function);
        break;
    case QtCriticalMsg:
        nhlog::qml()->critical("{} ({}:{}, {})", localMsg, file, context.line, function);
        break;
    case QtFatalMsg:
        nhlog::qml()->critical("{} ({}:{}, {})", localMsg, file, context.line, function);
        break;
    }
}
}

namespace nhlog {
std::shared_ptr<spdlog::logger>
qml()
{
    return qml_logger;
}
}

Full context: https://github.com/Nheko-Reborn/nheko/blob/8835040db61d039af4bab34e36b1e634bb9d1d1f/src/Logging.cpp

To my understanding, this is legal code and I ran this with undefined sanitizer. It however causes a crash and triggers the address sanitizer:

==29161==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fd44a03b518 at pc 0x55ec7d083e2e bp 0x7fffc5a7c090 sp 0x7fffc5a7c088
READ of size 8 at 0x7fd44a03b518 thread T0
    #0 0x55ec7d083e2d in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/shared_ptr_base.h:1070:6
    #1 0x55ec7da9d22c in std::__shared_ptr<spdlog::logger, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr() /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/shared_ptr_base.h:1524:31
    #2 0x55ec7da80568 in std::shared_ptr<spdlog::logger>::~shared_ptr() /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/bits/shared_ptr.h:175:11
    #3 0x55ec7f4410f9 in (anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&) /home/nicolas/Dokumente/devel/open-source/nheko/src/Logging.cpp:62:5
    #4 0x7fd4501a49b7 in qt_message_print /usr/src/debug/dev-qt/qtcore-5.15.8-r1/qtbase-everywhere-src-5.15.8/src/corelib/global/qlogging.cpp:1843:57
    #5 0x7fd4501a608f in qt_message_output(QtMsgType, QMessageLogContext const&, QString const&) /usr/src/debug/dev-qt/qtcore-5.15.8-r1/qtbase-everywhere-src-5.15.8/src/corelib/global/qlogging.cpp:1924:21
    #6 0x7fd4502a202f in QDebug::~QDebug() /usr/src/debug/dev-qt/qtcore-5.15.8-r1/qtbase-everywhere-src-5.15.8/src/corelib/io/qdebug.cpp:154:30
    #7 0x7fd4517ac4cf in dumpwarning /usr/src/debug/dev-qt/qtdeclarative-5.15.8-r2/qtdeclarative-everywhere-src-5.15.8/src/qml/qml/qqmlengine.cpp:2073:55
    #8 0x7fd4517c2d44 in QQmlComponentPrivate::complete(QQmlEnginePrivate*, QQmlComponentPrivate::ConstructionState*) /usr/src/debug/dev-qt/qtdeclarative-5.15.8-r2/qtdeclarative-everywhere-src-5.15.8/src/qml/qml/qqmlcomponent.cpp:1008:36
    #9 0x7fd4517c2d44 in QQmlComponentPrivate::complete(QQmlEnginePrivate*, QQmlComponentPrivate::ConstructionState*) /usr/src/debug/dev-qt/qtdeclarative-5.15.8-r2/qtdeclarative-everywhere-src-5.15.8/src/qml/qml/qqmlcomponent.cpp:996:6
    #10 0x7fd4517c4e2f in QQmlComponentPrivate::completeCreate() /usr/src/debug/dev-qt/qtdeclarative-5.15.8-r2/qtdeclarative-everywhere-src-5.15.8/src/qml/qml/qqmlcomponent.cpp:1092:17
    #11 0x7fd4517c4fe5 in QQmlComponent::completeCreate() /usr/src/debug/dev-qt/qtdeclarative-5.15.8-r2/qtdeclarative-everywhere-src-5.15.8/src/qml/qml/qqmlcomponent.cpp:1079:22
    #12 0x7fd4517c4fe5 in QQmlComponent::create(QQmlContext*) /usr/src/debug/dev-qt/qtdeclarative-5.15.8-r2/qtdeclarative-everywhere-src-5.15.8/src/qml/qml/qqmlcomponent.cpp:825:23
    #13 0x7fd451d24c9b in QQuickView::continueExecute() /usr/src/debug/dev-qt/qtdeclarative-5.15.8-r2/qtdeclarative-everywhere-src-5.15.8/src/quick/items/qquickview.cpp:492:55
    #14 0x55ec7f491a60 in MainWindow::MainWindow(QWindow*) /home/nicolas/Dokumente/devel/open-source/nheko/src/MainWindow.cpp:93:5
    #15 0x55ec7f77e6f6 in main /home/nicolas/Dokumente/devel/open-source/nheko/src/main.cpp:341:16
    #16 0x7fd44f834305 in __libc_start_call_main /usr/src/debug/sys-libs/glibc-2.36-r6/glibc-2.36/csu/../sysdeps/nptl/libc_start_call_main.h:58:16
    #17 0x7fd44f8343c7 in __libc_start_main /usr/src/debug/sys-libs/glibc-2.36-r6/glibc-2.36/csu/../csu/libc-start.c:381:3
    #18 0x55ec7ce3b940 in _start (/home/nicolas/Dokumente/devel/open-source/nheko/build-clang-san/nheko+0x72cf940)

This is with libfmt 9.1.0 and spdlog 1.11.0.

The following assembly is generated for the qmlMessageHandler function:

00000000000008a0 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)>:
{
 8a0:   55                      push   rbp
 8a1:   48 89 e5                mov    rbp,rsp
 8a4:   48 81 ec 70 01 00 00    sub    rsp,0x170
 8ab:   64 48 8b 04 25 28 00 00 00  mov    rax,QWORD PTR fs:0x28
 8b4:   48 89 45 f8             mov    QWORD PTR [rbp-0x8],rax
 8b8:   89 bd 64 ff ff ff       mov    DWORD PTR [rbp-0x9c],edi
 8be:   48 89 b5 58 ff ff ff    mov    QWORD PTR [rbp-0xa8],rsi
 8c5:   48 89 95 50 ff ff ff    mov    QWORD PTR [rbp-0xb0],rdx
    std::string localMsg = msg.toStdString();
 8cc:   48 8b b5 50 ff ff ff    mov    rsi,QWORD PTR [rbp-0xb0]
 8d3:   48 8d 7d d8             lea    rdi,[rbp-0x28]
 8d7:   e8 00 00 00 00          call   8dc <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x3c>    8d8: R_X86_64_PLT32 QString::toStdString[abi:cxx11]() const-0x4
    const char *file     = context.file ? context.file : "";
 8dc:   48 8b 85 58 ff ff ff    mov    rax,QWORD PTR [rbp-0xa8]
 8e3:   48 83 78 08 00          cmp    QWORD PTR [rax+0x8],0x0
 8e8:   0f 84 17 00 00 00       je     905 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x65>
 8ee:   48 8b 85 58 ff ff ff    mov    rax,QWORD PTR [rbp-0xa8]
 8f5:   48 8b 40 08             mov    rax,QWORD PTR [rax+0x8]
 8f9:   48 89 85 e8 fe ff ff    mov    QWORD PTR [rbp-0x118],rax
 900:   e9 13 00 00 00          jmp    918 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x78>
 905:   48 8d 05 00 00 00 00    lea    rax,[rip+0x0]        # 90c <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x6c> 908: R_X86_64_PC32  .L.str.15-0x4
 90c:   48 89 85 e8 fe ff ff    mov    QWORD PTR [rbp-0x118],rax
 913:   e9 00 00 00 00          jmp    918 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x78>
 918:   48 8b 85 e8 fe ff ff    mov    rax,QWORD PTR [rbp-0x118]
 91f:   48 89 45 d0             mov    QWORD PTR [rbp-0x30],rax
    const char *function = context.function ? context.function : "";
 923:   48 8b 85 58 ff ff ff    mov    rax,QWORD PTR [rbp-0xa8]
 92a:   48 83 78 10 00          cmp    QWORD PTR [rax+0x10],0x0
 92f:   0f 84 17 00 00 00       je     94c <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0xac>
 935:   48 8b 85 58 ff ff ff    mov    rax,QWORD PTR [rbp-0xa8]
 93c:   48 8b 40 10             mov    rax,QWORD PTR [rax+0x10]
 940:   48 89 85 e0 fe ff ff    mov    QWORD PTR [rbp-0x120],rax
 947:   e9 13 00 00 00          jmp    95f <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0xbf>
 94c:   48 8d 05 00 00 00 00    lea    rax,[rip+0x0]        # 953 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0xb3> 94f: R_X86_64_PC32  .L.str.15-0x4
 953:   48 89 85 e0 fe ff ff    mov    QWORD PTR [rbp-0x120],rax
 95a:   e9 00 00 00 00          jmp    95f <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0xbf>
 95f:   48 8b 85 e0 fe ff ff    mov    rax,QWORD PTR [rbp-0x120]
 966:   48 89 45 c8             mov    QWORD PTR [rbp-0x38],rax
      msg.endsWith(QStringLiteral("Both point size and pixel size set. Using pixel size.")))
 96a:   48 8b 85 50 ff ff ff    mov    rax,QWORD PTR [rbp-0xb0]
 971:   48 89 85 c8 fe ff ff    mov    QWORD PTR [rbp-0x138],rax
 978:   48 8d 7d c0             lea    rdi,[rbp-0x40]
 97c:   48 89 bd d0 fe ff ff    mov    QWORD PTR [rbp-0x130],rdi
 983:   48 8d 75 b8             lea    rsi,[rbp-0x48]
 987:   e8 54 05 00 00          call   ee0 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)::$_0::operator()() const>
 98c:   48 8b bd c8 fe ff ff    mov    rdi,QWORD PTR [rbp-0x138]
 993:   48 8b b5 d0 fe ff ff    mov    rsi,QWORD PTR [rbp-0x130]
 99a:   ba 01 00 00 00          mov    edx,0x1
 99f:   e8 00 00 00 00          call   9a4 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x104>   9a0: R_X86_64_PLT32 QString::endsWith(QString const&, Qt::CaseSensitivity) const-0x4
 9a4:   88 85 df fe ff ff       mov    BYTE PTR [rbp-0x121],al
 9aa:   e9 00 00 00 00          jmp    9af <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x10f>
 9af:   48 8d 7d c0             lea    rdi,[rbp-0x40]
 9b3:   e8 00 00 00 00          call   9b8 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x118>   9b4: R_X86_64_PLT32 QString::~QString()-0x4
 9b8:   8a 85 df fe ff ff       mov    al,BYTE PTR [rbp-0x121]
 9be:   a8 01                   test   al,0x1
 9c0:   0f 85 05 00 00 00       jne    9cb <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x12b>
 9c6:   e9 2f 00 00 00          jmp    9fa <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x15a>
 9cb:   c7 85 40 ff ff ff 01 00 00 00   mov    DWORD PTR [rbp-0xc0],0x1
        return;
 9d5:   e9 cb 03 00 00          jmp    da5 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x505>
 9da:   48 89 c1                mov    rcx,rax
}
 9dd:   89 d0                   mov    eax,edx
 9df:   48 89 8d 48 ff ff ff    mov    QWORD PTR [rbp-0xb8],rcx
 9e6:   89 85 44 ff ff ff       mov    DWORD PTR [rbp-0xbc],eax
      msg.endsWith(QStringLiteral("Both point size and pixel size set. Using pixel size.")))
 9ec:   48 8d 7d c0             lea    rdi,[rbp-0x40]
 9f0:   e8 00 00 00 00          call   9f5 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x155>   9f1: R_X86_64_PLT32 QString::~QString()-0x4
 9f5:   e9 d3 03 00 00          jmp    dcd <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x52d>
    switch (type) {
 9fa:   8b 85 64 ff ff ff       mov    eax,DWORD PTR [rbp-0x9c]
 a00:   48 89 85 c0 fe ff ff    mov    QWORD PTR [rbp-0x140],rax
 a07:   48 83 e8 04             sub    rax,0x4
 a0b:   0f 87 8a 03 00 00       ja     d9b <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4fb>
 a11:   48 8b 85 c0 fe ff ff    mov    rax,QWORD PTR [rbp-0x140]
 a18:   48 8d 0d 00 00 00 00    lea    rcx,[rip+0x0]        # a1f <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x17f>    a1b: R_X86_64_PC32  .rodata-0x4
 a1f:   48 63 04 81             movsxd rax,DWORD PTR [rcx+rax*4]
 a23:   48 01 c8                add    rax,rcx
 a26:   ff e0                   jmp    rax
 a28:   48 8d 7d a8             lea    rdi,[rbp-0x58]
 a2c:   48 89 bd b8 fe ff ff    mov    QWORD PTR [rbp-0x148],rdi
        nhlog::qml()->debug("{} ({}:{}, {})", localMsg, file, context.line, function);
 a33:   e8 00 00 00 00          call   a38 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x198>   a34: R_X86_64_PLT32 nhlog::qml()-0x4
 a38:   48 8b bd b8 fe ff ff    mov    rdi,QWORD PTR [rbp-0x148]
 a3f:   e8 00 00 00 00          call   a44 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x1a4>   a40: R_X86_64_PLT32 std::__shared_ptr_access<spdlog::logger, (__gnu_cxx::_Lock_policy)2, false, false>::operator->() const-0x4
 a44:   48 89 c7                mov    rdi,rax
 a47:   48 8d 05 00 00 00 00    lea    rax,[rip+0x0]        # a4e <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x1ae>    a4a: R_X86_64_PC32  .L.str.16-0x4
 a4e:   48 89 85 30 ff ff ff    mov    QWORD PTR [rbp-0xd0],rax
 a55:   48 c7 85 38 ff ff ff 0e 00 00 00    mov    QWORD PTR [rbp-0xc8],0xe
 a60:   4c 8b 8d 58 ff ff ff    mov    r9,QWORD PTR [rbp-0xa8]
 a67:   49 83 c1 04             add    r9,0x4
 a6b:   48 8b b5 30 ff ff ff    mov    rsi,QWORD PTR [rbp-0xd0]
 a72:   48 8b 95 38 ff ff ff    mov    rdx,QWORD PTR [rbp-0xc8]
 a79:   48 89 e0                mov    rax,rsp
 a7c:   48 8d 4d c8             lea    rcx,[rbp-0x38]
 a80:   48 89 08                mov    QWORD PTR [rax],rcx
 a83:   48 8d 4d d8             lea    rcx,[rbp-0x28]
 a87:   4c 8d 45 d0             lea    r8,[rbp-0x30]
 a8b:   e8 00 00 00 00          call   a90 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x1f0>   a8c: R_X86_64_PLT32 void spdlog::logger::debug<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&>(fmt::v9::basic_format_string<char, fmt::v9::type_identity<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>::type, fmt::v9::type_identity<char const*&>::type, fmt::v9::type_identity<int const&>::type, fmt::v9::type_identity<char const*&>::type>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&)-0x4
 a90:   e9 00 00 00 00          jmp    a95 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x1f5>
 a95:   c7 85 40 ff ff ff 02 00 00 00   mov    DWORD PTR [rbp-0xc0],0x2
        break;
 a9f:   e9 db 02 00 00          jmp    d7f <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4df>
 aa4:   48 89 c1                mov    rcx,rax
}
 aa7:   89 d0                   mov    eax,edx
 aa9:   48 89 8d 48 ff ff ff    mov    QWORD PTR [rbp-0xb8],rcx
 ab0:   89 85 44 ff ff ff       mov    DWORD PTR [rbp-0xbc],eax
 ab6:   e9 d2 02 00 00          jmp    d8d <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4ed>
 abb:   48 8d 7d 98             lea    rdi,[rbp-0x68]
 abf:   48 89 bd b0 fe ff ff    mov    QWORD PTR [rbp-0x150],rdi
        nhlog::qml()->info("{} ({}:{}, {})", localMsg, file, context.line, function);
 ac6:   e8 00 00 00 00          call   acb <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x22b>   ac7: R_X86_64_PLT32 nhlog::qml()-0x4
 acb:   48 8b bd b0 fe ff ff    mov    rdi,QWORD PTR [rbp-0x150]
 ad2:   e8 00 00 00 00          call   ad7 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x237>   ad3: R_X86_64_PLT32 std::__shared_ptr_access<spdlog::logger, (__gnu_cxx::_Lock_policy)2, false, false>::operator->() const-0x4
 ad7:   48 89 c7                mov    rdi,rax
 ada:   48 8d 05 00 00 00 00    lea    rax,[rip+0x0]        # ae1 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x241>    add: R_X86_64_PC32  .L.str.16-0x4
 ae1:   48 89 85 20 ff ff ff    mov    QWORD PTR [rbp-0xe0],rax
 ae8:   48 c7 85 28 ff ff ff 0e 00 00 00    mov    QWORD PTR [rbp-0xd8],0xe
 af3:   4c 8b 8d 58 ff ff ff    mov    r9,QWORD PTR [rbp-0xa8]
 afa:   49 83 c1 04             add    r9,0x4
 afe:   48 8b b5 20 ff ff ff    mov    rsi,QWORD PTR [rbp-0xe0]
 b05:   48 8b 95 28 ff ff ff    mov    rdx,QWORD PTR [rbp-0xd8]
 b0c:   48 89 e0                mov    rax,rsp
 b0f:   48 8d 4d c8             lea    rcx,[rbp-0x38]
 b13:   48 89 08                mov    QWORD PTR [rax],rcx
 b16:   48 8d 4d d8             lea    rcx,[rbp-0x28]
 b1a:   4c 8d 45 d0             lea    r8,[rbp-0x30]
 b1e:   e8 00 00 00 00          call   b23 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x283>   b1f: R_X86_64_PLT32 void spdlog::logger::info<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&>(fmt::v9::basic_format_string<char, fmt::v9::type_identity<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>::type, fmt::v9::type_identity<char const*&>::type, fmt::v9::type_identity<int const&>::type, fmt::v9::type_identity<char const*&>::type>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&)-0x4
 b23:   e9 00 00 00 00          jmp    b28 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x288>
 b28:   c7 85 40 ff ff ff 02 00 00 00   mov    DWORD PTR [rbp-0xc0],0x2
        break;
 b32:   e9 2c 02 00 00          jmp    d63 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4c3>
 b37:   48 89 c1                mov    rcx,rax
}
 b3a:   89 d0                   mov    eax,edx
 b3c:   48 89 8d 48 ff ff ff    mov    QWORD PTR [rbp-0xb8],rcx
 b43:   89 85 44 ff ff ff       mov    DWORD PTR [rbp-0xbc],eax
 b49:   e9 23 02 00 00          jmp    d71 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4d1>
 b4e:   48 8d 7d 88             lea    rdi,[rbp-0x78]
 b52:   48 89 bd a8 fe ff ff    mov    QWORD PTR [rbp-0x158],rdi
        nhlog::qml()->warn("{} ({}:{}, {})", localMsg, file, context.line, function);
 b59:   e8 00 00 00 00          call   b5e <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x2be>   b5a: R_X86_64_PLT32 nhlog::qml()-0x4
 b5e:   48 8b bd a8 fe ff ff    mov    rdi,QWORD PTR [rbp-0x158]
 b65:   e8 00 00 00 00          call   b6a <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x2ca>   b66: R_X86_64_PLT32 std::__shared_ptr_access<spdlog::logger, (__gnu_cxx::_Lock_policy)2, false, false>::operator->() const-0x4
 b6a:   48 89 c7                mov    rdi,rax
 b6d:   48 8d 05 00 00 00 00    lea    rax,[rip+0x0]        # b74 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x2d4>    b70: R_X86_64_PC32  .L.str.16-0x4
 b74:   48 89 85 10 ff ff ff    mov    QWORD PTR [rbp-0xf0],rax
 b7b:   48 c7 85 18 ff ff ff 0e 00 00 00    mov    QWORD PTR [rbp-0xe8],0xe
 b86:   4c 8b 8d 58 ff ff ff    mov    r9,QWORD PTR [rbp-0xa8]
 b8d:   49 83 c1 04             add    r9,0x4
 b91:   48 8b b5 10 ff ff ff    mov    rsi,QWORD PTR [rbp-0xf0]
 b98:   48 8b 95 18 ff ff ff    mov    rdx,QWORD PTR [rbp-0xe8]
 b9f:   48 89 e0                mov    rax,rsp
 ba2:   48 8d 4d c8             lea    rcx,[rbp-0x38]
 ba6:   48 89 08                mov    QWORD PTR [rax],rcx
 ba9:   48 8d 4d d8             lea    rcx,[rbp-0x28]
 bad:   4c 8d 45 d0             lea    r8,[rbp-0x30]
 bb1:   e8 00 00 00 00          call   bb6 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x316>   bb2: R_X86_64_PLT32 void spdlog::logger::warn<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&>(fmt::v9::basic_format_string<char, fmt::v9::type_identity<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>::type, fmt::v9::type_identity<char const*&>::type, fmt::v9::type_identity<int const&>::type, fmt::v9::type_identity<char const*&>::type>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&)-0x4
 bb6:   e9 00 00 00 00          jmp    bbb <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x31b>
 bbb:   c7 85 40 ff ff ff 02 00 00 00   mov    DWORD PTR [rbp-0xc0],0x2
        break;
 bc5:   e9 7d 01 00 00          jmp    d47 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4a7>
 bca:   48 89 c1                mov    rcx,rax
}
 bcd:   89 d0                   mov    eax,edx
 bcf:   48 89 8d 48 ff ff ff    mov    QWORD PTR [rbp-0xb8],rcx
 bd6:   89 85 44 ff ff ff       mov    DWORD PTR [rbp-0xbc],eax
 bdc:   e9 74 01 00 00          jmp    d55 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4b5>
 be1:   48 8d bd 78 ff ff ff    lea    rdi,[rbp-0x88]
 be8:   48 89 bd a0 fe ff ff    mov    QWORD PTR [rbp-0x160],rdi
        nhlog::qml()->critical("{} ({}:{}, {})", localMsg, file, context.line, function);
 bef:   e8 00 00 00 00          call   bf4 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x354>   bf0: R_X86_64_PLT32 nhlog::qml()-0x4
 bf4:   48 8b bd a0 fe ff ff    mov    rdi,QWORD PTR [rbp-0x160]
 bfb:   e8 00 00 00 00          call   c00 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x360>   bfc: R_X86_64_PLT32 std::__shared_ptr_access<spdlog::logger, (__gnu_cxx::_Lock_policy)2, false, false>::operator->() const-0x4
 c00:   48 89 c7                mov    rdi,rax
 c03:   48 8d 05 00 00 00 00    lea    rax,[rip+0x0]        # c0a <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x36a>    c06: R_X86_64_PC32  .L.str.16-0x4
 c0a:   48 89 85 00 ff ff ff    mov    QWORD PTR [rbp-0x100],rax
 c11:   48 c7 85 08 ff ff ff 0e 00 00 00    mov    QWORD PTR [rbp-0xf8],0xe
 c1c:   4c 8b 8d 58 ff ff ff    mov    r9,QWORD PTR [rbp-0xa8]
 c23:   49 83 c1 04             add    r9,0x4
 c27:   48 8b b5 00 ff ff ff    mov    rsi,QWORD PTR [rbp-0x100]
 c2e:   48 8b 95 08 ff ff ff    mov    rdx,QWORD PTR [rbp-0xf8]
 c35:   48 89 e0                mov    rax,rsp
 c38:   48 8d 4d c8             lea    rcx,[rbp-0x38]
 c3c:   48 89 08                mov    QWORD PTR [rax],rcx
 c3f:   48 8d 4d d8             lea    rcx,[rbp-0x28]
 c43:   4c 8d 45 d0             lea    r8,[rbp-0x30]
 c47:   e8 00 00 00 00          call   c4c <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x3ac>   c48: R_X86_64_PLT32 void spdlog::logger::critical<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&>(fmt::v9::basic_format_string<char, fmt::v9::type_identity<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>::type, fmt::v9::type_identity<char const*&>::type, fmt::v9::type_identity<int const&>::type, fmt::v9::type_identity<char const*&>::type>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&)-0x4
 c4c:   e9 00 00 00 00          jmp    c51 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x3b1>
 c51:   c7 85 40 ff ff ff 02 00 00 00   mov    DWORD PTR [rbp-0xc0],0x2
        break;
 c5b:   e9 c5 00 00 00          jmp    d25 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x485>
 c60:   48 89 c1                mov    rcx,rax
}
 c63:   89 d0                   mov    eax,edx
 c65:   48 89 8d 48 ff ff ff    mov    QWORD PTR [rbp-0xb8],rcx
 c6c:   89 85 44 ff ff ff       mov    DWORD PTR [rbp-0xbc],eax
 c72:   e9 bf 00 00 00          jmp    d36 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x496>
 c77:   48 8d bd 68 ff ff ff    lea    rdi,[rbp-0x98]
 c7e:   48 89 bd 98 fe ff ff    mov    QWORD PTR [rbp-0x168],rdi
        nhlog::qml()->critical("{} ({}:{}, {})", localMsg, file, context.line, function);
 c85:   e8 00 00 00 00          call   c8a <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x3ea>   c86: R_X86_64_PLT32 nhlog::qml()-0x4
 c8a:   48 8b bd 98 fe ff ff    mov    rdi,QWORD PTR [rbp-0x168]
 c91:   e8 00 00 00 00          call   c96 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x3f6>   c92: R_X86_64_PLT32 std::__shared_ptr_access<spdlog::logger, (__gnu_cxx::_Lock_policy)2, false, false>::operator->() const-0x4
 c96:   48 89 c7                mov    rdi,rax
 c99:   48 8d 05 00 00 00 00    lea    rax,[rip+0x0]        # ca0 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x400>    c9c: R_X86_64_PC32  .L.str.16-0x4
 ca0:   48 89 85 f0 fe ff ff    mov    QWORD PTR [rbp-0x110],rax
 ca7:   48 c7 85 f8 fe ff ff 0e 00 00 00    mov    QWORD PTR [rbp-0x108],0xe
 cb2:   4c 8b 8d 58 ff ff ff    mov    r9,QWORD PTR [rbp-0xa8]
 cb9:   49 83 c1 04             add    r9,0x4
 cbd:   48 8b b5 f0 fe ff ff    mov    rsi,QWORD PTR [rbp-0x110]
 cc4:   48 8b 95 f8 fe ff ff    mov    rdx,QWORD PTR [rbp-0x108]
 ccb:   48 89 e0                mov    rax,rsp
 cce:   48 8d 4d c8             lea    rcx,[rbp-0x38]
 cd2:   48 89 08                mov    QWORD PTR [rax],rcx
 cd5:   48 8d 4d d8             lea    rcx,[rbp-0x28]
 cd9:   4c 8d 45 d0             lea    r8,[rbp-0x30]
 cdd:   e8 00 00 00 00          call   ce2 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x442>   cde: R_X86_64_PLT32 void spdlog::logger::critical<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&>(fmt::v9::basic_format_string<char, fmt::v9::type_identity<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&>::type, fmt::v9::type_identity<char const*&>::type, fmt::v9::type_identity<int const&>::type, fmt::v9::type_identity<char const*&>::type>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char const*&, int const&, char const*&)-0x4
 ce2:   e9 00 00 00 00          jmp    ce7 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x447>
 ce7:   c7 85 40 ff ff ff 02 00 00 00   mov    DWORD PTR [rbp-0xc0],0x2
    }
 cf1:   48 8d bd 68 ff ff ff    lea    rdi,[rbp-0x98]
 cf8:   e8 00 00 00 00          call   cfd <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x45d>   cf9: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 cfd:   e9 23 00 00 00          jmp    d25 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x485>
 d02:   48 89 c1                mov    rcx,rax
}
 d05:   89 d0                   mov    eax,edx
 d07:   48 89 8d 48 ff ff ff    mov    QWORD PTR [rbp-0xb8],rcx
 d0e:   89 85 44 ff ff ff       mov    DWORD PTR [rbp-0xbc],eax
    }
 d14:   48 8d bd 68 ff ff ff    lea    rdi,[rbp-0x98]
 d1b:   e8 00 00 00 00          call   d20 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x480>   d1c: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 d20:   e9 11 00 00 00          jmp    d36 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x496>
 d25:   48 8d bd 78 ff ff ff    lea    rdi,[rbp-0x88]
 d2c:   e8 00 00 00 00          call   d31 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x491>   d2d: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 d31:   e9 11 00 00 00          jmp    d47 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4a7>
 d36:   48 8d bd 78 ff ff ff    lea    rdi,[rbp-0x88]
 d3d:   e8 00 00 00 00          call   d42 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4a2>   d3e: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 d42:   e9 0e 00 00 00          jmp    d55 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4b5>
 d47:   48 8d 7d 88             lea    rdi,[rbp-0x78]
 d4b:   e8 00 00 00 00          call   d50 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4b0>   d4c: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 d50:   e9 0e 00 00 00          jmp    d63 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4c3>
 d55:   48 8d 7d 88             lea    rdi,[rbp-0x78]
 d59:   e8 00 00 00 00          call   d5e <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4be>   d5a: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 d5e:   e9 0e 00 00 00          jmp    d71 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4d1>
 d63:   48 8d 7d 98             lea    rdi,[rbp-0x68]
 d67:   e8 00 00 00 00          call   d6c <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4cc>   d68: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 d6c:   e9 0e 00 00 00          jmp    d7f <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4df>
 d71:   48 8d 7d 98             lea    rdi,[rbp-0x68]
 d75:   e8 00 00 00 00          call   d7a <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4da>   d76: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 d7a:   e9 0e 00 00 00          jmp    d8d <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4ed>
 d7f:   48 8d 7d a8             lea    rdi,[rbp-0x58]
 d83:   e8 00 00 00 00          call   d88 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4e8>   d84: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 d88:   e9 0e 00 00 00          jmp    d9b <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4fb>
 d8d:   48 8d 7d a8             lea    rdi,[rbp-0x58]
 d91:   e8 00 00 00 00          call   d96 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x4f6>   d92: R_X86_64_PLT32 std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
 d96:   e9 32 00 00 00          jmp    dcd <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x52d>
}
 d9b:   c7 85 40 ff ff ff 00 00 00 00   mov    DWORD PTR [rbp-0xc0],0x0
 da5:   48 8d 7d d8             lea    rdi,[rbp-0x28]
 da9:   e8 00 00 00 00          call   dae <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x50e>   daa: R_X86_64_PLT32 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()-0x4
 dae:   64 48 8b 04 25 28 00 00 00  mov    rax,QWORD PTR fs:0x28
 db7:   48 8b 4d f8             mov    rcx,QWORD PTR [rbp-0x8]
 dbb:   48 39 c8                cmp    rax,rcx
 dbe:   0f 85 1e 00 00 00       jne    de2 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x542>
 dc4:   48 81 c4 70 01 00 00    add    rsp,0x170
 dcb:   5d                      pop    rbp
 dcc:   c3                      ret
 dcd:   48 8d 7d d8             lea    rdi,[rbp-0x28]
 dd1:   e8 00 00 00 00          call   dd6 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x536>   dd2: R_X86_64_PLT32 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()-0x4
 dd6:   48 8b bd 48 ff ff ff    mov    rdi,QWORD PTR [rbp-0xb8]
 ddd:   e8 00 00 00 00          call   de2 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x542>   dde: R_X86_64_PLT32 _Unwind_Resume-0x4
 de2:   e8 00 00 00 00          call   de7 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x547>   de3: R_X86_64_PLT32 __stack_chk_fail-0x4
 de7:   66 0f 1f 84 00 00 00 00 00  nop    WORD PTR [rax+rax*1+0x0]

To me this looks like multiple destructor calls are generated for the temporary shared_ptr. You can "fix" that by getting rid of the qml() call and accessing the shared_ptr directly or by putting the logging calls inside a scope. From my understanding, this happens because of the consteval constructor for the libfmt arguments. Without the libfmt calls, the destructors seem to happen in the normal places. Specifically that part of the assembly then looks like this:

    switch (type) {
 975:   8b 85 74 ff ff ff       mov    eax,DWORD PTR [rbp-0x8c]
 97b:   48 89 85 30 ff ff ff    mov    QWORD PTR [rbp-0xd0],rax
 982:   48 83 e8 04             sub    rax,0x4
 986:   0f 87 8b 00 00 00       ja     a17 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x177>
 98c:   48 8b 85 30 ff ff ff    mov    rax,QWORD PTR [rbp-0xd0]
 993:   48 8d 0d 00 00 00 00    lea    rcx,[rip+0x0]        # 99a <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0xfa> 996: R_X86_64_PC32      .rodata-0x4
 99a:   48 63 04 81             movsxd rax,DWORD PTR [rcx+rax*4]
 99e:   48 01 c8                add    rax,rcx
 9a1:   ff e0                   jmp    rax
        nhlog::qml();
 9a3:   48 8d 7d b8             lea    rdi,[rbp-0x48]
 9a7:   e8 00 00 00 00          call   9ac <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x10c>       9a8: R_X86_64_PLT32     nhlog::qml()-0x4
 9ac:   48 8d 7d b8             lea    rdi,[rbp-0x48]
 9b0:   e8 00 00 00 00          call   9b5 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x115>       9b1: R_X86_64_PLT32     std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
        break;
 9b5:   e9 5d 00 00 00          jmp    a17 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x177>
        nhlog::qml();
 9ba:   48 8d 7d a8             lea    rdi,[rbp-0x58]
 9be:   e8 00 00 00 00          call   9c3 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x123>       9bf: R_X86_64_PLT32     nhlog::qml()-0x4
 9c3:   48 8d 7d a8             lea    rdi,[rbp-0x58]
 9c7:   e8 00 00 00 00          call   9cc <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x12c>       9c8: R_X86_64_PLT32     std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
        break;
 9cc:   e9 46 00 00 00          jmp    a17 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x177>
        nhlog::qml();
 9d1:   48 8d 7d 98             lea    rdi,[rbp-0x68]
 9d5:   e8 00 00 00 00          call   9da <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x13a>       9d6: R_X86_64_PLT32     nhlog::qml()-0x4
 9da:   48 8d 7d 98             lea    rdi,[rbp-0x68]
 9de:   e8 00 00 00 00          call   9e3 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x143>       9df: R_X86_64_PLT32     std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
        break;
 9e3:   e9 2f 00 00 00          jmp    a17 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x177>
        nhlog::qml();
 9e8:   48 8d 7d 88             lea    rdi,[rbp-0x78]
 9ec:   e8 00 00 00 00          call   9f1 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x151>       9ed: R_X86_64_PLT32     nhlog::qml()-0x4
 9f1:   48 8d 7d 88             lea    rdi,[rbp-0x78]
 9f5:   e8 00 00 00 00          call   9fa <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x15a>       9f6: R_X86_64_PLT32     std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
        break;
 9fa:   e9 18 00 00 00          jmp    a17 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x177>
        nhlog::qml();
 9ff:   48 8d bd 78 ff ff ff    lea    rdi,[rbp-0x88]
 a06:   e8 00 00 00 00          call   a0b <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x16b>       a07: R_X86_64_PLT32     nhlog::qml()-0x4
 a0b:   48 8d bd 78 ff ff ff    lea    rdi,[rbp-0x88]
 a12:   e8 00 00 00 00          call   a17 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x177>       a13: R_X86_64_PLT32     std::shared_ptr<spdlog::logger>::~shared_ptr()-0x4
}
 a17:   c7 85 50 ff ff ff 00 00 00 00   mov    DWORD PTR [rbp-0xb0],0x0
 a21:   48 8d 7d d8             lea    rdi,[rbp-0x28]
 a25:   e8 00 00 00 00          call   a2a <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x18a>       a26: R_X86_64_PLT32     std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()-0x4
 a2a:   64 48 8b 04 25 28 00 00 00      mov    rax,QWORD PTR fs:0x28
 a33:   48 8b 4d f8             mov    rcx,QWORD PTR [rbp-0x8]
 a37:   48 39 c8                cmp    rax,rcx
 a3a:   0f 85 15 00 00 00       jne    a55 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x1b5>
 a40:   48 81 c4 d0 00 00 00    add    rsp,0xd0
 a47:   5d                      pop    rbp
 a48:   c3                      ret
 a49:   48 8b bd 58 ff ff ff    mov    rdi,QWORD PTR [rbp-0xa8]
 a50:   e8 00 00 00 00          call   a55 <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x1b5>       a51: R_X86_64_PLT32     _Unwind_Resume-0x4
 a55:   e8 00 00 00 00          call   a5a <(anonymous namespace)::qmlMessageHandler(QtMsgType, QMessageLogContext const&, QString const&)+0x1ba>       a56: R_X86_64_PLT32     __stack_chk_fail-0x4
 a5a:   66 0f 1f 44 00 00       nop    WORD PTR [rax+rax*1+0x0]

Here is the Preprocessed source file.

Sorry this is a bit long. If you have any suggestions on how I could simplify this report, I will try that. We are now using this workaround: https://github.com/Nheko-Reborn/nheko/commit/4c34f4bfee284f0065f4b72c5a12649d664acf43 Original issue: https://github.com/Nheko-Reborn/nheko/issues/1292

There is a good chance I am triggering undefined behaviour, however GCC compiles it fine without warnings and I don't see any sanitizer warnings about it apart from the obvious crash from the bad code. I apologize if this is actually an issue with our code.

I tested this in Clang 15.0.7 and 14.0.6 from the Gentoo repos, haven't had a change to test 16 yet. This is with libstdc++, not libc++.

tbaederr commented 1 year ago

Can you paste the compiler command line used?

llvmbot commented 1 year ago

@llvm/issue-subscribers-c-20

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-frontend

deepbluev7 commented 1 year ago

Can you paste the compiler command line used?

Sure, this is the snippet from the compile_commands.json:

  "command": "/usr/lib/llvm/15/bin/clang++ -DFMT_SHARED -DGSTREAMER_AVAILABLE -DNHEKO_DBUS_SYS -DQAPPLICATION_CLASS=QApplication -DQT_CONCURRENT_LIB -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_GUI_LIB -DQT_MULTIMEDIA_LIB -DQT_NETWORK_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_QUICKCONTROLS2_LIB -DQT_QUICKWIDGETS_LIB -DQT_QUICK_LIB -DQT_SVG_LIB -DQT_WIDGETS_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DSPDLOG_SHARED_LIB -DXCB_AVAILABLE -Dnheko_EXPORTS -I/home/nicolas/Dokumente/devel/open-source/nheko/build-clang -I/home/nicolas/Dokumente/devel/open-source/nheko -I/home/nicolas/Dokumente/devel/open-source/nheko/build-clang/nheko_autogen/include -I/home/nicolas/Dokumente/devel/open-source/nheko/src -I/home/nicolas/Dokumente/devel/open-source/nheko/includes -I/home/nicolas/Dokumente/devel/open-source/nheko/third_party/blurhash -I/home/nicolas/Dokumente/devel/open-source/nheko/third_party/cpp-httplib-0.5.12 -I/home/nicolas/Dokumente/devel/open-source/nheko/third_party/SingleApplication-3.3.2 -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtDBus -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/mkspecs/linux-g++ -isystem /home/nicolas/Dokumente/devel/open-source/mtxclient/include -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtSvg -isystem /usr/include/qt5/QtConcurrent -isystem /usr/include/qt5/QtMultimedia -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtQml -isystem /usr/include/qt5/QtQuickControls2 -isystem /usr/include/qt5/QtQuick -isystem /usr/include/qt5/QtQmlModels -isystem /usr/include/qt5/QtQuickWidgets -isystem /usr/include/gstreamer-1.0 -isystem /usr/include/glib-2.0 -isystem /usr/lib64/glib-2.0/include -isystem /usr/lib64/libffi/include -isystem /usr/include/orc-0.4 -isystem /usr/include/libmount -isystem /usr/include/blkid -ftime-trace \t\t-Wall \t\t-Wextra \t\t-pedantic \t\t-fsized-deallocation \t\t-fdiagnostics-color=always \t\t-Wunreachable-code \t\t-Wno-attributes -Wshadow -g -fPIE -Werror -fPIC -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -pthread -std=gnu++20 -Winvalid-pch -Xclang -include-pch -Xclang /home/nicolas/Dokumente/devel/open-source/nheko/build-clang/CMakeFiles/nheko.dir/cmake_pch.hxx.pch -Xclang -include -Xclang /home/nicolas/Dokumente/devel/open-source/nheko/build-clang/CMakeFiles/nheko.dir/cmake_pch.hxx -o CMakeFiles/nheko.dir/src/Logging.cpp.o -c /home/nicolas/Dokumente/devel/open-source/nheko/src/Logging.cpp",
  "file": "/home/nicolas/Dokumente/devel/open-source/nheko/src/Logging.cpp"