Xcode 4 internal compiler error: bus error

﹥>﹥吖頭↗ 提交于 2019-12-05 05:47:19
Alex

I hit this error and it turns out the mistake was mine, caused basically by a type-o, or more accurately a paste-o.

I was creating two labels and adding them to the subview. The code went essentially like this.

UILabel *pointsLabel = [[UILabel alloc] initWithFrame:ptsFrame];
...
[self addSubview:pointsLabel];
[pointsLabel release];

UILabel *typeLabel = [[UILabel alloc] initWithFrame:typeFrame];
...
[self addSubview:pointsLabel];
[typeLabel release];

Notice in the second addSubview I added the pointsLabel again even though I had already released it (and really meant to add the typeLabel). I would expect this to cause a runtime error as well but for whatever reason it caused the Bus Error describe above. Something to look for.

I just had this happen (not for the first time). I still haven't figured out exactly what is causing the problem but it will compile for the simulator, but not for the device. Moving my [[array alloc] init] out of my init method and into a separate setup method fixed the problem.

Maybe I'm allocating too much memory in too short a period or something? That seems unlikely however since there are several [[array alloc] init] array setups being done before and after the one I was trying to add in. Everything was being done absolutely identical to how the other arrays were being done so why it was a problem this time is something I don't yet understand.

I also got this error, only when compiling on device, after xcode preformed a modernize of my code. I switched the compiler to Apple LLVM 2.1 in both the project and the targets build settings and ran again. This picked up some stray ; in the project and the error bus error went away.

Did you deallocate any of the objects like otherView, Im pretty sure that produces a bus error in xcode.

Really looks like a compiler bug to me.

I got the same problem (Xcode 4.0.2; LLVM GCC 4.2). In a view controller's viewDidLoad I had a line:

self.title = @"Enter your details";

I didn't need this line anymore so I removed it and subsequent builds failed with "internal compiler error: Bus error". If instead of removing the line I changed it to:

self.title = nil;

the build compiled fine.

The detailed build log contained:

MyViewController.m:316: internal compiler error: Bus error
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.
{standard input}:0:End-of-File not at end of a line
{standard input}:1704:End-of-File not at end of a line
{standard input}:unknown:Partial line at end of file ignored
{standard input}:1695:non-relocatable subtraction expression, "L_OBJC_CLASSLIST_REFERENCES_$_6" minus "LPC11_18"
{standard input}:1695:symbol: "L_OBJC_CLASSLIST_REFERENCES_$_6" can't be undefined in a subtraction expression
{standard input}:1692:non-relocatable subtraction expression, "L_OBJC_SELECTOR_REFERENCES_36" minus "LPC11_17"
{standard input}:1692:symbol: "L_OBJC_SELECTOR_REFERENCES_36" can't be undefined in a subtraction expression
[... any many more lines like this ...]

I got the same error by putting the next line of code:

tempButton.titleLabel.adjustsFontSizeToFitWidth = YES;

Doubling the same line of code it did not gave an error:

tempButton.titleLabel.adjustsFontSizeToFitWidth = YES;
tempButton.titleLabel.adjustsFontSizeToFitWidth = YES;

I encountered this problem in a project, but only when compiling for a device. When I built for the simulator it worked fine.

I was able to work around the issue by just changing my compiler from "LLVM GCC 4.2" to "LLVM Compiler 2.0" in the project's build settings.

I have to think that this is a compiler bug. It shouldn't be the case that syntactically valid yet semantically buggy code will cause the compiler to error out. The compiler does not execute the code, it just compiles it. So it shouldn't matter if you've got logic or memory management errors in there, the compiler doesn't care about those kinds of things.

Do you use any deprecated function?

I remove all calls to deprecated function and works!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!