I maintain a macOS application. Some users (but not all) report an issue (I suspect, those running Catalina), where the first time the app is launched, it crashes. All future launches work okay.

I've managed to reproduce this, and it's crashing in the argument parsing code. My suspicion is that Gatekeeper is passing some unusual argument on the first launch (the one where it shows the 'this is an application downloaded from foo.com' dialog).

The argument-parsing code is pretty robust : it already rejects bogus arguments, so there must be something very unusual being passed. The problem is my local builds don't show the problem, and I don't know to reset the quarantine flag to trigger the fault again. (Also of course the crashes are in release builds, so the crash trace doesn't give me an exact location)

If I could trigger the quarantine warning artificially, by marking a local debug build as 'newly downloaded', I suspect this would be trivial to debug.


Okay, found a way to test this on a debug build, and figured it out. My solution was to copy the com.apple.quarantine xattr onto the debug binary which XCode creates, and then test this via 'open'. (Launching via Terminal never showed the issue)

This reveals that when launched with the quarantine flag set, the command line contains a 'NULL' as the second arg; i.e argc=2, argv[0]=, argv[1]=0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .