Bug 55553 - LLVM causes Assertion failed: ((instructionAddress & 0x3) == 0), function makeLDR_literal
Summary: LLVM causes Assertion failed: ((instructionAddress & 0x3) == 0), function mak...
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: 15.3
Assignee: Zoltan Varga
URL:
Depends on:
Blocks: 55555
  Show dependency tree
 
Reported: 2017-04-25 12:22 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2017-07-20 07:04 UTC (History)
5 users (show)

Tags: 2017-02
Is this bug a regression?: ---
Last known good build:


Attachments
crash.zip (30.09 KB, application/zip)
2017-04-25 12:22 UTC, Rolf Bjarne Kvinge [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
VERIFIED FIXED

Description Rolf Bjarne Kvinge [MSFT] 2017-04-25 12:22:55 UTC
Created attachment 21754 [details]
crash.zip

Unzip attached test case.
Run test.sh

Result:

> ./test.sh 
+ LLC=/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/LLVM/bin/llc
+ CLANG='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -arch arm64 -miphoneos-version-min=10.0'
+ /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/LLVM/bin/llc -O0 -data-sections -asm-verbose=false -mtriple=arm64-ios -enable-pie -enable-mono-eh-frame -mono-eh-frame-symbol=_mono_aot_testApp_eh_frame -relocation-model=static -filetype=obj -o testApp.exe-llvm.o testApp.exe.s.opt.bc
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -arch arm64 -miphoneos-version-min=10.0 -c -x objective-c++ -o main.o main.m
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -arch arm64 -miphoneos-version-min=10.0 main.o testApp.exe-llvm.o -o testApp
0  0x109f5753b  __assert_rtn + 129
1  0x109fc249c  ld::tool::makeLDR_literal(ld::tool::LoadStoreInfo const&, unsigned long long, unsigned long long) + 402
2  0x109fbf4d7  ld::tool::OutputFile::applyFixUps(ld::Internal&, unsigned long long, ld::Atom const*, unsigned char*) + 6245
3  0x109fc2a1c  ld::tool::OutputFile::writeAtoms(ld::Internal&, unsigned char*) + 330
4  0x109fbafa2  ld::tool::OutputFile::writeOutputFile(ld::Internal&) + 858
5  0x109fb46bc  ld::tool::OutputFile::write(ld::Internal&) + 178
6  0x109f583fc  main + 1096
A linker snapshot was created at:
	/tmp/testApp-2017-03-25-142030.ld-snapshot
ld: Assertion failed: ((instructionAddress & 0x3) == 0), function makeLDR_literal, file /Library/Caches/com.apple.xbs/Sources/ld64/ld64-278.4/src/ld/OutputFile.cpp, line 835.
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It seems that llc has a problem when compiling a .o from a .bc. If I compile the .bc to .s, and then use clang to compile the .s to .o, then the native linker does not complain (this is explained in the test.sh script as well, with sample commands).
Comment 1 Rolf Bjarne Kvinge [MSFT] 2017-04-25 16:57:12 UTC
It's possible to work around this by passing -Wl,-ignore_optimization_hints to clang.
Comment 2 Zoltan Varga 2017-05-01 08:02:52 UTC
Bump llvm to 975e3a6903003d7dba1b01f8a3c4a42a55049842, that should fix it.
Comment 3 Ludovic Henry 2017-05-01 14:10:04 UTC
@Rolf, could you check if bumping llvm fixes it?
Comment 4 Sebastien Pouliot 2017-05-02 15:29:21 UTC
PR master https://github.com/xamarin/xamarin-macios/pull/2059
Comment 5 Rolf Bjarne Kvinge [MSFT] 2017-05-04 05:23:22 UTC
@Ludovic, I can confirm the llvm fix fixes the problem.
Comment 7 Sebastien Pouliot 2017-05-04 12:38:30 UTC
The fix is only in master so moving milestone to 15.3

Since we have a workaround (and it's late to bump llvm) I do not think we need to backport it to 15.2.
Comment 8 Prasad Raghorte 2017-07-20 07:04:27 UTC
I have run the provided sample on terminal for the below configuration and no such clang error was observed. looks good to me. Marking this as verified.
Build info: https://gist.github.com/raghorteprasad/d1bd993f287b2b06e49be1263e97a74a