Crash when calling `LDClient.start` with large `startWaitSeconds` on Apple Silicon
borodindr opened this issue · 6 comments
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:
- Mac with Apple Silicon (M1, M2 etc)
- MacOS 14.4 or higher
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.
Library version
LaunchDarkly 9.8.0 and 9.8.1.
XCode and Swift version
- Xcode - reproduced on 15.4 and 15.3
- Swift - 5.9
- Run from MacOS 14.4 or higher with Apple Silicon
- Run destination - MacOS 14.4+ or any iOS
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)
@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.
Great! Thank you for the quick response.
@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.
@tanderson-ld version 9.8.2 was validated and the issue is fixed. Thank you!
@borodindr , thank you for positively confirming!