launchdarkly / ios-client-sdk

LaunchDarkly Client-side SDK for iOS (Swift and Obj-C)
https://docs.launchdarkly.com/sdk/client-side/ios
Other
68 stars 82 forks source link

Crash when calling `LDClient.start` with large `startWaitSeconds` on Apple Silicon #392

Closed borodindr closed 3 weeks ago

borodindr commented 4 weeks ago

Describe the bug When calling LDClient.start method with startWaitSeconds greater than 15, app crashes when it is trying to log the message. Happens only when a project running on Apple Silicon Mac with MacOS 14.4 or higher. Please don't be confused with Run Destination, it can be any.

To reproduce Required equipment:

Call the following anywhere on app launch:

let config = LDConfig(mobileKey: "key", autoEnvAttributes: .disabled)
LDClient.start(config: config, startWaitSeconds: 60)

Expected behavior Log message is displayed and the app continue to work.

Logs Screenshot of the crash:

Screenshot 2024-06-05 at 7 21 32 PM

Library version LaunchDarkly 9.8.0 and 9.8.1.

XCode and Swift version

Platform the issue occurs on All platforms if project ran from Xcode on MacOS 14.4 or higher with Apple Silicon

Additional context When calling os_log in LDClient.start method (line 792 in LDClient.swift file), the message has 3 parameters: %s, %d and %s or string, decimal and string. But then arguments passed are String, Double and Double. On older MacOS versions, if argument type doesn't match, it will log (null) but starting from MacOS 14.4 on Apple Silicon it produces an exception.

Possible solution could be changing the third argument in the log message from %s to %d like below:

os_log("%s LDClient.start was called with a timeout greater than %d seconds. We recommend a timeout of less than %d seconds.", log: config.logger, type: .debug, self.typeName(and: #function), LDClient.longTimeoutInterval, LDClient.longTimeoutInterval)
tanderson-ld commented 4 weeks ago

@borodindr , thank you for reporting this and we appreciate the extra info you collected. We will take a look and release a fix when ready.

tanderson-ld commented 3 weeks ago

A PR has been opened for this issue and will be merged/released in the next few days.

borodindr commented 3 weeks ago

Great! Thank you for the quick response.

tanderson-ld commented 3 weeks ago

@borodindr , version 9.8.2 has been released and this issue should be fixed. I wasn't able to reproduce the issue myself since I don't have that specific device. Please let us know whether or not this resolves the issue for you. Thank you.

borodindr commented 3 weeks ago

@tanderson-ld version 9.8.2 was validated and the issue is fixed. Thank you!

tanderson-ld commented 3 weeks ago

@borodindr , thank you for positively confirming!