llvm / llvm-project

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

Clang-18 crash in -rewrite-legacy-objc #94380

Open ethanc8 opened 3 months ago

ethanc8 commented 3 months ago

Hi! I was trying to understand another compiler bug (I don't know enough about it to post here, but you can see symptoms at https://github.com/gnustep/libobjc2/issues/283) which occurred in the combination of the library libs-quartzcore and parts of the application GitUp. I've attached the logs of the issue. The issue only occurred in -rewrite-legacy-objc -fno-ms-extensions -fpermissive. Under normal compilation, it compiled fine, and under -rewrite-objc -fno-ms-extensions -fpermissive, it returned errors because the code contained constructs only allowed in C and not in C++, such as assigning booleans (BOOL) to variables of type struct objc_object* (id) without a typecast.

CAAnimation-f7059d.m CAAnimation-f7059d.sh

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang-18 CAAnimation.m -c -MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNUSTEP_RUNTIME=1 -D_NONFRAGILE_ABI=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -pthread -fPIC -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -O2 -rewrite-legacy-objc -fno-ms-extensions -fpermissive -fobjc-runtime=gnustep-2.1 -fblocks -fconstant-string-class=NSConstantString -I./derived_src -I. -I/home/ethan/GNUstep/Library/Headers -I/usr/GNUstep/Local/Library/Headers -I/usr/GNUstep/System/Library/Headers -o obj/QuartzCore.obj/CAAnimation.m.o
1.      <eof> parser at end of file
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM.so.18.1      0x00007f9417d94716 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54
1  libLLVM.so.18.1      0x00007f9417d926d0 llvm::sys::RunSignalHandlers() + 80
2  libLLVM.so.18.1      0x00007f9417ce41f0
3  libc.so.6            0x00007f9416842520
4  libclang-cpp.so.18.1 0x00007f9420a75f24
5  libclang-cpp.so.18.1 0x00007f9420a7641a
6  libclang-cpp.so.18.1 0x00007f9420a770e6 clang::RewriteBuffer::ReplaceText(unsigned int, unsigned int, llvm::StringRef) + 86
7  libclang-cpp.so.18.1 0x00007f9420a78175 clang::Rewriter::ReplaceText(clang::SourceLocation, unsigned int, llvm::StringRef) + 197
8  libclang-cpp.so.18.1 0x00007f942109922b
9  libclang-cpp.so.18.1 0x00007f9421071f73
10 libclang-cpp.so.18.1 0x00007f941f37ffc6 clang::ParseAST(clang::Sema&, bool, bool) + 614
11 libclang-cpp.so.18.1 0x00007f94211b0ab5 clang::FrontendAction::Execute() + 85
12 libclang-cpp.so.18.1 0x00007f942112a084 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 708
13 libclang-cpp.so.18.1 0x00007f942122b25e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 750
14 clang-18             0x000059055c74ad55 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 4069
15 clang-18             0x000059055c748155
16 libclang-cpp.so.18.1 0x00007f9420de25c9
17 libLLVM.so.18.1      0x00007f9417ce3f8c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 140
18 libclang-cpp.so.18.1 0x00007f9420de1f5e clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const + 366
19 libclang-cpp.so.18.1 0x00007f9420daa4d1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 897
20 libclang-cpp.so.18.1 0x00007f9420daa71e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const + 142
21 libclang-cpp.so.18.1 0x00007f9420dc6d2d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) + 333
22 clang-18             0x000059055c747ac4 clang_main(int, char**, llvm::ToolContext const&) + 11172
23 clang-18             0x000059055c754bf6 main + 102
24 libc.so.6            0x00007f9416829d90
25 libc.so.6            0x00007f9416829e40 __libc_start_main + 128
26 clang-18             0x000059055c744bc5 _start + 37
clang-18: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Ubuntu clang version 18.1.6 (++20240518023229+1118c2e05e67-1~exp1~20240518143321.130)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
clang-18: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-18: note: diagnostic msg: /tmp/CAAnimation-f7059d.m
clang-18: note: diagnostic msg: /tmp/CAAnimation-f7059d.sh
clang-18: note: diagnostic msg: 

********************
llvmbot commented 3 months ago

@llvm/issue-subscribers-clang-frontend

Author: None (ethanc8)

