15

I'm getting an EXC_BREAKPOINT (EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe) error while running my app on a iOS7 device. The thing is, it runs smoothly on iOS7 simulator.

By using breakpoints, I've found the error occurs in line 6.

required init(coder aDecoder: NSCoder) {
    personPicker = ABPeoplePickerNavigationController()
    super.init(coder: aDecoder)
    personPicker.peoplePickerDelegate = self
}
 /*error line*/ @IBAction func BPressed(sender: AnyObject) {
 self.presentViewController(personPicker, animated: true, completion: nil)
}

This error is new, and didn't appeared on my device until I've added these lines into the code;

        let url = NSURL(string: urlPath)
        let request = NSURLRequest(URL: url!)
        NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue.mainQueue()) {(response, data, error) in
            println(NSString(data: data, encoding: NSUTF8StringEncoding))
        }

Also; the debugger points the error to this line:

0x16a7f0:  trap 

And gives this output in the console:

fatal error: attempt to create an Unmanaged instance from a null pointer

This error causes a black screen on device even though I've changed nothing in storyboard.

Thank you for taking your time.

Edit: This error showed no result in search engines, but I think it may be related to obj-c.

TheSaurus
  • 347
  • 1
  • 7
  • 22
  • 1
    I'm getting the exact same error (including subcode), but I'm not seeing anything in the console. It's working fine on my iPhone 6, but crashing on my 4S and iPod Touch. Seems to be the case both in the simulator and on actual devices. The problematic line for me is an append call to an array of Coordinate (which is a struct of x and y Ints). – vegather Apr 06 '15 at 20:11
  • 2
    Are you at any place in your code using an Int (or any other dataType) that might get a value so large that you get a bit overflow? As I said, I only had the problem on by 4S and iTouch (32-bit devices), but it was working perfectly on my iPhone 6. Well, I was using normal Ints to store the value from arc4random(). Changing this to UInt32 instead solved my problem. http://stackoverflow.com/questions/28177192/app-crashes-on-iphone-4s-but-no-other-device-possible-issue-with-skphysicsconta – vegather Apr 06 '15 at 20:30
  • A nice perspective, indeed. But doesn't the ios simulator emulate 32-bit? My code uses a lot of variables actually, but the max value is 13 digits for int and 40 for string. – TheSaurus Apr 06 '15 at 20:55
  • Isn't that the problem then? My understanding is that Int on a 32-bit device can only store values up to 2^31 or 2 147 483 648 which is 10 digits. Attempting to store 13 digits in that would cause a bit overflow (or crash apparently in Swift). What happens if you use Int64 or UInt64? And yes, I believe the simulator does emulate 32-bit which is why it crashes. – vegather Apr 06 '15 at 21:32
  • I'm going to change those variable types with the ones you suggested. It runs smoothly in iOS7 simulator, crashes on iOS7 4S device. – TheSaurus Apr 06 '15 at 22:03
  • Changed the ints to string, since I wasn't doing any mathematical equations with those digits. Yet the error stands still. (The ints were for confirmation codes.) – TheSaurus Apr 07 '15 at 13:57
  • iPhone 4s is 32 bit. There are various iOS7 simulators, for 32 and 64 bit devices. iPhone 4s simulator should behave same as iPhone 4s. – gnasher729 May 05 '15 at 19:37

3 Answers3

14

I ran across this issue today when testing some Swift code against an old iPad 2 (I think it's an iPad 2 -- it's model MD368LL/A), running iOS 8.1.3. It turned out that the problem existed everywhere that I was calling something like:

Int(arc4random() % <someInt>)

This worked fine on later iPads, iPhone5S, iPhone6, etc. Fixed by changing code to:

Int(UInt32(arc4random()) % UInt32(<someInt>))

I think it was a register overflow on the older hardware.

dlw
  • 511
  • 5
  • 10
  • Exact same issue for us: crash when doing String(intA + intB) on older devices. Explicitly marking as UInt32 fixes. – cayleyh Feb 02 '18 at 19:15
5

I ran into this problem, in iPhone 5, which is iOS 10.3.3.

let date = Date()
// Crashes in `iPhone 5`, but works in `iPhone 5s`.
let time: Int = 1000 * Int(date.timeIntervalSince1970) //< Crash due to cast `Double` to `Int`

// This crashes in `iPhone 5`, and `iPhone 5s` too.
let time: Int32 = 1000 * Int32(date.timeIntervalSince1970)

// It works fine in `iPhone 5`, and `iPhone 5s`.
let time: Int64 = 1000 * Int64(date.timeIntervalSince1970)
AechoLiu
  • 17,522
  • 9
  • 100
  • 118
2

In my case, this ended up being from a bit overflow issue if you cast too large of a number into too small of a type. E.g. Int(someNumber) if someNumber was an Int64 type.

iPhone 5c break at the offending line of code:

enter image description here

iwasrobbed
  • 46,496
  • 21
  • 150
  • 195