[llvm-bugs] [Bug 47950] New: Compiling fmt on Win64 with -fsanitize=address and -D_DLL crashes with sectionless symbol error

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 22 17:26:46 PDT 2020


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

            Bug ID: 47950
           Summary: Compiling fmt on Win64 with -fsanitize=address and
                    -D_DLL crashes with sectionless symbol error
           Product: new-bugs
           Version: 11.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: nyanpasu64 at tuta.io
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 24094
  --> https://bugs.llvm.org/attachment.cgi?id=24094&action=edit
Minimal reproducing test case, expanded, and bitcode

I'm running Windows 10 x64, and Clang 10 and 11 x64, using headers from MSVC.
When I try building fmt with -fsanitize=address enabled, Clang crashes with an
internal error.

C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -DFMT_LOCALE
-IC:/Users/nyanpasu/code/fmt/include -fsanitize=address -g -Xclang -gcodeview
-O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -std=gnu++14 -MD -MT
CMakeFiles/fmt.dir/src/format.cc.obj -MF CMakeFiles\fmt.dir\src\format.cc.obj.d
-o CMakeFiles/fmt.dir/src/format.cc.obj -c
C:/Users/nyanpasu/code/fmt/src/format.cc
fatal error: error in backend: cannot make section .ASAN$GL associative with
sectionless symbol ?id@?$numpunct at _W@std@@2V0locale at 2@A
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -DFMT_LOCALE
-IC:/Users/nyanpasu/code/fmt/include -fsanitize=address -g -Xclang -gcodeview
-O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -std=gnu++14 -MD -MT
CMakeFiles/fmt.dir/src/format.cc.obj -MF CMakeFiles\fmt.dir\src\format.cc.obj.d
-o CMakeFiles/fmt.dir/src/format.cc.obj -c
C:/Users/nyanpasu/code/fmt/src/format.cc 
1.      <eof> parser at end of file
2.      Code generation
[truncated, see
https://gist.github.com/nyanpasu64/a80e00abf37e0fc1236d6ca3caff766d/raw/3feb42e9f024a10fd0a4e6b4c82269ccaa95d90c/10clang
]


When I run `llc foo.bc`, I get the following:

Declaration may not be in a Comdat!
{ %"class.std::locale::id", [56 x i8] }*
@"?id@?$numpunct at _W@std@@2V0locale at 2@A"
Declaration may not be in a Comdat!
{ %"class.std::locale::id", [56 x i8] }* @"?id@?$numpunct at D@std@@2V0locale at 2@A"
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace.
Stack dump:
0.      Program arguments: llc foo.bc
[truncated, see
https://gist.github.com/nyanpasu64/a80e00abf37e0fc1236d6ca3caff766d/raw/3feb42e9f024a10fd0a4e6b4c82269ccaa95d90c/20llc
]

I get basically the same error when run `bugpoint -run-llc foo.bc` which is
intended to minimize the test case. I haven't had much luck with manually
minimizing it.

## Minimal reproducer (attachment format.cc)

#include <locale>

void grouping_impl() {
  std::use_facet<std::numpunct<char>>(std::locale());
}

Compile with `clang -fsanitize=address -D_DLL -std=c++14 -c format.cc`. There
is no crash if you do not pass in both -fsanitize=address and -D_DLL. And
MSVC's <locale> does not compile in Clang's -std=c++11 mode.

Running with -E expands to the 38,809 line, 1.3 MB abomination (attachment
preprocessed.cpp).

Running with `-emit-llvm -c -o foo.bc` produces attachment foo.bc. Trying to
run `llc foo.bc` (with any relocation model) produces error:

Declaration may not be in a Comdat!
{ %"class.std::locale::id", [56 x i8] }* @"?id@?$numpunct at D@std@@2V0locale at 2@A"
llc.exe: foo.bc: error: input module is broken!

## Versions

OS: Windows 10 x64
LLVM/Clang: both 10.0.0 (old) and 11.0.0 (very recent), using MSVC headers/ABI
MSVC headers: latest v14.27 (Clang uses header C:\Program Files (x86)\Microsoft
Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\include\locale) 
fmt: latest 7.0.3
(https://github.com/fmtlib/fmt/releases/download/7.0.3/fmt-7.0.3.zip) and
earlier versions, but see minimal reproducer

-- 
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/20201023/bd126d15/attachment.html>


More information about the llvm-bugs mailing list