Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Windows X86 Debug build crashes when compiling a simple C program #48066

Closed Quuxplusone closed 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR49097
Status RESOLVED DUPLICATE of bug 46176
Importance P normal
Reported by Mandeep Singh Grang (mgrang@codeaurora.org)
Reported on 2021-02-08 12:13:15 -0800
Last modified on 2021-02-09 13:28:44 -0800
Version trunk
Hardware PC Windows NT
CC blitzrakete@gmail.com, dblaikie@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk, rnk@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
On clang 10 onwards, a Windows X86 Debug build results in a crash when
compiling a simple C program. I am using the following version of MSVC to build
clang:
Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29336 for x86

Git bisect points to this patch as the culprit: https://reviews.llvm.org/D65249

Steps to reproduce the issue:

echo void foo() {} | clang -x c -

1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '-'.
4.      Running pass 'Expand Atomic instructions' on function '@f'
0x6B3CAED0 (0x0B58CD60 0x00000001 0x08BB0C33 0x0B58CDF4), _calloc_base() +
0x7A0 bytes(s)
0x6B3CD9EC (0x0B58CD60 0x00000001 0x00000000 0x00000000), _free_dbg() + 0x7C
bytes(s)
0x6B3CDFC0 (0x0B58CD60 0x0B58CDB4 0x0D5C8858 0x0B58CD74), free() + 0x20 bytes(s)
0x01322E1F (0x0D5C8858 0x0B58CD80 0x03B34EA6 0x0D5C8858),
llvm::SmallVectorImpl<llvm::LLT>::~SmallVectorImpl<llvm::LLT>() + 0x2F
bytes(s), C:\mgrang\checkedc\upgrade\src\llvm\include\llvm\ADT\SmallVector.h,
line 382 + 0x11 byte(s)
0x0145EE80 (0x0D5C8858 0x0B58CD8C 0x03B35099 0x0D5C8850),
llvm::SmallVector<llvm::LLT,4>::~SmallVector<llvm::LLT,4>() + 0x30 bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\include\llvm\ADT\SmallVector.h, line 891 +
0x8 byte(s)
0x03B34EA6 (0x0D5C8850 0x0B58CD98 0x03B37106 0x0D5C8850),
<lambda_543130242edd05ce781a30adb393f226>::~<lambda_543130242edd05ce781a30adb393f226>()
+ 0x16 bytes(s)
0x03B35099 (0x0D5C8850 0x0B58CDA8 0x03B37BC8 0x00000000),
std::_Func_impl_no_alloc<<lambda_543130242edd05ce781a30adb393f226>,bool,llvm::LegalityQuery
const
&>::~_Func_impl_no_alloc<<lambda_543130242edd05ce781a30adb393f226>,bool,llvm::LegalityQuery
const &>() + 0x19 bytes(s)
0x03B37106 (0x00000000 0x0D5C8850 0x0B58CDC4 0x00BB4CA6),
std::_Func_impl_no_alloc<<lambda_543130242edd05ce781a30adb393f226>,bool,llvm::LegalityQuery
const &>::`scalar deleting destructor'() + 0x16 bytes(s)
0x03B37BC8 (0x00000001 0x0B58CE44 0x0D5C8850 0x01CCCCCC),
std::_Func_impl_no_alloc<<lambda_543130242edd05ce781a30adb393f226>,bool,llvm::LegalityQuery
const &>::_Delete_this() + 0x18 bytes(s), C:\Program Files (x86)\Microsoft
Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\functional,
line 964
0x00BB4CA6 (0x0B58CDF4 0x0B58CDDC 0x00BB2AB6 0x0B58CDF4),
std::_Func_class<bool,llvm::LegalityQuery const &>::_Tidy() + 0x66 bytes(s),
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\functional, line 1073
+ 0x38 byte(s)
0x00BB2796 (0x0B58CDF4 0x0B58CDE8 0x00BB0A9D 0xCCCCCCCC),
std::_Func_class<bool,llvm::LegalityQuery const
&>::~_Func_class<bool,llvm::LegalityQuery const &>() + 0x16 bytes(s),
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\functional, line 1000
0x00BB2AB6 (0xCCCCCCCC 0x0B58CE84 0x00BB5166 0x0B58CE44), std::function<bool
__cdecl(llvm::LegalityQuery const &)>::~function<bool
__cdecl(llvm::LegalityQuery const &)>() + 0x16 bytes(s)
0x00BB0A9D (0x0B58CE44 0xC241F56F 0x0B58CE84 0x00BB513F),
llvm::LegalityPredicates::all<std::function<bool __cdecl(llvm::LegalityQuery
const &)> >() + 0x2D bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\include\llvm\CodeGen\GlobalISel\LegalizerInfo.h,
line 198 + 0x22 byte(s)
0x00BB5166 (0x00000000 0x0B58D278 0x0B58D298 0x0B58D29C),
llvm::LegalizeRuleSet::actionForCartesianProduct() + 0x66 bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\include\llvm\CodeGen\GlobalISel\LegalizerInfo.h,
line 489 + 0x4A byte(s)
0x00BB6BD8 (0x0B58D278 0x0B58D298 0x0B58D29C 0x0B58D2A4),
llvm::LegalizeRuleSet::legalForCartesianProduct() + 0x28 bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\include\llvm\CodeGen\GlobalISel\LegalizerInfo.h,
line 566
0x00BA84AE (0x0B58D5EC 0xCCCCCCCC 0xCCCCCCCC 0xCCCCCCCC),
llvm::X86LegalizerInfo::setLegalizerInfo32bit() + 0x8BE bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\Target\X86\X86LegalizerInfo.cpp, line
147 + 0xB9 byte(s)
0x00BA78FC (0x0D57E570 0x0D554528 0x0B58D994 0x00000027),
llvm::X86LegalizerInfo::X86LegalizerInfo() + 0x5C bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\Target\X86\X86LegalizerInfo.cpp, line 63
0x0080C41F (0x0D5546C4 0x0B835CDF 0x00000008 0x0B58D758),
llvm::X86Subtarget::X86Subtarget() + 0x80F bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\Target\X86\X86Subtarget.cpp, line 352 +
0x26 byte(s)
0x007DA28A (0x0B58D664 0x0D5546C4 0x0B58D968 0x0B58D958),
std::make_unique<llvm::X86Subtarget,llvm::Triple const &,llvm::StringRef
&,llvm::StringRef &,llvm::X86TargetMachine const &,llvm::MaybeAlign,unsigned
int &,unsigned int &,0>() + 0xAA bytes(s), C:\Program Files (x86)\Microsoft
Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29333\include\memory, line
2833 + 0x8F byte(s)
0x007D30D5 (0x0B7EF304 0x0B58DB24 0x0B58DA54 0x00000000),
llvm::X86TargetMachine::getSubtargetImpl() + 0x445 bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\Target\X86\X86TargetMachine.cpp, line
308 + 0x49 byte(s)
0x01242CA3 (0x0B7EF304 0x0B58DB60 0x0B58DB6C 0x00000000), `anonymous
namespace'::AtomicExpand::runOnFunction() + 0x63 bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\CodeGen\AtomicExpandPass.cpp, line 172
+ 0x13 byte(s)
0x018EA242 (0x0B7EF304 0x0B58DC88 0x00000000 0x0B7EF304),
llvm::FPPassManager::runOnFunction() + 0x1D2 bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\IR\LegacyPassManager.cpp, line 1587 +
0x17 byte(s)
0x018EA52A (0x0B832338 0x0B58DCCC 0x0B58DC94 0x00000000),
llvm::FPPassManager::runOnModule() + 0x7A bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\IR\LegacyPassManager.cpp, line 1629 +
0x10 byte(s)
0x018EAF82 (0x0B832338 0x0B58E018 0x0B58E024 0x0AADE000), `anonymous
namespace'::MPPassManager::runOnModule() + 0x242 bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\IR\LegacyPassManager.cpp, line 1698 +
0x17 byte(s)
0x018EB835 (0x0B832338 0x0B58DE3C 0x0B58E018 0x02B2404C),
llvm::legacy::PassManagerImpl::run() + 0xF5 bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\IR\LegacyPassManager.cpp, line 614 +
0x1B byte(s)
0x018E589D (0x0B832338 0x0B58E1B8 0x00000000 0xCCCCCCCC),
llvm::legacy::PassManager::run() + 0x1D bytes(s),
C:\mgrang\checkedc\upgrade\src\llvm\lib\IR\LegacyPassManager.cpp, line 1825
0x02B2404C (0x00000005 0x0B7F0AD8 0x0B58E290 0x0B58E1E0), `anonymous
namespace'::EmitAssemblyHelper::EmitAssembly() + 0x7EC bytes(s),
C:\mgrang\checkedc\upgrade\src\clang\lib\CodeGen\BackendUtil.cpp, line 967
0x02B22238 (0x0B7F28A0 0x0B7D2CA0 0x0B7D0038 0x0B7CC240),
clang::EmitBackendOutput() + 0x2E8 bytes(s),
C:\mgrang\checkedc\upgrade\src\clang\lib\CodeGen\BackendUtil.cpp, line 1680
0x087E0A7E (0x0B8223F8 0x0B58E558 0x0B58E34C 0x01CCCCCC),
clang::BackendConsumer::HandleTranslationUnit() + 0x3BE bytes(s),
C:\mgrang\checkedc\upgrade\src\clang\lib\CodeGen\CodeGenAction.cpp, line 335 +
0x62 byte(s)
0x05944A3B (0x0B86DD38 0x00000000 0x00000000 0x0B58E560), clang::ParseAST() +
0x2BB bytes(s), C:\mgrang\checkedc\upgrade\src\clang\lib\Parse\ParseAST.cpp,
line 171 + 0x18 byte(s)
0x033EBBE1 (0x0B58E5A0 0x0B58E560 0xCCCCCCCC 0xCCCCCCCC),
clang::ASTFrontendAction::ExecuteAction() + 0x101 bytes(s),
C:\mgrang\checkedc\upgrade\src\clang\lib\Frontend\FrontendAction.cpp, line 1057
+ 0x30 byte(s)
0x087D7A16 (0x0B58E6D0 0x0B58E5AC 0xCCCCCCCC 0xCCCCCCCC),
clang::CodeGenAction::ExecuteAction() + 0x516 bytes(s),
C:\mgrang\checkedc\upgrade\src\clang\lib\CodeGen\CodeGenAction.cpp, line 1185
0x033EB6E6 (0x0B58E660 0x0B58E7DC 0x0B7C7690 0xCCCCCCCC),
clang::FrontendAction::Execute() + 0x76 bytes(s),
C:\mgrang\checkedc\upgrade\src\clang\lib\Frontend\FrontendAction.cpp, line 950
+ 0xF byte(s)
0x0337FC63 (0x0B7EF248 0x0B58EE14 0x0B58E7DC 0xCCCCCCCC),
clang::CompilerInstance::ExecuteAction() + 0x5D3 bytes(s),
C:\mgrang\checkedc\upgrade\src\clang\lib\Frontend\CompilerInstance.cpp, line
984 + 0xC byte(s)
0x03575F61 (0x0B79B618 0x0B58EEEC 0x0B58FB50 0xCCCCCCCC),
clang::ExecuteCompilerInvocation() + 0x541 bytes(s),
C:\mgrang\checkedc\upgrade\src\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp,
line 278 + 0x14 byte(s)
0x007ADFD3 (0x0B58FA78 0x00000036 0x0B7CCE7D 0x006012A9), cc1_main() + 0x483
bytes(s), C:\mgrang\checkedc\upgrade\src\clang\tools\driver\cc1_main.cpp, line
240 + 0xE byte(s)
0x0079DACF (0x0B58FA68 0x0048BA2D 0x0048BA2D 0xCCCCCCCC), ExecuteCC1Tool() +
0xFF bytes(s), C:\mgrang\checkedc\upgrade\src\clang\tools\driver\driver.cpp,
line 330 + 0x3D byte(s)
0x0079E19F (0x00000037 0x0B7CB678 0x0B7A4478 0x00000037), main() + 0x4FF
bytes(s), C:\mgrang\checkedc\upgrade\src\clang\tools\driver\driver.cpp, line
407 + 0xC byte(s)
0x082FBC13 (0xC241C7CF 0x0048BA2D 0x0048BA2D 0x0AADE000), invoke_main() + 0x33
bytes(s),
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl, line
78 + 0x2D byte(s)
0x082FBA67 (0x0B58FF68 0x082FBC98 0x0B58FF78 0x7685FA29),
__scrt_common_main_seh() + 0x157 bytes(s),
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl, line
288 + 0x5 byte(s)
0x082FB8FD (0x0B58FF78 0x7685FA29 0x0AADE000 0x7685FA10), __scrt_common_main()
+ 0xD bytes(s),
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl, line
331
0x082FBC98 (0x0AADE000 0x7685FA10 0x0B58FFD4 0x772F75F4), mainCRTStartup() +
0x8 bytes(s),
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp, line 17
0x7685FA29 (0x0AADE000 0x056D957F 0x00000000 0x00000000), BaseThreadInitThunk()
+ 0x19 bytes(s)
0x772F75F4 (0xFFFFFFFF 0x77317350 0x00000000 0x00000000),
RtlGetAppContainerNamedObjectPath() + 0xE4 bytes(s)
0x772F75C4 (0x0048BA2D 0x0AADE000 0x00000000 0x00000000),
RtlGetAppContainerNamedObjectPath() + 0xB4 bytes(s)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 11.0.0 (https://github.com/Microsoft/checkedc-clang
5b67a18821f2b1dc2aad5cedec5d39934803ac95)

