Bug 13178 - LLVM crashes during AOT
Summary: LLVM crashes during AOT
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 6.3.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: 6.4 (async)
Assignee: Zoltan Varga
URL:
Depends on:
Blocks:
 
Reported: 2013-07-11 11:52 UTC by Nic Wise
Modified: 2013-09-29 19:28 UTC (History)
4 users (show)

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


Attachments
small sample executable that fails --aot --llvm. (3.50 KB, application/octet-stream)
2013-09-29 18:15 UTC, Brandon Bremen
Details
full verbose output from mono --aot --llvm (15.89 KB, application/octet-stream)
2013-09-29 18:16 UTC, Brandon Bremen
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:
RESOLVED FIXED

Description Nic Wise 2013-07-11 11:52:00 UTC
This is from here:

http://forums.xamarin.com/discussion/comment/20418

Just updated to Mono 3.1 (from the beta channel)

Rebuilt a perviously working project, and KABOOM

Xamarin Studio Version 4.0.9 (build 12) Installation UUID: e2c9010f-f7fa-4697-9e56-a6088aa107ef Runtime: Mono 3.1.1 ((no/c07cb68) GTK 2.24.20 GTK# (2.12.0.0) Package version: 301010000

Apple Developer Tools Xcode 4.6.3 (2068) Build 4H1503

Xamarin.iOS Version: 6.3.7.164 (Business Edition) Hash: b7e6b95 Branch: Build date: 2013-03-07 10:27:05-0400

If I turn off LLVM, it works fine.

This is only with ONE of my projects. I've tried it with another one, and it's ok. I've attached the bin and obj folders here, incase they are useful. I've also tried deleting them, but same error.

I was able to build this before I installed 3.1, but as Mono is INSIDE X.iOS, that makes no sense?

I have XCode DP2 installed if thats any help, as well as the normal xcode. I'm pointing at the normal one.



Compiling to native code
/Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" --cache "/Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache" --nomanifest --nosign -dev "/Users/nic/code/git/tripwallet/bin/iPhone/AppStore/TripWallet.app" -r "/Users/nic/code/git/tripwallet/MonoTouch.Dialog/bin/iPhone/Release/MonoTouch.Dialog.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" -r "/Users/nic/code/git/tripwallet/meta/NewtonsoftJsonMonoTouch.dll" --crashreporting-api-key:zzz -linksdkonly -sdk "6.1" -targetver "5.1" --abi=armv7+llvm "/Users/nic/code/git/tripwallet/bin/iPhone/AppStore/TripWallet.exe"
AOT Compilation exited with code 1, command:
MONO_PATH=/Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/Build /Developer/MonoTouch/usr/bin/arm-darwin-mono-boehm --debug --llvm -O=gsharedvt  --aot=mtriple=armv7-ios,full,static,asmonly,direct-icalls,nodebug,dwarfdebug,llvm-path=/Developer/MonoTouch/LLVM/bin/,outfile=/Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/System.Xml.dll.armv7.s "/Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/Build/System.Xml.dll"
Assertion failed: (indexes), function PrepareMonoLSDA, file /Developer/MonoTouch/Source/llvm/lib/CodeGen/AsmPrinter/DwarfMonoException.cpp, line 340.
0  llc               0x00929cc8 void* llvm::object_creator<std::vector<std::string, std::allocator<std::string> > >() + 13256
1  llc               0x00929f6c void* llvm::object_creator<std::vector<std::string, std::allocator<std::string> > >() + 13932
2  llc               0x0092a3ba void* llvm::object_creator<std::vector<std::string, std::allocator<std::string> > >() + 15034
3  libsystem_c.dylib 0x9703b8cb _sigtramp + 43
4  libsystem_c.dylib 0xffffffff _sigtramp + 1761363807
5  llc               0x0092a02b void* llvm::object_creator<std::vector<std::string, std::allocator<std::string> > >() + 14123
6  llc               0x0092a002 void* llvm::object_creator<std::vector<std::string, std::allocator<std::string> > >() + 14082
7  llc               0x0043c5c8 void std::__final_insertion_sort<llvm::LandingPadInfo const**, bool (*)(llvm::LandingPadInfo const*, llvm::LandingPadInfo const*)>(llvm::LandingPadInfo const**, llvm::LandingPadInfo const**, bool (*)(llvm::LandingPadInfo const*, llvm::LandingPadInfo const*)) + 7384
8  llc               0x0043eaef void std::__final_insertion_sort<llvm::LandingPadInfo const**, bool (*)(llvm::LandingPadInfo const*, llvm::LandingPadInfo const*)>(llvm::LandingPadInfo const**, llvm::LandingPadInfo const**, bool (*)(llvm::LandingPadInfo const*, llvm::LandingPadInfo const*)) + 16895
9  llc               0x00404740 std::vector<llvm::TargetLowering::AsmOperandInfo, std::allocator<llvm::TargetLowering::AsmOperandInfo> >::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::TargetLowering::AsmOperandInfo*, std::vector<llvm::TargetLowering::AsmOperandInfo, std::allocator<llvm::TargetLowering::AsmOperandInfo> > >, llvm::TargetLowering::AsmOperandInfo const&) + 17152
10 llc               0x0014b52b std::_Rb_tree<llvm::MachineInstr*, std::pair<llvm::MachineInstr* const, unsigned int>, std::_Select1st<std::pair<llvm::MachineInstr* const, unsigned int> >, std::less<llvm::MachineInstr*>, std::allocator<std::pair<llvm::MachineInstr* const, unsigned int> > >::_M_erase(std::_Rb_tree_node<std::pair<llvm::MachineInstr* const, unsigned int> >*) + 1883
11 llc               0x004e0067 std::vector<llvm::MachineBasicBlock*, std::allocator<llvm::MachineBasicBlock*> >::_M_fill_insert(__gnu_cxx::__normal_iterator<llvm::MachineBasicBlock**, std::vector<llvm::MachineBasicBlock*, std::allocator<llvm::MachineBasicBlock*> > >, unsigned long, llvm::MachineBasicBlock* const&) + 1719
12 llc               0x0085f238 std::vector<llvm::Type*, std::allocator<llvm::Type*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::Type**, std::vector<llvm::Type*, std::allocator<llvm::Type*> > >, llvm::Type* const&) + 29032
13 llc               0x0085f51f std::vector<llvm::Type*, std::allocator<llvm::Type*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::Type**, std::vector<llvm::Type*, std::allocator<llvm::Type*> > >, llvm::Type* const&) + 29775
14 llc               0x0085f833 std::vector<llvm::Type*, std::allocator<llvm::Type*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::Type**, std::vector<llvm::Type*, std::allocator<llvm::Type*> > >, llvm::Type* const&) + 30563
15 llc               0x0085fee0 std::vector<llvm::Type*, std::allocator<llvm::Type*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::Type**, std::vector<llvm::Type*, std::allocator<llvm::Type*> > >, llvm::Type* const&) + 32272
16 llc               0x0086012b std::vector<llvm::Type*, std::allocator<llvm::Type*> >::_M_insert_aux(__gnu_cxx::__normal_iterator<llvm::Type**, std::vector<llvm::Type*, std::allocator<llvm::Type*> > >, llvm::Type* const&) + 32859
17 llc               0x00102218
18 llc               0x00100ca5
Stack dump:
0.  Program arguments: /Developer/MonoTouch/LLVM/bin/llc -mattr=+vfp2,-neon,+d16 -asm-verbose=false -mtriple=armv7-ios -relocation-model=pic -disable-gnu-eh-frame -enable-mono-eh-frame -o /Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/System.Xml.dll.armv7.s /Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/System.Xml.dll.armv7.s.opt.bc 
1.  Running pass 'Function Pass Manager' on module '/Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/System.Xml.dll.armv7.s.opt.bc'.
2.  Running pass 'ARM Assembly / Object Emitter' on function '@mono_aot_personality'
Mono Ahead of Time compiler - compiling assembly /Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/Build/System.Xml.dll
Executing opt: /Developer/MonoTouch/LLVM/bin/opt -f -simplifycfg -domtree -domfrontier -scalarrepl -instcombine -simplifycfg -domtree -domfrontier -scalarrepl -simplify-libcalls -instcombine -simplifycfg -instcombine -simplifycfg -reassociate -domtree -loops -loop-simplify -domfrontier -loop-simplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -iv-users -indvars -loop-deletion -loop-simplify -lcssa -loop-unroll -instcombine -memdep -gvn -memdep -memcpyopt -sccp -instcombine -domtree -memdep -dse -adce -simplifycfg -preverify -domtree -verify -o /Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/System.Xml.dll.armv7.s.opt.bc /Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/System.Xml.dll.armv7.s.bc
Executing llc: /Developer/MonoTouch/LLVM/bin/llc  -mattr=+vfp2,-neon,+d16 -asm-verbose=false -mtriple=armv7-ios -relocation-model=pic -disable-gnu-eh-frame -enable-mono-eh-frame -o /Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/System.Xml.dll.armv7.s /Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/System.Xml.dll.armv7.s.opt.bc

