Skip to content

[Bug] EXC_BAD_ACCESS Fatal Crash in expo-iap ExpoIapModule #334

Description

@m-szczepanek

Library

expo-iap

Library version

expo-iap 3.4.9

Affected platform

iOS

Store

Onside (expo-iap only)

Environment

React Native

OS:
iOS 26.6
iOS 26.5.2
iOS 26.5
iOS 18.6.2

Devices:
iPhone 13 Pro Max
iPhone 14 Pro Max
iPhone 16 Pro Max
iPhone 15
iPhone 16

What happened?

App fatal crash after IAP for some users

Expected behavior

No fatal iOS crashes after IAP

Reproduction steps

After IAP purchase

Logs or stack trace

Crash signature

Sentry Log:

EXC_BAD_ACCESS KERN_INVALID_ADDRESS
mechanism: mach  |  handled: no  |  level: fatal  |  origin: ios (native)
Stack:
  closure in ExpoIapModule.definition   ← expo-iap
  ExpoIapHelper.setupStore
  swift::RefCounts<T>::doDecrementSlow  ← Swift ARC decrement
  _swift_release_dealloc
  swift_deallocClassInstance            ← crash: accessing freed object
  objc_destructInstance

doDecrementSlow + swift_deallocClassInstance + KERN_INVALID_ADDRESS is the classic Swift ARC use-after-free fingerprint: an object is being accessed after its memory has been reclaimed.

Possible cause of issue:

@MainActor
public final class ExpoIapModule: Module {
    nonisolated public func definition() -> ModuleDefinition {
        OnCreate {
            Task { @MainActor in          // ← captures `self` STRONGLY
                ExpoIapHelper.setupStore(module: self)
            }
        }
        OnDestroy {
            Task { @MainActor in          // ← captures `self` STRONGLY
                await ExpoIapHelper.cleanupStore()
            }
        }
    }
}

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    expo-iapexpo-iap libraryonsideOnside integration🐛 bugSomething isn't working📱 iOSRelated to iOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions