Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ethanc8 opened this issue Jun 4, 2024 · 3 comments
Open

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

ethanc8 opened this issue Jun 4, 2024 · 3 comments
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] objective-c

Comments

@ethanc8
Copy link

ethanc8 commented Jun 4, 2024

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 gnustep/libobjc2#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: 

********************
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] objective-c and removed new issue labels Jun 4, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 4, 2024

@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
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.      &lt;eof&gt; 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&amp;, 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&amp;, 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&amp;) + 708
13 libclang-cpp.so.18.1 0x00007f942122b25e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 750
14 clang-18             0x000059055c74ad55 cc1_main(llvm::ArrayRef&lt;char const*&gt;, 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&lt;void ()&gt;) + 140
18 libclang-cpp.so.18.1 0x00007f9420de1f5e clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const + 366
19 libclang-cpp.so.18.1 0x00007f9420daa4d1 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const + 897
20 libclang-cpp.so.18.1 0x00007f9420daa71e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const + 142
21 libclang-cpp.so.18.1 0x00007f9420dc6d2d clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) + 333
22 clang-18             0x000059055c747ac4 clang_main(int, char**, llvm::ToolContext const&amp;) + 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
Copy link
Collaborator

shafik commented Jun 4, 2024

CC @rjmccall

@ethanc8
Copy link
Author

ethanc8 commented Jun 5, 2024

Note that this is on Linux, using GNUstep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" crash Prefer [crash-on-valid] or [crash-on-invalid] objective-c
Projects
None yet
Development

No branches or pull requests

4 participants