Re: Break on assert


Carl Hoefs
 

On Nov 5, 2020, at 4:35 PM, Jens Alfke <jens@mooseyard.com> wrote:

On Nov 1, 2020, at 6:28 PM, Bernie Maier <apple-dev@worklists.blurk.net> wrote:

It's possible that this is not actually an assertion / exception in the runtime sense. There's nothing stopping developers from "helpfully" documenting their assumptions (i.e. asserting their assumptions) with a simple log message with the literal text "[Assert] some dev message".
Right. There's no single notion of what an "assertion" is — it's just a boolean test that does Something if it fails. The "Something" could be throwing an exception (Obj-C, C++), raising a SIGABORT signal (C), or whatever else. I'm not actually sure what Swift does to abort.

I don't think I've seen an assertion before that logs "[Assert] …" so this doesn't seem to be any of the usual suspects like NSAssert or C's assert().
Indeed, I did try setting a break on all manner of things - assert, print, logv, slog, puts, NSException raise, "on throw", etc., even Swift break points - about 2 dozen break points in all, but never caught it. I don't know how that message gets generated!

I did discover a situation in which I presented an NSAlert panel from a non-main thread. When I fixed that, the "assert" also stopped. So for posterity, the "[Assert] Cannot be called with asCopy = NO on non-main thread" message is a tipoff to that end.

-Carl

Join xcode@apple-dev.groups.io to automatically receive all group messages.