error MT3001: Could not AOT the assembly '/Users/nic/code/git/tripwallet/obj/iPhone/TestFlight/mtouch-cache/Build/System.Xml.dll'
Comment 1 Nic Wise 2013-07-11 12:01:24 UTC
oops, can't add a 70meg file as an attachment. So it's here

https://www.dropbox.com/s/h8tm1bmhl6g9nkt/binobj.zip

Thanks
Comment 2 Sebastien Pouliot 2013-07-16 08:38:43 UTC
afaik arm-darwin-mono-boehm shouldnot have any dependency on the system mono. 

The mcs compiler comes from the system mono - but the crash occrus on an SDK assembly.

Zoltan?
Comment 3 Nic Wise 2013-07-16 09:13:44 UTC
Sorry, I should absolutely know better. It's not 3.1.1. I'm back on 3.0.12, (and the mono is embedded, so it shouldn't matter) and I get the same thing.

Only one project tho. And always on System.Xml.dll, which I dont directly use.

It just happened at the same time as I got 3.1.1 :) And on two machines, too.

Happy to share the project - it's on bitbucket, so if you tell me your login/email/whatever the ident is, I'll share it.
Comment 4 Zoltan Varga 2013-07-16 09:47:16 UTC
Fixed in llvm bf1cd665566b57eaf9cb647db6241655be9c5953. This is safe to backport to the release branch.
Comment 6 Nic Wise 2013-07-16 10:05:40 UTC
Thanks everyone - much appreciated!
Comment 7 Zoltan Varga 2013-07-16 10:15:42 UTC
LLVM will assert when presented with a module with no methods in it, i.e. if everything was removed by the linker.
Comment 8 PJ 2013-07-17 14:54:49 UTC
This is a regression it seems, so let's bump LLVM to get the fix in 6.4.
Comment 9 Brandon Bremen 2013-09-29 18:13:39 UTC
I've reproduced this bug with Xamarin Studio 4.1.12 which bundles mono version "Mono JIT compiler version 3.2.3 ((no/8d3b4b7 Mon Sep 16 23:46:28 EDT 2013)".

