iOS app crashing every other launch, can't find error
Asked Answered
L

3

80

First time I launch the app, everything seems to run fine. I'll hit the stop button, do some work and when I go to launch it again, it seems to crash before it can even load anything. Press stop, hit Run again, and it works fine. Until I repeat the process.

This is where xcode is highlighting the error with "Thread 1:signal SIGABRT". Obviously nothing useful here.

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([PokerAppDelegate class]));
    }
}

The debug console shows nothing besides (lldb) (So I suppose its stopping, not crashing at this point) So, when I perform a BT this is what I get:

(lldb) bt
* thread #1: tid = 0x1c03, 0x9a258a6a libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGABRT
    frame #0: 0x9a258a6a libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x99ea1b2f libsystem_c.dylib`pthread_kill + 101
    frame #2: 0x04a7057b libsystem_sim_c.dylib`abort + 140
    frame #3: 0x01dc0b4e GraphicsServices`GSRegisterPurpleNamedPort + 348
    frame #4: 0x01dc069f GraphicsServices`_GSEventInitialize + 123
    frame #5: 0x01dc0c1f GraphicsServices`GSEventInitialize + 36
    frame #6: 0x000163f9 UIKit`UIApplicationMain + 600
    frame #7: 0x00001d0d Guitar Chord Poker HD`main(argc=1, argv=0xbffff32c) + 141 at main.m:16
    frame #8: 0x00001c35 Guitar Chord Poker HD`start + 53
(lldb) 

Here's what I have done so far:

  • Performed a 'Clean'
  • I've reset the simulators and reset my computer
  • I've commented out all the code in the view controller, still crashes
  • I've commented out all the code in the app delegate, still crashes
  • BUT....I've run the app on a device outside of Xcode, and it seems to work perfectly fine.
  • (EDIT) I've deleted/reinstalled xcode, and all content(Simulators, Docs) from the various cache folders (This stops xcode from automatically reinstalling the old ones after a new download). Still can't find where command line tools is kept though. Still crashes.

Despite all this, apps still crash every second/other launch.

Thing is I had no issues until the most recent Xcode update. Could it be an Xcode bug?

(EDIT) I am also running the latest developer releases of OSX. Could that be interfering?

