Strange Crashes in iOS 16.4.1 and higher

This crash only happens in release configuration and only on devices running somewhere between 16.3 and 16.4 or higher. It is happening with a few of my different singleton classes in an Obj-C project. What's more strange is that the related code sections work fine up until a Bluetooth Low Energy connection is made. This is an older codebase and will be getting replaced with a complete rewrite in the next few months, but I need to resolve this crash in the meantime. Seems like something changed with ARC or some other system under the hood as the production build which has been fine for a long time exhibits this issue. The singleton call is the only place alloc is called for the DWNotificationView class in the project.

If I change the optimization level of the release build to 'None [-O0]' then everything works again. It also works if I set the optimization level to [-Ofast].

Since there's no clear explanation, I would make 2 changes to see if they fix the issue:

  1. static DWNotificationView *singleton = nil; //nil and NULL are supposed to be the same but nil is preferred for objects in Obj C

  2. if (singleton == nil) //this also shouldn't matter but you never know if fast optimization is picky

Strange Crashes in iOS 16.4.1 and higher
 
 
Q