Jassertfalse on mac

Hey all!.,

jassertfalse on mac seems to kill the application anytime (i remember this was not always the case (not sure)), on windows i’m able to continue the debugging.
Is there any chance to change the behavior?

xcode 3.2.6

I noticed this too, I think its because the jassert got changed to use assert() rather than Debugger() for some XCode 4 compatibility. Does assert() SIGABRT on XCode 4 as well? Is this perhaps a compiler option somewhere?

Yeah, I had to change it to assert() because the old version didn’t work any more in Xcode 4. No idea how to change it to make it continuable - if anyone has a suggestion, please let me know!

You can still use Debugger in Xcode 4, you just have to set the appropriate option. It’s a per-scheme option (although I think there’s a global default for new projects/schemes somewhere). Edit your scheme, select the Run action, go to the Diagnostics tab, and check the last checkbox: “Stop on Debugger() and DebugStr()”.

The other problem with Debugger is that it’s been deprecated, legacied, and by 10.7 I think even removed from the public CoreServices headers. But it’s always (at least on Intel, but I think on PPC as well) just called kill(getpid(), SIGINT). So jassert can just do that directly.

Of course another option is to have jassert decide whether to send SIGINT or SIGABRT based on some combination of the P_TRACED flag, the SIGINT handler, and… well, I’m not sure exactly how you’d decide, but if the JUCE user could override that with a runtime call or -D or env variable or something it wouldn’t have to guess perfectly. (It might actually be worth having jassert send a different signal, and install a handler for that which decides whether to forward to SIGINT or SIGABRT, so the point of customization is just replacing the first handler?)

Thanks. Actually, looking at the code, on iOS and Linux I was already using kill (0, SIGTRAP) - Tried using the same code in OSX and it works just fine, so not sure why I didn’t just use that in the first place!


::kill (0, SIGTRAP);

isn’t working for me on 10.7.3 with Xcode 4.3. I get the assert message written to the console and then OSX throws up the ‘yourApp quit unexpectedly’ (Ignore/Report/Reopen etc).

asm(“int $3”);
DOES work however, and lets you continue past the assert too…

(though this won’t work on PPC apparently, according to: stackoverflow.com/questions/37299/xcode-equivalent-of-asm-int-3-debugbreak-halt )


[edit] this is using the LLDB debugger btw… (which appears to now be the default), maybe that explains the difference?

For fuck’s sake, every version of Xcode seems to behave differently…! What do Apple use for their assertions?

1 Like

I think they have a poor chinese at Foxconn that stops the execution manually. 8)

What’s the current “best practice” for Mac asserts? I get messages on the console but no stopping with Xcode 4.3.2…

Eh? That’s what I use, and it definitely stops.

Debugger() do not work ?

jassert doesn’t stop regardless of whether I have the Debugger() option checked or not. Hmm…