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

[Bug]: Segfault due to mismatching "march" commandline arguments #1710

Closed
mpflanzer opened this issue May 3, 2022 · 3 comments
Closed

[Bug]: Segfault due to mismatching "march" commandline arguments #1710

mpflanzer opened this issue May 3, 2022 · 3 comments
Labels

Comments

@mpflanzer
Copy link

mpflanzer commented May 3, 2022

Description

Update: This can more easily be reproduced with the following invocation

echo "" | clang -target aarch64-none-linux-android26 -w -march=armv8.2-a -mcpu=kryo -mtune=kryo -Werror=return-type -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wformat -Werror=format-security -fexceptions -fPIC -D__USE_FORTIFY_LEVEL=_FORTIFY_SOURCE -DANDROID -D_FORTIFY_SOURCE=2 -DPIC -Wa,-march=all -c -o /dev/null -x assembler-with-cpp -

clang doesn't dump any of the crash files, even I explicitly set the directory via -fcrash-diagnostics-dir and always want to have the files produced (-gen-reproducer). But the crash can easily be reproduced:

  • wget https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/gnutls-3.6.14.tar.xz && tar -xf gnutls-3.6.14.tar.xz
  • cd gnutls-3.6.14/lib/accelerated/aarch64
  • clang -target aarch64-none-linux-android26 -w -march=armv8.2-a -mcpu=kryo -mtune=kryo -Werror=return-type -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wformat -Werror=format-security -fexceptions -fPIC -Wa,-march=all -D__USE_FORTIFY_LEVEL=_FORTIFY_SOURCE -DANDROID -D_FORTIFY_SOURCE=2 -DPIC -c -o elf/.libs/sha1-armv8.o elf/sha1-armv8.s

Please feel free to ask if more information is needed. The same problem still exists with the latest release 3.6.16 of gnutls.

PLEASE submit a bug report to https://github.com/android-ndk/ndk/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target aarch64-none-linux-android26 -w -march=armv8.2-a -mcpu=kryo -mtune=kryo -Werror=return-type -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wformat -Werror=format-security -fexceptions -fPIC -Wa,-march=all -D__USE_FORTIFY_LEVEL=_FORTIFY_SOURCE -DANDROID -D_FORTIFY_SOURCE=2 -DPIC -c -o elf/.libs/sha1-armv8.o elf/sha1-armv8.s
1.	Compilation construction
2.	Building compilation jobs
3.	Building compilation jobs
 #0 0x000000000456d858 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x456d858)
 #1 0x000000000456d6e0 llvm::sys::RunSignalHandlers() (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x456d6e0)
 #2 0x000000000456da9a (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x456da9a)
 #3 0x00007fec5058a980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
 #4 0x00000000038438d7 llvm::opt::Arg::getAsString(llvm::opt::ArgList const&) const (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x38438d7)
 #5 0x000000000358d95f clang::driver::tools::aarch64::getAArch64TargetFeatures(clang::driver::Driver const&, llvm::Triple const&, llvm::opt::ArgList const&, std::__1::vector<llvm::StringRef, std::__1::allocator<llvm::StringRef> >&, bool) (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x358d95f)
 #6 0x0000000003575de4 (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x3575de4)
 #7 0x0000000003b6b8a5 (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x3b6b8a5)
 #8 0x0000000003b86dc5 clang::driver::Driver::BuildJobsForActionNoCache(clang::driver::Compilation&, clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, bool, bool, char const*, std::__1::map<std::__1::pair<clang::driver::Action const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, clang::driver::InputInfo, std::__1::less<std::__1::pair<clang::driver::Action const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::allocator<std::__1::pair<std::__1::pair<clang::driver::Action const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const, clang::driver::InputInfo> > >&, clang::driver::Action::OffloadKind) const (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x3b86dc5)
 #9 0x0000000003b884c9 clang::driver::Driver::BuildJobsForAction(clang::driver::Compilation&, clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, bool, bool, char const*, std::__1::map<std::__1::pair<clang::driver::Action const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, clang::driver::InputInfo, std::__1::less<std::__1::pair<clang::driver::Action const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >, std::__1::allocator<std::__1::pair<std::__1::pair<clang::driver::Action const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > const, clang::driver::InputInfo> > >&, clang::driver::Action::OffloadKind) const (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x3b884c9)
#10 0x000000000384a8e4 clang::driver::Driver::BuildJobs(clang::driver::Compilation&) const (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x384a8e4)
#11 0x000000000384530f clang::driver::Driver::BuildCompilation(llvm::ArrayRef<char const*>) (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x384530f)
#12 0x000000000383a565 main (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x383a565)
#13 0x00007fec4f5c9bf7 __libc_start_main /build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:344:0
#14 0x000000000582fa99 _start (/home/jenkins/host_utils/ndk/android-ndk-r25-beta3/toolchains/llvm/prebuilt/linux-x86_64/bin/clang+0x582fa99)

Upstream bug

No response

Commit to cherry-pick

No response

Affected versions

r24, r25

Canary version

No response

Host OS

Linux

Host OS version

Ubuntu 18.04

Affected ABIs

arm64-v8a

@mpflanzer mpflanzer added the bug label May 3, 2022
@mpflanzer
Copy link
Author

Culprit for the segfault seems to be the mismatch between -march=armv8.2-a and -Wa,-march=all in the commandline arguments. If I change the later to a matching -Wa,-march=armv8.2-a the file is processed correctly.

@mpflanzer mpflanzer changed the title [Bug]: Segfault while compiling gnutls 3.6.14 [Bug]: Segfault due to mismatching "march" commandline arguments May 3, 2022
@stephenhines
Copy link
Collaborator

I've added this to our agenda with ARM tomorrow morning. I'll file an upstream LLVM bug if necessary, but thank you for the clear description of what is going wrong here.

@jfgoog
Copy link
Collaborator

jfgoog commented May 16, 2022

This looks to have been fixed in https://reviews.llvm.org/D114677.

When I tried to reproduce this at head, I get an error, but not a crash:

$ echo "" | bin/clang -target aarch64-none-linux-android26 -w -march=armv8.2-a -mcpu=kryo -mtune=kryo -Werror=return-type -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wformat -Werror=format-security -fexceptions -fPIC -D__USE_FORTIFY_LEVEL=_FORTIFY_SOURCE -DANDROID -D_FORTIFY_SOURCE=2 -DPIC -Wa,-march=all -c -o /dev/null -x assembler-with-cpp -
clang: error: the clang compiler does not support '-march=all'

osspop pushed a commit to osspop/android-ndk that referenced this issue Jan 17, 2023
Bug: android/ndk#1710
Test: None
Change-Id: Iffb9e9f49fe1d558f7d738ac94e0437418b8848f
(cherry picked from commit d8a5a55)
Merged-In: Iffb9e9f49fe1d558f7d738ac94e0437418b8848f
osspop pushed a commit to osspop/android-ndk that referenced this issue Jan 17, 2023
Bug: android/ndk#1710
Test: None
Change-Id: Iffb9e9f49fe1d558f7d738ac94e0437418b8848f
osspop pushed a commit to osspop/android-ndk that referenced this issue Jan 17, 2023
Bug: android/ndk#1710
Test: None
Change-Id: Iffb9e9f49fe1d558f7d738ac94e0437418b8848f
(cherry picked from commit d8a5a55)
Merged-In: Iffb9e9f49fe1d558f7d738ac94e0437418b8848f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants