[llvm-bugs] [Bug 50146] New: std::call_once always segfaults on MinGW (regression 11->12)

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 27 12:17:44 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50146

            Bug ID: 50146
           Summary: std::call_once always segfaults on MinGW (regression
                    11->12)
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: blckcat at inbox.ru
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk

Any use of `std::call_once` on MinGW causes a segfault. It used to work in
Clang 11, but broke in 12.

Minimal example:
    #include <iostream>
    #include <mutex>

    int main()
    {
        std::once_flag flag;
        std::call_once(flag, []{std::cout << "Once!\n";});
    }

The clang version is: Ubuntu clang version
12.0.1-++20210423082613+072c90a863aa-1~exp1~20210423063319.76

The flags I use: clang++-12 --version --target=x86_64-w64-mingw32
--sysroot=/mingw64 -pthread -femulated-tls

The libstdc++ comes from MSYS2 GCC 10.2.0 (rev 10).

Here's what GDB says if I add `-g`:
    Program received signal SIGSEGV, Segmentation fault.
    0x00000001e014dc4a in ?? () from
Z:\home\holyblackcat\Sandbox\2\libgcc_s_seh-1.dll
    (gdb) bt
    #0  0x00000001e014dc4a in ?? () from
Z:\home\holyblackcat\Sandbox\2\libgcc_s_seh-1.dll
    #1  0x00000000004015f3 in std::call_once<main::$_0> (__once=..., __f=...)
at /mingw64/include/c++/10.2.0/mutex:721
    #2  0x00000000004015b5 in main () at 1.cpp:8
    (gdb) f 1
    #1  0x00000000004015f3 in std::call_once<main::$_0> (__once=..., __f=...)
at /mingw64/include/c++/10.2.0/mutex:721
    721           __once_callable = std::__addressof(__callable);
    (gdb) list
    716           auto __callable = [&] {
    717               std::__invoke(std::forward<_Callable>(__f),
    718                             std::forward<_Args>(__args)...);
    719           };
    720     #ifdef _GLIBCXX_HAVE_TLS
    721           __once_callable = std::__addressof(__callable);
    722           __once_call = []{
(*(decltype(__callable)*)__once_callable)(); };
    723     #else
    724           unique_lock<mutex> __functor_lock(__get_once_mutex());
    725           __once_functor = __callable;

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210427/0094e484/attachment.html>


More information about the llvm-bugs mailing list