ObjC ARC contraction (clang crash) - objective-c

I always hesitate to add a brand new question to the killer forums here, but I haven't seen anything close to this bug.
Seems clang has crashed on my while compiling one of my .m files. If anyone has seen or knows of any solution for the below I'd be immensely obliged.
This error occurs when I build for armv6 in a release configuration using XCode 4.4.1
But does not occur when I build for armv6 in a debug configuration, or release for armv7, armv7s or i386.
The specific error is "ObjC ARC contraction":
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module '/Users/Me/Documents/ThisProject/iOS/..../ClassFoo.m'.
4. Running pass 'ObjC ARC contraction' on function '#"\01-[ClassFoo evalJS:]"'
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://developer.apple.com/bugreporter/ and include command line arguments and all diagnostic information.
In the ../Intermediaries/Project.build/armv6/ folder I see:
ClassFoo.dia
and I should see (like all of its surrounding files)
ClassFoo.d
ClassFoo.dia
ClassFoo.o
Here are the top 4 of the clang stack, in case someone recognizes something in it:
0 clang 0x00000001010536f2 main + 17107682
1 clang 0x0000000101053b79 main + 17108841
2 libsystem_c.dylib 0x00007fff93c428ea _sigtramp + 26
3 libsystem_c.dylib 0x00007fff93c7a54e tiny_malloc_from_free_list + 1078
edit: I also noticed when trying again recently that I'm getting complaints about the -fno-objc-arc flag -- perhaps the compiler sym-links are pointing at the wrong binaries?
Thanks in advance,
Miles

Thanks for all your interest, and I'm sorry to have to answer this question myself but no other solution I've tried has resulted in anything successful. I've done my best to document my adventure here as a how-to-guide to hopefully help a few others.
The short version:
Xcode 4.5+ does not support building to armv6 (iphone 3g).
With fresh installs of 4.5 & 4.4.1 I experienced various versions
of the original error.
The reason is two-fold:
xcspec files Xcode uses do not include entries for this architecture.
4 needed libclang_rt*.a files have had their armv6 slices stripped.
There is a solution! (see long version below)
The long version:
Amongst the many many frustrating attempts I made to sort this issue out, such as searching SO forums, searching apple dev forums, googling, endlessly fiddling with project settings, copying earlier SDKs into the Xcode.app packages, posting this question, filing a bug report with Apple, etc. ad infinitum <-- means, "and so in into infinity" each seemed to have either nothing pertinent to reveal or only a tiny tidbit of information.
The recipe for this solution finally took one frustrated and determined developer and the culmination of everything in one very long night.
So where's the how-to?
( Right here, bro )
There are about 12 steps, so don't forget the final ones below the images!
Disclaimer: This is my own solution and it works great for me, but if you're not sure about what's going on or what you're doing please be very careful and realize that I will assume no responsibility for any damages you may incurr by trying to follow these steps. That said, here you go!
If you don't already have a copy, download Xcode 4.4.1 from http://connect.apple.com
Extract /PATH_TO_YOUR_Xcode_4.4.1.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk
Copy it to /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/
Now you'll edit 4 Xcode .xcspec files in your Xcode 4.5:
Navigate here: /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Specifications
Select these files:
iPhoneXcode4Options.xcspec
iPhoneOSArchitectures.xcspec
iPhoneCompilerOptions.xcspec
iPhoneClangOptions.xcspec
Right-click and select "Open with Xcode"
Repeat for Xcode 4.4.1, and stick the two windows side-by-side (just makes this easier).
You're going to add armv6 to several entries as below:
Here again:
And here:
Here you cut & paste an entry from Xcode 4.4.1 to Xcode 4.5:
Alright you completed that tediousness, yay! Save the edited files and close them all. Next you have to create new libclang_rt*.a files to handle compiling these arches. This step is more easily done in Terminal. Enter these commands:
Make sure the backups copy and there isn't some error in paths or typing!
cd /PATH_TO_YOUR_Xcode_4.4.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.2/lib/darwin
sudo mkdir armv6_extractions
lipo -extract armv6 -output armv6_extractions/libclang_rt.ios.armv6.a libclang_rt.ios.a
lipo -extract armv6 -output armv6_extractions/libclang_rt.profile_ios.armv6.a libclang_rt.profile_ios.a
lipo -extract armv6 -output armv6_extractions/libclang_rt.cc_kext.armv6.a libclang_rt.cc_kext.a
sudo cp -R armv6_extractions /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.2/lib/darwin
cd /PATH_TO_YOUR_Xcode_4.5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/4.2/lib/darwin
sudo mkdir originals
sudo cp libclang_rt.ios.a originals/
sudo cp libclang_rt.cc_kext_ios5.a originals/
sudo cp libclang_rt.profile_ios.a originals/
lipo -create -output libclang_rt.ios.a armv6_extractions/libclang_rt.ios.armv6.a originals/libclang_rt.ios.a
lipo -create -output libclang_rt.cc_kext_ios5.a armv6_extractions/libclang_rt.cc_kext.armv6.a originals/libclang_rt.cc_kext_ios5.a
lipo -create -output libclang_rt.profile_ios.a armv6_extractions/libclang_rt.cc_kext.armv6.a originals/libclang_rt.profile_ios.a
Restart Xcode 4.5
^...I wrote "11" here...why's it showing as "1"?
Open your project and edit your settings accordingly. I recommend that you create a separate configuration just for building to armv6, and lipo everything together when you're done.
Add armv6 to Valid Architectures
Add armv6 to Architectures
For your specific armv6 configuration, set Base SDK to iOS 5.x (whatever is now listed in the drop-down menu)
Set your deployment target as needed ( I have built as low as iOS4.1 so far, and I believe the iOS5.x sdk you installed in the beginning can deploy as low as 4.x )
Okay, I think that's all.
If anyone sees any edits that need to be made PLEASE do so, and I welcome any feedback that anyone has to give here.
If something goes wrong, fingers crossed you can always reinstall your Xcode and try again (or not).
Best of luck.

