Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

mingw32:clang++ compile crash when use -O2 : around allocate heap memory? #28492

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR28493
Status NEW
Importance P normal
Reported by yume-wikijp@live.jp
Reported on 2016-07-10 22:28:37 -0700
Last modified on 2016-09-17 04:36:19 -0700
Version 3.8
Hardware PC Windows NT
CC eric@efcs.ca, llvm-bugs@lists.llvm.org, mclow.lists@gmail.com, vit9696@avp.su
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
I'm using msys2 mingw32 clang++.

$ clang++ sample.cpp -v -o sample.out -O2 -Wall -Wextra -std=c++11
clang version 3.8.0 (tags/RELEASE_380/final)
Target: i686-w64-windows-gnu
Thread model: posix
InstalledDir: D:\msys64\mingw32\bin
 "D:\\msys64\\mingw32\\bin\\clang++.exe" -cc1 -triple i686-w64-windows-gnu -emit-obj -disable-free -disable-llvm-verifier -main-file-name sample.cpp -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -momit-leaf-frame-pointer -v -dwarf-column-info -debugger-tuning=gdb -resource-dir "D:\\msys64\\mingw32\\bin\\..\\lib\\clang\\3.8.0" -internal-isystem "D:\\msys64\\mingw32\\i686-w64-mingw32\\include\\c++" -internal-isystem "D:\\msys64\\mingw32\\i686-w64-mingw32\\include\\c++\\i686-w64-mingw32" -internal-isystem "D:\\msys64\\mingw32\\i686-w64-mingw32\\include\\c++\\backward" -internal-isystem "D:\\msys64\\mingw32\\i686-w64-mingw32\\include\\c++\\5.4.0" -internal-isystem "D:\\msys64\\mingw32\\i686-w64-mingw32\\include\\c++\\5.4.0\\i686-w64-mingw32" -internal-isystem "D:\\msys64\\mingw32\\i686-w64-mingw32\\include\\c++\\5.4.0\\backward" -internal-isystem "D:\\msys64\\mingw32\\include\\c++\\5.4.0" -internal-isystem "D:\\msys64\\mingw32\\include\\c++\\5.4.0\\i686-w64-mingw32" -internal-isystem "D:\\msys64\\mingw32\\include\\c++\\5.4.0\\backward" -internal-isystem "D:\\msys64\\mingw32\\lib\\gcc\\i686-w64-mingw32\\5.4.0\\include\\c++" -internal-isystem "D:\\msys64\\mingw32\\lib\\gcc\\i686-w64-mingw32\\5.4.0\\include\\c++\\i686-w64-mingw32" -internal-isystem "D:\\msys64\\mingw32\\lib\\gcc\\i686-w64-mingw32\\5.4.0\\include\\c++\\backward" -internal-isystem "D:\\msys64\\mingw32\\bin\\..\\lib\\clang\\3.8.0\\include" -internal-isystem "D:\\msys64\\mingw32\\lib\\gcc\\i686-w64-mingw32\\5.4.0\\include" -internal-isystem "D:\\msys64\\mingw32\\i686-w64-mingw32/sys-root/mingw/include" -internal-isystem "D:\\msys64\\mingw32\\lib\\gcc\\i686-w64-mingw32\\5.4.0\\include-fixed" -internal-isystem "D:\\msys64\\mingw32\\i686-w64-mingw32\\include" -internal-isystem "D:\\msys64\\mingw32\\include" -O2 -Wall -Wextra -std=c++11 -fdeprecated-macro -fdebug-compilation-dir "D:\\user\\documents\\git\\string_split\\sample" -ferror-limit 19 -fmessage-length 203 -fno-use-cxa-atexit -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -o "D:\\msys64\\tmp\\sample-6463c7.o" -x c++ sample.cpp
clang -cc1 version 3.8.0 based upon LLVM 3.8.0 default target i686-w64-windows-
gnu
ignoring nonexistent directory "D:\msys64\mingw32\i686-w64-mingw32\include\c++"
ignoring nonexistent directory "D:\msys64\mingw32\i686-w64-
mingw32\include\c++\i686-w64-mingw32"
ignoring nonexistent directory "D:\msys64\mingw32\i686-w64-
mingw32\include\c++\backward"
ignoring nonexistent directory "D:\msys64\mingw32\i686-w64-
mingw32\include\c++\5.4.0"
ignoring nonexistent directory "D:\msys64\mingw32\i686-w64-
mingw32\include\c++\5.4.0\i686-w64-mingw32"
ignoring nonexistent directory "D:\msys64\mingw32\i686-w64-
mingw32\include\c++\5.4.0\backward"
ignoring nonexistent directory "D:\msys64\mingw32\lib\gcc\i686-w64-
mingw32\5.4.0\include\c++"
ignoring nonexistent directory "D:\msys64\mingw32\lib\gcc\i686-w64-
mingw32\5.4.0\include\c++\i686-w64-mingw32"
ignoring nonexistent directory "D:\msys64\mingw32\lib\gcc\i686-w64-
mingw32\5.4.0\include\c++\backward"
ignoring nonexistent directory "D:\msys64\mingw32\i686-w64-mingw32/sys-
root/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 D:\msys64\mingw32\include\c++\5.4.0
 D:\msys64\mingw32\include\c++\5.4.0\i686-w64-mingw32
 D:\msys64\mingw32\include\c++\5.4.0\backward
 D:\msys64\mingw32\bin\..\lib\clang\3.8.0\include
 D:\msys64\mingw32\lib\gcc\i686-w64-mingw32\5.4.0\include
 D:\msys64\mingw32\lib\gcc\i686-w64-mingw32\5.4.0\include-fixed
 D:\msys64\mingw32\i686-w64-mingw32\include
 D:\msys64\mingw32\include