Hi! I was trying to understand another compiler bug (I don't know enough about it to post here, but you can see symptoms at https://github.com/gnustep/libobjc2/issues/283) which occurred in the combination of the library [libs-quartzcore](https://github.com/ethanc8/libs-quartzcore) and parts of the application [GitUp](https://github.com/ethanc8/Gitup). I've attached the logs of the issue. The issue only occurred in `-rewrite-legacy-objc -fno-ms-extensions -fpermissive`. Under normal compilation, it compiled fine, and under `-rewrite-objc -fno-ms-extensions -fpermissive`, it returned errors because the code contained constructs only allowed in C and not in C++, such as assigning booleans (`BOOL`) to variables of type `struct objc_object*` (`id`) without a typecast. [CAAnimation-f7059d.m](https://github.com/user-attachments/files/15567874/CAAnimation-f7059d.m.txt) [CAAnimation-f7059d.sh](https://github.com/user-attachments/files/15567876/CAAnimation-f7059d.sh.txt) ``` PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script. Stack dump: 0. Program arguments: clang-18 CAAnimation.m -c -MMD -MP -DGNUSTEP -DGNUSTEP_BASE_LIBRARY=1 -DGNU_GUI_LIBRARY=1 -DGNUSTEP_RUNTIME=1 -D_NONFRAGILE_ABI=1 -DGNUSTEP_BASE_LIBRARY=1 -fno-strict-aliasing -fexceptions -fobjc-exceptions -D_NATIVE_OBJC_EXCEPTIONS -pthread -fPIC -Wall -DGSWARN -DGSDIAGNOSE -Wno-import -g -O2 -rewrite-legacy-objc -fno-ms-extensions -fpermissive -fobjc-runtime=gnustep-2.1 -fblocks -fconstant-string-class=NSConstantString -I./derived_src -I. -I/home/ethan/GNUstep/Library/Headers -I/usr/GNUstep/Local/Library/Headers -I/usr/GNUstep/System/Library/Headers -o obj/QuartzCore.obj/CAAnimation.m.o 1. <eof> parser at end of file Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it): 0 libLLVM.so.18.1 0x00007f9417d94716 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 54 1 libLLVM.so.18.1 0x00007f9417d926d0 llvm::sys::RunSignalHandlers() + 80 2 libLLVM.so.18.1 0x00007f9417ce41f0 3 libc.so.6 0x00007f9416842520 4 libclang-cpp.so.18.1 0x00007f9420a75f24 5 libclang-cpp.so.18.1 0x00007f9420a7641a 6 libclang-cpp.so.18.1 0x00007f9420a770e6 clang::RewriteBuffer::ReplaceText(unsigned int, unsigned int, llvm::StringRef) + 86 7 libclang-cpp.so.18.1 0x00007f9420a78175 clang::Rewriter::ReplaceText(clang::SourceLocation, unsigned int, llvm::StringRef) + 197 8 libclang-cpp.so.18.1 0x00007f942109922b 9 libclang-cpp.so.18.1 0x00007f9421071f73 10 libclang-cpp.so.18.1 0x00007f941f37ffc6 clang::ParseAST(clang::Sema&, bool, bool) + 614 11 libclang-cpp.so.18.1 0x00007f94211b0ab5 clang::FrontendAction::Execute() + 85 12 libclang-cpp.so.18.1 0x00007f942112a084 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 708 13 libclang-cpp.so.18.1 0x00007f942122b25e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 750 14 clang-18 0x000059055c74ad55 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 4069 15 clang-18 0x000059055c748155 16 libclang-cpp.so.18.1 0x00007f9420de25c9 17 libLLVM.so.18.1 0x00007f9417ce3f8c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 140 18 libclang-cpp.so.18.1 0x00007f9420de1f5e clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const + 366 19 libclang-cpp.so.18.1 0x00007f9420daa4d1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 897 20 libclang-cpp.so.18.1 0x00007f9420daa71e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const + 142 21 libclang-cpp.so.18.1 0x00007f9420dc6d2d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) + 333 22 clang-18 0x000059055c747ac4 clang_main(int, char**, llvm::ToolContext const&) + 11172 23 clang-18 0x000059055c754bf6 main + 102 24 libc.so.6 0x00007f9416829d90 25 libc.so.6 0x00007f9416829e40 __libc_start_main + 128 26 clang-18 0x000059055c744bc5 _start + 37 clang-18: error: clang frontend command failed with exit code 139 (use -v to see invocation) Ubuntu clang version 18.1.6 (++20240518023229+1118c2e05e67-1~exp1~20240518143321.130) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin clang-18: note: diagnostic msg: ******************** PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-18: note: diagnostic msg: /tmp/CAAnimation-f7059d.m clang-18: note: diagnostic msg: /tmp/CAAnimation-f7059d.sh clang-18: note: diagnostic msg: ******************** ```
shafik commented 3 months ago

CC @rjmccall

ethanc8 commented 3 months ago

Note that this is on Linux, using GNUstep.