Livvy answered 19/4, 2013 at 21:35 Comment(24)
Have you tried to run an empty project on iOS simulator and on device connected/disconnected?Anticipative
@ReckHou Okay wow, yeah same issue on a brand new project. What could be the cause? Any way around it besides reinstalling xcode?Livvy
Already we have two people with this problem. (after last update I get similar error) Currently I use AppCode until the next Xcode update with bug fixed. (My question #16113536)Atony
@IlyaIlin Thanks for that, seems as though there are 3 of us now. I should never have upgraded, it's not like it added anything new anyway. Looking into AppCode.Livvy
I'm experiencing the same thing here. Any of you guys figure out what was causing this?Eunuchoidism
@ChristianA.Strømmen Nope, I deleted xcode and reinstalled it, still the same. I think it might have something to do with command line tools. But haven't worked out how to remove them yet. For now I'm just putting up with it.Livvy
When you run the app in the Device, try going to Organizer in Xcode and checking the device console/logs for hints on what the problem could beAlphosis
@Alphosis I've updated the question. I checked the console logs, but couldn't get the app to crash again. Testing on a device seems to have corrected itself for now, and I don't have the logs from before.Livvy
OK.. is it exactly every other run that it crashes?Rhinencephalon
The only think I can think of is that it's not the same for the app to crash and to run. Are you hitting stop or hitting home on the device/sim and then stop. Does that effect the frequency of when it crashes? One difference is user defaults being written (when you hit home). There are others I'm sure. I would plaster the thing with NSLog's and narrow down exactly where it's crashing.Rhinencephalon
I assume you've deleted the app on the sim and not just are rewriting over top of it. I've had apps where a replacement to an asset isn't being overwritten in the bundle on the sim. Make sure to check in /Users/[youruser]/Library/Application Support/iPhone Simulator and show package contents on your app bundle to make sure all the proper versions of all your assets are there. Could be a lingering file.Rhinencephalon
@Rhinencephalon I've just ran through roughly 20 launches, and these were the results. I = Successful / X = Crash..... I I X I X I I X I X I X I I X I X I X I I X I I ---- "Lingering file" I'll check that nowLivvy
How are you exiting out when it does not crash? Hitting stop or home and then stop?Rhinencephalon
I'm hitting stop. Also, the same thing happens with new projects. So I don't believe it could be a remaining file issue. I'll test it with hitting home.Livvy
You create a totally fresh ios project using one of the templates and it does this? It's gotta be something screwy with your install. That actually makes more sense then some random bug.Rhinencephalon
Yeah that's what I'm thinking is happening. But I reinstalled everything. I even installed an older version of xcode and the same thing happens. Also, the app runs fine in the simulator, and device, only when not being run through the debugger. I also always get a "Build Succeeded" message, crash or not. This all started after installing command line tools then updating xcode. NSLogs and breaks wont work here, fails before it even begins. Even on new projects.Livvy
Hitting the stop button can cause all sorts of issues, since it kills the processes in an abnormal manner. Try this: get your app to run, then before hitting stop, press the home button on the device to background the app. Wait 10 seconds THEN hit stop. See if you can then run the app without it crashing. If so, you are killing a background task that probably has a handle to some resource in a bad state.Kaduna
Does this help: #3590131Phaih
Have you tried turning on zombies?Philine
I had this before and solved it by deleting the app in the simulator, and running again. If that doesn't work, start the simulator BEFORE running the app, so that it shows the home screen. THEN run the app.Mokpo
@Phaih Seems quite closely related to my issue, with it crashing before anything even begins, but I've already been through all the suggestions in that post.Livvy
@Vrol Nope, just tried that now, still crashes. I'm not doing anything different than I always have. After the recent updates, issues abound. But reverting back, hasn't seemed to help either. Pretty damn close to reinstalling the entire OS.Livvy
I started seeing the same after updating to OSX 10.8.4 earlier today. I had no problems with Xcode 4.6.2 on OSX 10.4.3. The problems seem to go away if I switch from LLDB to GDB, so it might be caused by the debugger (Xcode 4.6.2 LLDB in combination with OSX 10.8.4).Rectocele
I'm getting the same after an update to 10.8.4. Every other launch. Reset simulator, restart Xcode, makes no difference. Immediate crash in main(). Every other run. Thanks for the GDB idea - that's working here.Durware
T
74

Seems to be a combination of OS X 10.8.4 and LLDB. As kenster says, switching to GDB makes the problem go away.

Edit:
It's caused by a race condition in the debug server (I hear).

Here's a fix if you want to keep using LLDB: Instead of clicking Run while the app is already running in the simulator, kill it in Xcode (⌘-.), say "I love Xcode" 5 times and Run it again (⌘-R). It won't crash, I tested it.


Fixed in Xcode 4.6.3.

Thenceforward answered 5/6, 2013 at 21:25 Comment(5)
It doesn't reeeally work well. The launch pretty much chokes every other time. Switching to GDB is much more stable solution as for now until Apple fixes their stuff.Therrien
You and the asker are my new personal favorite people. This was driving me insane, to where I was about to send my MBP in for repairs.Cervelat
With 10.9 and Xcode 5, GDB has been removed and it's all LLDB now. But it all works as it should!Livvy
Argh! Going back to a deprecated compiler, just to fix a (really painful) bug in the brand-new-state-of-the-art compiler is a big problem… But no choice, I'll have to do it.Emmetropia
Updating to 4.6.3 did it - I didn't even know that version had been released.Retroact
C
11

I was having this issue as well. Take a look at this post. Xcode 4.6.2 app crashes on every second run

Basically change your debugger from LLDB to GDB. I can't believe this was due to LLDB being buggy.

Convulsive answered 5/6, 2013 at 13:30 Comment(2)
Oh My God.... Fixed. I'm so used to it that every time I run a project I keep getting ready to rage. But nothing happens. Thank's heaps. Will let Apple know in my bug report.Livvy
Thanks for the information, was driving me nuts all day yesterday. Why do I always wait until I've pulled out all my (remaining) hair before I search HERE! LOL.Recuperate
E
3

Switching to GDB or rebooting device/host does not solve the issue in my environment.

However, modifying the Run target in the associated XCode scheme to no longer launch automatically but instead to "Wait for HelloWorld.app to launch" did.

Only drawback is that this implies to manually start the application on the device. The debugger will then get connected.

Embodiment answered 30/9, 2013 at 12:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.