[Usual disclaimer about incomplete information.]
On Aug 22, 2014, at 11:25 PM, Peters, Brandon <[email protected]> wrote:
> I am getting this error:
>
> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode 0x0)
>
> over this line of code:
>
> if self.contentView!.frame.size.width > photo.size.width {
> docRect.size.width = self.contentView!.frame.size.width
> imageLocation.origin.x =
> (self.contentView!.frame.size.width - photo.size.width) / 2.0
> }
...
> I will also add the stack trace:
This is not a stack trace, which would be a history of the calls that led down
to the current execution point. It is a disassembly of the execution point
itself. It appears to be for code that comes after the Swift source you show.
> ArnoldTransformer2`@objc ArnoldTransformer2.ATView.drawRect
> (ArnoldTransformer2.ATView)(C.CGRect) -> () at ATView.swift:
So this is the very end of your drawRect(_:CGRect) method in (am I right?)
class ATView, subclass of UIView (I’m guessing iOS because of the use of
CGRect, but you really should say so when you ask questions), part of your
application ArnoldTransformer2. Yes?
> 0x10000e550: pushq %rbp
> 0x10000e551: movq %rsp, %rbp
> 0x10000e554: subq $0x30, %rsp
[Make room for an additional 48 bytes in the stack.]
> 0x10000e558: leaq 0x10(%rbp), %rax
> 0x10000e55c: movsd (%rax), %xmm0
> 0x10000e560: movsd 0x8(%rax), %xmm1
> 0x10000e565: movsd 0x10(%rax), %xmm2
> 0x10000e56a: movsd 0x18(%rax), %xmm3
> 0x10000e56f: movq %rdi, -0x8(%rbp)
> 0x10000e573: movsd %xmm2, -0x10(%rbp)
> 0x10000e578: movsd %xmm3, -0x18(%rbp)
> 0x10000e57d: movsd %xmm0, -0x20(%rbp)
> 0x10000e582: movsd %xmm1, -0x28(%rbp)
> 0x10000e587: callq 0x100018f1a ; symbol stub for: objc_retain
> 0x10000e58c: movsd -0x20(%rbp), %xmm0
> 0x10000e591: movsd -0x28(%rbp), %xmm1
> 0x10000e596: movsd -0x10(%rbp), %xmm2
> 0x10000e59b: movsd -0x18(%rbp), %xmm3
> 0x10000e5a0: movq -0x8(%rbp), %rdi
> 0x10000e5a4: movq %rax, -0x30(%rbp)
> 0x10000e5a8: callq 0x10000bc60 ;
> ArnoldTransformer2.ATView.drawRect (ArnoldTransformer2.ATView)(C.CGRect) ->
> () at ATView.swift:224
This instruction is a call to drawRect(_:CGRect). (Attention world: it’s a
_direct_ call!) In fact, it looks to be a recursive call to this very function.
Look at line 224 of ATView.swift (see the clue in the disassembly?). Are you
calling self.drawRect(_:CGRect) from inside itself? In that case, the infinite
recursion will run the stack out of memory, and you will crash. The clue would
be the _real_ stack trace, in the Debug navigator, which I will bet shows at
least 150,000 consecutive calls to drawRect(_:CGRect).
> 0x10000e5ad: addq $0x30, %rsp <- Problem is here
[Relinquish those 48 bytes.]
That instruction isn’t the problem. It’s the callq instruction immediately
before it.
> 0x10000e5b1: popq %rbp
> 0x10000e5b2: retq
Return from drawRect(_:CGRect).
If you do not know why it should be very rare that you should call
drawRect(_:CGRect) directly, you shouldn’t be calling it at all. Show us the
whole source of your function. Expect questions about what you are trying to
accomplish.
Let us know what platform you’re coding for. Could be OS X, but I get a whiff
of iOS Simulator.
— F
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]