You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash logging a GATT error: OSLog helper passes 6+ arguments as one #116
G7PeripheralManager.reportGattError (G7PeripheralManager.swift:480, from 0338684) logs with six format arguments:
log.error("[gatt] %{public}@ error on %{public}@ — %{public}@ (%{public}@#%d)%{public}@",what,characteristic.uuid.uuidString,error.localizedDescription,ns.domain,ns.code,tag)
The OSLog helper (G7SensorKit/OSLog.swift) spreads only up to five arguments. Anything more falls into default:, which passes the whole [CVarArg] array on as a single argument:
default:
os_log(message,log:self,type:type,args)
The array is bridged to one NSArray, so os_log fills the first placeholder with it and reads the other five from garbage memory. As a result, any error in peripheral(_:didUpdateNotificationStateFor:error:) or peripheral(_:didUpdateValueFor:error:) crashes the app: both report it through reportGattError.
Crash (Trio with G7SensorKit at #114, which doesn't touch this code; iOS Simulator with g7sim over ImpossiBLE, with the g7sim sensor set to "stopped" in its config, tapping Pair Sensor Directly from an eavesdropping session):
Nothing in this is specific to the Simulator: on a phone, any error a sensor reports in these callbacks takes the same path. It's the only call site with more than five arguments today.
Possible fixes, whichever you prefer:
Add a case 6 to the helper.
Fold tag into the message so the call stays at five arguments.
Either way, make default: safe: for example, log the format string and the argument count instead of passing the array on. A future 7+ argument call then can't crash. G7SensorKitUI/OSLog.swift and G7SensorPlugin/OSLog.swift have the same default:.
Activity
ps2 commentedon Nov 8, 2026
Fixed in #117 (next-dev). Thanks for the clear analysis.
Don't crash logging a GATT error
Don't crash logging a GATT error