pkamb
pkamb

Reputation: 35002

App crashing with SIGABRT in `once.h` on definition of `dispatch_once`

I'm suddenly getting a SIGABRT in dispatch_once as shown in Xcode below.

No changes have been recently added that use dispatch_once.

dispatch_once(predicate, block); Thread 1: signal SIGABRT

SIGABRT in dispatch_once

#if DISPATCH_ONCE_INLINE_FASTPATH
DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
DISPATCH_SWIFT3_UNAVAILABLE("Use lazily initialized globals instead")
void
_dispatch_once(dispatch_once_t *predicate,
        DISPATCH_NOESCAPE dispatch_block_t block)
{
    if (DISPATCH_EXPECT(*predicate, ~0l) != ~0l) {
        dispatch_once(predicate, block);
    } else {
        dispatch_compiler_barrier();
    }
    DISPATCH_COMPILER_CAN_ASSUME(*predicate == ~0l);
}
#undef dispatch_once
#define dispatch_once _dispatch_once
#endif
#endif // DISPATCH_ONCE_INLINE_FASTPATH

Upvotes: 6

Views: 2823

Answers (3)

pkamb
pkamb

Reputation: 35002

In my case this issue occurred when a Storyboard and Class files were added to the project, and automatically added to the main Target, but not added to the Target Membership of the secondary Target.

The issue only occurred in the iOS Simulator, using the Target we use specifically for the simulator.

The issue was not caught by the compiler due to no real references to the class. Instead, a stringly-typed reference to the Storyboard name was used to construct the view:

[UIStoryboard storyboardWithName:@"storyboardFileThatWasNotAddedToThisTarget" bundle:nil];

Fixed by adding the new files to the secondary Target:

Add Target Membership to secondary Target

Found issue by adding an Exception Breakpoint to the Xcode debugger.

Upvotes: 1

Sazzad Hissain Khan
Sazzad Hissain Khan

Reputation: 40236

I was using Realm and the crash happens when I updated the Xcode but pod was not updated. Make sure you update your pods using,

pod repo update
pod update

If you get permission issue run with sudo.

From realm website,

Realm model properties must have the @objc dynamic var attribute to become accessors for the underlying database data. Note that if the class is declared as @objcMembers (Swift 4 or later), the individual properties can just be declared as dynamic var.

Upvotes: 1

BuguiBu
BuguiBu

Reputation: 1625

In my case it was caused, but no confirmed by logs or exception traces, by the use of KeychainItemWrapper, as recommended here. I dropped that old class and replaced it with the modern solution SAMKeychain.

Upvotes: 1

Related Questions