End of search list.
#0 0x05e6779d
#1 0x0028dfd0
#2 0x00e054a1 (D:\msys64\mingw32\bin\clang++.exe+0xa054a1)
#3 0x779fe40c RtlInitUnicodeString (C:\Windows\SysWOW64\ntdll.dll+0x2e40c)
#4 0x779fe172 RtlAllocateHeap (C:\Windows\SysWOW64\ntdll.dll+0x2e172)
#5 0x779fe40c RtlInitUnicodeString (C:\Windows\SysWOW64\ntdll.dll+0x2e40c)
#6 0x779fe172 RtlAllocateHeap (C:\Windows\SysWOW64\ntdll.dll+0x2e172)
#7 0x761d9d45 malloc (C:\Windows\syswow64\msvcrt.dll+0x9d45)
#8 0x6fef6c7a (D:\msys64\mingw32\bin\libstdc++-6.dll+0xb6c7a)
#9 0x021d0c1d (D:\msys64\mingw32\bin\clang++.exe+0x1dd0c1d)
#10 0x6fef6c7a (D:\msys64\mingw32\bin\libstdc++-6.dll+0xb6c7a)
clang++.exe: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 (tags/RELEASE_380/final)
Target: i686-w64-windows-gnu
Thread model: posix
InstalledDir: D:\msys64\mingw32\bin
clang++.exe: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang++.exe: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++.exe: note: diagnostic msg: D:\msys64\tmp\sample-704744.cpp
clang++.exe: note: diagnostic msg: D:\msys64\tmp\sample-704744.sh
clang++.exe: note: diagnostic msg:

********************

msys2 mingw32 clang++ only fail. msys2 mingw64 clang++ work fine.

sample.cpp is a part of
https://github.com/yumetodo/string_split
this repo(./sample/sample.cpp).

D:\msys64\tmp\sample-704744.sh
http://pastebin.com/MFypKbWK
Quuxplusone commented 8 years ago
sample-704744.cpp
https://gist.github.com/yumetodo/2be9c037e1ef992664493fb457817c1c
Quuxplusone commented 8 years ago

This is not a libc++ bug. Your using libstdc++.

Quuxplusone commented 8 years ago

To Eric Fiselier

Oh...

Where shold I post report?

Quuxplusone commented 8 years ago

I keep rebinning it as clang. That's where it should be.

Quuxplusone commented 8 years ago
Hello,
As it looks the reported issue exactly the same as
https://github.com/Alexpux/MINGW-packages/issues/1669

The minimal samples to trigger a crash are:
struct A {
  char ok;
  void init();
  void method() {
    if (ok) init();
  }
};

static A a;
int main() {
  a.method();
}

or

struct _Hashtable {
  void *_M_buckets;
  void _M_deallocate_buckets();
  ~_Hashtable() {
    if (_M_buckets)
      _M_deallocate_buckets();
  }
} a;

Compiled with:
clang -c -O2 sample.cpp

Verbose output as well as some others details are provided on github. Could you
give it a look please?
Quuxplusone commented 8 years ago
I tried to reproduce it and result is

#0 0x032f103b
#1 0x0303dfc0
#2 0x00e054a1 (D:\msys64\mingw32\bin\clang.exe+0xa054a1)
#3 0x0075788d (D:\msys64\mingw32\bin\clang.exe+0x35788d)
#4 0x0303e53c
#5 0xffffffffffffffff
#6 0xffffffffffffffff
#7 0xffffffffffffffff
#8 0xffffffffffffffff
#9 0xffffffffffffffff
#10 0xffffffffffffffff
#11 0xffffffffffffffff
#12 0xffffffffffffffff
#13 0xffffffffffffffff
#14 0xffffffffffffffff
#15 0xffffffffffffffff
#16 0xffffffffffffffff
#17 0xffffffffffffffff
#18 0xffffffffffffffff
#19 0xffffffffffffffff
#20 0xffffffffffffffff
#21 0x00a4ab6c (D:\msys64\mingw32\bin\clang.exe+0x64ab6c)
#22 0x00a4764d (D:\msys64\mingw32\bin\clang.exe+0x64764d)
#23 0x033084a8
#24 0x02e23cc0 (D:\msys64\mingw32\bin\clang.exe+0x2a23cc0)
clang.exe: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 (tags/RELEASE_380/final)
Target: i686-w64-windows-gnu
Thread model: posix
InstalledDir: D:\msys64\mingw32\bin
clang.exe: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang.exe: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang.exe: note: diagnostic msg: D:\msys64\tmp\bug_test-7cded1.cpp
clang.exe: note: diagnostic msg: D:\msys64\tmp\bug_test-7cded1.sh
clang.exe: note: diagnostic msg:

********************

It looks slightly different. It's seem malloc function work fine.
Quuxplusone commented 8 years ago
https://llvm.org/bugs/show_bug.cgi?id=26900
https://github.com/Alexpux/MINGW-packages/issues/1195

this issue is EXACTLY the same issue, I think.

Watch

https://github.com/yumetodo/string_split/issues/1#issuecomment-247759036