EXC_BAD_ACCESS (code=1, address=0x0) on modern apple devices #245

Open
opened 2025-12-29 18:24:52 +01:00 by adam · 12 comments
Owner

Originally created by @alabash on GitHub (Dec 4, 2018).

Hi!

I'm using your library in several projects and love it. It works great and the problem seems to occur only on new Apple devices which is a mystery for me. And only in development (release build configuration crashes too) while simple Adhoc or Testflight install works fine, like it never happened. I've tested on iPhone XR and iPhone XS Max, they both crash while iPad Air, iPad Air 2 and iPad Mini 2 work as expected. All the devices mentioned above are running under iOS 12.1.

I've isolated crashing code. It is pretty straightforward.

class User: CoreStoreObject {
    let userId = Value.Required<Int>("user_id", initial: 0)
    let name = Value.Optional<String>("name")
}

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        let dataStack = DataStack(
            CoreStoreSchema(
                modelVersion: "V1",
                entities: [
                    Entity<User>("User")
                ],
                versionLock: [
                    "User": [0x71f1c9576306cae1, 0x1cc9e7d27b8905bd, 0x90ecdf3454c60c44, 0xe4f0004dd40736de]
                ]
            )
        )

        do {
            try dataStack.addStorageAndWait(SQLiteStore(fileName: "DataStorage.sqlite", localStorageOptions: .recreateStoreOnModelMismatch))
        } catch {
            print(error.localizedDescription)
        }

        CoreStore.defaultStack = dataStack

        CoreStore.perform(
            asynchronous: { transaction in
                let user: User = transaction.create(Into<User>())
                user.userId .= 1
                user.name .= "Core Store"
            },
            success: { _ in
                
            },
            failure: { error in
                print(error.localizedDescription)
            }
        )
    }
}

image

Can you help? :)

Originally created by @alabash on GitHub (Dec 4, 2018). Hi! I'm using your library in several projects and love it. It works great and the problem seems to occur only on new Apple devices which is a mystery for me. And only in development (release build configuration crashes too) while simple Adhoc or Testflight install works fine, like it never happened. I've tested on iPhone XR and iPhone XS Max, they both crash while iPad Air, iPad Air 2 and iPad Mini 2 work as expected. All the devices mentioned above are running under iOS 12.1. I've isolated crashing code. It is pretty straightforward. ``` class User: CoreStoreObject { let userId = Value.Required<Int>("user_id", initial: 0) let name = Value.Optional<String>("name") } class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let dataStack = DataStack( CoreStoreSchema( modelVersion: "V1", entities: [ Entity<User>("User") ], versionLock: [ "User": [0x71f1c9576306cae1, 0x1cc9e7d27b8905bd, 0x90ecdf3454c60c44, 0xe4f0004dd40736de] ] ) ) do { try dataStack.addStorageAndWait(SQLiteStore(fileName: "DataStorage.sqlite", localStorageOptions: .recreateStoreOnModelMismatch)) } catch { print(error.localizedDescription) } CoreStore.defaultStack = dataStack CoreStore.perform( asynchronous: { transaction in let user: User = transaction.create(Into<User>()) user.userId .= 1 user.name .= "Core Store" }, success: { _ in }, failure: { error in print(error.localizedDescription) } ) } } ``` ![image](https://user-images.githubusercontent.com/892177/49413299-783df100-f780-11e8-8b67-16789fa631ba.png) Can you help? :)
adam added the ios/compiler buglooking for workarounds labels 2025-12-29 18:24:52 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Dec 4, 2018):

There's nothing that particularly stands out in your code and your screenshot so I'm not sure what's going on. By any chance, is your project's SWIFT_REFLECTION_METADATA_LEVEL Build Setting set to anything than All? Also, how are you importing Corestore, by Pod or through Carthage?

@JohnEstropia commented on GitHub (Dec 4, 2018): There's nothing that particularly stands out in your code and your screenshot so I'm not sure what's going on. By any chance, is your project's `SWIFT_REFLECTION_METADATA_LEVEL` Build Setting set to anything than `All`? Also, how are you importing Corestore, by Pod or through Carthage?
Author
Owner