Note: The following are two bugs reported for similar (but not same) issues:
1. https://bugs.llvm.org/show_bug.cgi?id=44945
2. https://bugs.llvm.org/show_bug.cgi?id=46176
Quuxplusone commented 3 years ago
Are you sure this isn't the known MSVC bug for passing overaligned arguments in
debug builds?
https://developercommunity.visualstudio.com/content/problem/1179643/msvc-copies-overaligned-non-trivially-copyable-par.html
Duped into this:
https://developercommunity2.visualstudio.com/t/Incorrect-Code-Gen--Missing-Error/831543
Which is labeled "pending release".

We have pragmas to workaround that issue:
https://github.com/llvm/llvm-project/commit/4e3edef4b8b637c0c76897497eb7c66f00157210

Maybe the workaround wasn't enough.
Quuxplusone commented 3 years ago

Thanks for the pointers, Reid. My test case passes with the Visual Studio Preview v16.9.0-pre.4.0. So I guess this is a duplicate of the MSVC bug you pointed to. I will go ahead and mark this as duplicate of https://bugs.llvm.org/show_bug.cgi?id=46176.

Quuxplusone commented 3 years ago

_This bug has been marked as a duplicate of bug 46176_

Quuxplusone commented 3 years ago

We attempted to work around the bug by applying that pragma in the commit I linked. Do you have that workaround in your version of LLVM? Maybe we just need to apply it to other files where this is an issue, or if the pragma doesn't work, perhaps we could fix the issue by moving from /Od to /O1 in cmake.