HKWorkout crashes on instantiation when metadata contains HKWeatherCondition enum > 27
| Originator: | dloewenherz | ||
| Number: | rdar://29840806 | Date Originated: | 02-Jan-2017 10:54 AM |
| Status: | Open | Resolved: | |
| Product: | iOS + SDK | Product Version: | 10.2 |
| Classification: | Serious Bug / Crash | Reproducible: | Always |
Area: HealthKit Summary: Instantiating an HKWorkout instance containing metadata with a HKWeatherCondition value above 27 causes a crash to occur. Steps to Reproduce: 1. Download the attached project (Radar2Jan2017.zip). 2. Build and run on an iPhone simulator. Expected Results: No crash occurs and the HKWorkout object on AppDelegate.swift L23 is created. Actual Results: The attached crash (Radar2Jan2017.crash) occurs on line 23. Version: iOS 10.2 (14C92) Notes: I discovered this issue when a user emailed me regarding a crash in the app my company publishes (Health Data Importer). Their health export.xml contained this entry for a workout: <MetadataEntry key="_HKPrivateWeatherCondition" value="29"/> Health Data Importer then sets the value for the HKMetadataKeyWeatherCondition key on the workout metadata to an NSNumber containing the value 29. Looking at the public API for HKWeatherCondition, the enum tops out at 28 values. For now, my code simply checks if the value is >27 and skips the key if that is the case. Configuration: iPhone 64GB T-Mobile Attachments: 'Radar2Jan2017.crash' and 'Radar2Jan2017.zip' were successfully uploaded.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!