I have had this problem before.... did you initialize your .m more than once? or import it? the only time this issue has occurred for me is when I tried to initialize or import a .m file somewhere other than where its native environment was.

A compiler should not crash. If it does then the vendor needs to fix it. Unfortunately I don't think you will be able to get any useful response via a Radar from Apple because they have moved on: there is a newer version of Clang in Xcode 4.5 and they don't support armv6 any more.
Having said that you should open a Technical Support Incident, because likely they can provide you with a workaround.

The error message indicates an internal error in the compiler while processing the function #"\01-[ClassFoo evalJS:]". You might be able to get around the error by rearranging the code in that function and/or adding volatile to local variables in that function.

Related

Is there an updated disk image binary for the x86 architecture for running gem5 in full system mode?

I am currently using the linux-x86.img which I downloaded from the documentation page for gem5 (http://www.m5sim.org/Download), but since I was not able to compile the fscanf and fopen commands on this image I was wondering if there is a more recent image which I could download and use instead.
The error message throw when trying to compile the lines with fopen and fscanf are
./obj/edgelist.o: In function loadEdgeArray': edgelist.c:(.text+0x148): undefined reference to __isoc99_fscanf'
./obj/edgelist.o: In function loadEdgeArrayInfo': edgelist.c:(.text+0x20c): undefined reference to __isoc99_fscanf'
collect2: ld returned 1 exit status
make: *** [test] Error 1
This error is thrown when trying to compile from both from qemu as well as gem5.
Here's one setup that generates such an image with Buildroot. I'm a fan of Buildroot because it builds everything from source. I don't understand how fscanf and fopen could fail in that image, but I have tested them in the above setup and they work fine.
Boot used to work in the past, but gem5 X86 full system boot has been broken for likely easy to fix reasons for a few months now as of March 2020 on the gem5 side, although there are efforts in place to fix it, and so likely it will work again soon: https://www.gem5.org/project/2020/03/09/boot-tests.html
Other alternatives include:
https://gem5art.readthedocs.io/en/latest/ which Jason has been pushing and uses Packer to generate disk images
You can also extract working disk images from Docker: https://hub.docker.com/_/ubuntu This requires exporting them to a file to give to gem5.
It is also worth noting that when the gem5.org website migrated from the old Wiki to the new static website setup in Q1 2020, we lost the ability of doing directory listing under http://dist.gem5.org/dist/current/arm/ for some reason, and so devs were forced to list them one by one on the static website... https://www.gem5.org/documentation/general_docs/fullsystem/guest_binaries
I am not sure why the error is no longer occurring for me, but documenting the steps I went through which might have fixed something. I reinstalled Ubuntu18.04 therefore had to rebuild gem5 and I used the parsec image (http://www.cs.utexas.edu/~parsec_m5/x86root-parsec.img.bz2) referenced in this answer Booting gem5 X86 Ubuntu Full System Simulation

Xcode not finishing archiving on "validate *.app" step

So I am running xcode 4.6 trying and trying to make a release archive for an iPad app. Unfortunately, when I hit Product>Archive, XCode will not finish the archive. When i go into the logs, it gets all the way through the code sign step and just hangs on "validate Finger-Spelling.app" (It is an ASL app)
It had the same issue earlier, but it fixed it when I updated to xcode 4.6. Honestly, I probably have just forgotten something simple, so I here are is the build log for the step it is stuck on.
The build log step that it is stuck on:
Validate /Users/Michael/Library/Developer/Xcode/DerivedData/Finger-Spelling-dfbrlachhucwlcamnxjofkjuekbi/Build/Intermediates/ArchiveIntermediates/Finger-Spelling/InstallationBuildProductsLocation/Applications/Finger-Spelling.app
cd "/Users/Michael/Documents/Xcode Projects/Finger-Spelling"
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
setenv PRODUCT_TYPE com.apple.product-type.application
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/Validation /Users/Michael/Library/Developer/Xcode/DerivedData/Finger-Spelling-dfbrlachhucwlcamnxjofkjuekbi/Build/Intermediates/ArchiveIntermediates/Finger-Spelling/InstallationBuildProductsLocation/Applications/Finger-Spelling.app
It also may be my Bundle ID, which is "com.MichaelB.Finger-Spelling", but that matches up with everything in my info.plists.
really a stab in the dark but when I had a problem here it was that the version number I had entered was incorrect.

Command /usr/bin/lipo failed with exit code 1 error

I have finally finished my app and I was getting ready to upload when this sudden error hit me and I have no idea what to do. I have checked other posts saying to change the code signing identity and I have done this but no luck. I tried every single option in the identity and no change. If anyone knows what is going on I would really appreciate it since I would simply just like to submit my app.
Here is what else it says in the erorr log:
/usr/bin/lipo: /Users/teddy/Library/Developer/Xcode/DerivedData/grocery_stores-dcyubhefhrcjhtcxbhldfpukdgdz/Build/Intermediates/grocery stores.build/Release-iphoneos/grocerystores.build/Objects-normal/armv7/grocery stores and /Users/teddy/Library/Developer/Xcode/DerivedData/grocery_stores-dcyubhefhrcjhtcxbhldfpukdgdz/Build/Intermediates/grocery stores.build/Release-iphoneos/grocery stores.build/Objects-normal/armv7/grocery stores have the same architectures (armv7) and can't be in the same fat output file
Command /usr/bin/lipo failed with exit code 1
I solved this issue by changing the value of the Valid Architecture found in Project > Build Settings > Architectures from the default "armv6 armv7" to "armv7". Hope this helps.
It's hard to see what exactly is happening without the command you are running. It looks to me like you are specifying the same input file twice, namely the arm7 version and lipo is telling you you can't add 2 arm7 versions of grocery stores to the universal file. Can you please enter the entire lipo command you are running? From the lipo man page:
-create
Take the input files (or file) and create one universal output file from them.
Do you possibly have the same file listed twice here?
Try changing your build target to a simulator build, clean and re-run.
In my case I used pods and oped projectFile instead of project workspace
In my case it was building a project on simulator in a release scheme, changed it to debug and it worked.

How to interpret a crashlog with no references to a specific class

Today my app crashed and generated this crashlog. The crashlog does not mention any classes in my project and to me it seems almost impossible to tackle this issue.
Any ideas how to approach this problem? Thanks for your help!
There's a tool included in Apple's Developer's tools called symbolicatecrash. With it you can symbolicate crash reports, but note that you'll need the associated .dsym file of your build Check this post to see a tutorial using it.
This is how I ran the symbolitecrash binary.
Find the binary symbolitecrash
locate symbolitecrash
Optional: You may add a convenience link to /usr/bin
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash /usr/bin/symbolicatecrash
Copy the crash log to the Debug-iphoneos folder and go to the project
cp ~/Desktop/TheCrash.crash ~/Myproject/build/Debug-iphoneos
cd ~/MyProject/build/Debug-iphoneos
Run the crash log symbolicater
symbolicatecrash TheCrash.crash MyProject.app.dSYM > ReportWithSymbols.crash
The result
crashlog http://k.minus.com/jk4X2obwZMI7j.png

Using bitbake to build a custom gumstix kernel

I've a gumstix Overo which I am configuring to work with a e-CAM camera. The documentation provided by camera manufacture asks me to patch a 2.6.34 kernel and compile in Video For Linux support. When I look at gumstix user documentation they say I should execute:
bitbake -c menuconfig virtual/linux
However when I run this command I get
bacon:~/proj/overo-oe$ bitbake -c menuconfig virtual/linux
NOTE: Handling BitBake files: \ (7100/7100) [100 %]
NOTE: Parsing finished. 6382 cached, 413 parsed, 305 skipped, 2 masked.
ERROR: Nothing PROVIDES 'virtual/linux'
I'm not altogether sure about how I provide virtual/linux. Any ideas about how to fix this error?
This might be a case of out-of-date documentation. In any case, my current work around is to name the kernel explicitly: bitbake -c menuconfig linux-omap3-2.6.34
I can help with a step-by-step procedure to bitbake 3.0 kernel.
If that may be helpful for you. Using a WMware Ubuntu ...
I would stay away from convoluted build systems as bitbake. Every one seems to be inventing one... making the 'tool' to get more of your time then the thing you want to do with the tool. All of them are the same. Linus would quote on those guys:
Just don't do it...!