To use the --llvm option, we had to add /Library/Frameworks/Mono.framework/Versions/3.2.3/bin/ to our PATH and exported DYLD_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Versions/3.2.3/lib/ . At this point, we execute "mono --aot --llvm inline.exe" (attached) and get the same crash as reported here.

Assertion failed: (indexes), function PrepareMonoLSDA, file DwarfMonoException.cpp, line 340.
0  llc               0x0090d6f8 llvm::sys::operator-(llvm::sys::TimeValue const&, llvm::sys::TimeValue const&) + 6152
1  llc               0x0090d8fc llvm::sys::operator-(llvm::sys::TimeValue const&, llvm::sys::TimeValue const&) + 6668
2  llc               0x0090ddea llvm::sys::operator-(llvm::sys::TimeValue const&, llvm::sys::TimeValue const&) + 7930
3  libsystem_c.dylib 0x00cb394b _sigtramp + 43

[...]

Stack dump:
0.  Program arguments: llc -asm-verbose=false -relocation-model=pic -disable-gnu-eh-frame -enable-mono-eh-frame -o temp.s temp.s.opt.bc
1.  Running pass 'Function Pass Manager' on module 'temp.s.opt.bc'.
2.  Running pass 'X86 Assembly / Object Emitter' on function '@mono_aot_personality'
Executing opt: opt -f -simplifycfg -domtree -domfrontier -scalarrepl -instcombine -simplifycfg -domtree -domfrontier -scalarrepl -simplify-libcalls -instcombine -simplifycfg -instcombine -simplifycfg -reassociate -domtree -loops -loop-simplify -domfrontier -loop-simplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -iv-users -indvars -loop-deletion -loop-simplify -lcssa -loop-unroll -instcombine -memdep -gvn -memdep -memcpyopt -sccp -instcombine -domtree -memdep -dse -adce -simplifycfg -preverify -domtree -verify -o "temp.s.opt.bc" "temp.s.bc"
Executing llc: llc  -asm-verbose=false -relocation-model=pic -disable-gnu-eh-frame -enable-mono-eh-frame -o "temp.s" "temp.s.opt.bc"


When running these commands independently, removing -enable-mono-eh-frame allows llc to complete.


It isn't clear which released Xamarin Studio version this bug might be fixed in. Can you confirm whether this fix has made it into a release?
Comment 10 Brandon Bremen 2013-09-29 18:15:04 UTC
Created attachment 5016 [details]
small sample executable that fails --aot --llvm.
Comment 11 Brandon Bremen 2013-09-29 18:16:04 UTC
Created attachment 5017 [details]
full verbose output from mono --aot --llvm
Comment 12 Zoltan Varga 2013-09-29 19:28:04 UTC
This bug is about xamarin.ios, mono 3.2.3 still has this problem.