@alabash commented on GitHub (Dec 4, 2018):

Thanks for the response. No, I didn't change it. Just checked it now it is set to "All". I'm using cocoapods.

@alabash commented on GitHub (Dec 4, 2018): Thanks for the response. No, I didn't change it. Just checked it now it is set to "All". I'm using cocoapods.
Author
Owner

@JohnEstropia commented on GitHub (Dec 4, 2018):

Hmm.. Does it happen to the mentioned devices on simulator as well?

@JohnEstropia commented on GitHub (Dec 4, 2018): Hmm.. Does it happen to the mentioned devices on simulator as well?
Author
Owner

@alabash commented on GitHub (Dec 4, 2018):

No, on the simulator it works ok, no crashes.

@alabash commented on GitHub (Dec 4, 2018): No, on the simulator it works ok, no crashes.
Author
Owner

@JohnEstropia commented on GitHub (Dec 5, 2018):

@evilgeniuz I recently bumped the Minimum Deployment Version in the develop branch. Can you try pointing your Pod to that branch and see if the behavior changes? (I am assuming your app is at iOS 10+ as minimum deployment version, though)

@JohnEstropia commented on GitHub (Dec 5, 2018): @evilgeniuz I recently bumped the Minimum Deployment Version in the `develop` branch. Can you try pointing your Pod to that branch and see if the behavior changes? (I am assuming your app is at `iOS 10+` as minimum deployment version, though)
Author
Owner

@alabash commented on GitHub (Dec 5, 2018):

Unfortunately the same. Gives error on XR and no errors on iPad mini 2.

@alabash commented on GitHub (Dec 5, 2018): Unfortunately the same. Gives error on XR and no errors on iPad mini 2.
Author
Owner

@JohnEstropia commented on GitHub (Dec 6, 2018):

I've reproduced the issue using the CoreStoreDemo app. It looks like this issue was first in Xcode 10.1: https://github.com/wordpress-mobile/WordPress-iOS/issues/10389

Still investigating...

@JohnEstropia commented on GitHub (Dec 6, 2018): I've reproduced the issue using the CoreStoreDemo app. It looks like this issue was first in Xcode 10.1: https://github.com/wordpress-mobile/WordPress-iOS/issues/10389 Still investigating...
Author
Owner

@JohnEstropia commented on GitHub (Dec 6, 2018):

@evilgeniuz Do you have a released version of the app built with Xcode 10.1? Do you see these crashes there?

@JohnEstropia commented on GitHub (Dec 6, 2018): @evilgeniuz Do you have a released version of the app built with Xcode 10.1? Do you see these crashes there?
Author
Owner

@alabash commented on GitHub (Dec 6, 2018):

Yeah, just checked it, crashes in 10.1 and in 10.0 works ok.

@alabash commented on GitHub (Dec 6, 2018): Yeah, just checked it, crashes in 10.1 and in 10.0 works ok.
Author
Owner

@JohnEstropia commented on GitHub (Dec 10, 2018):

Looks like we'll just have to wait for an update or use Xcode 10.0 for now. Related issues:
https://github.com/realm/realm-cocoa/issues/6013
https://github.com/wordpress-mobile/WordPress-iOS/pull/10400

@JohnEstropia commented on GitHub (Dec 10, 2018): Looks like we'll just have to wait for an update or use Xcode 10.0 for now. Related issues: https://github.com/realm/realm-cocoa/issues/6013 https://github.com/wordpress-mobile/WordPress-iOS/pull/10400
Author
Owner

@alabash commented on GitHub (Dec 10, 2018):

Yeah, using 10.0 for now everywhere. ありがとう!

@alabash commented on GitHub (Dec 10, 2018): Yeah, using 10.0 for now everywhere. ありがとう!
Author
Owner

@Miggets7 commented on GitHub (Dec 16, 2018):

Have the same issue, only when using a physical device in debugging mode. Even on a iPhone 5s. Thought to just mention it.

@Miggets7 commented on GitHub (Dec 16, 2018): Have the same issue, only when using a physical device in debugging mode. Even on a iPhone 5s. Thought to just mention it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#245