Skip to content

NaN crash Encodable.toString(pretty:) #264

@cprince-foreflight

Description

@cprince-foreflight

Describe the bug
We are getting production app crash reports here with the toString. Crashlytics is reporting it as:

Encodable.toString(pretty:)
NSInvalidArgumentException - NaN number in JSON write

With more detail:
Screenshot 2023-10-26 at 12 12 55 PM

To Reproduce
So far I don't have a clear repro case. But, we have 34 crash events affecting 30 users.

It looks like some our custom data being added to dictionary payloads has NaN numeric (NSNumber) values. And that is making it through the JSON tests (e.g., here), but later somehow causing the JSONDecoder to crash.

I can't actually show that above idea with an actual crash in our development build though, so that's just my best guess so far.

Expected behavior
I wouldn't expect the JSONDecoder usage in JSON.swift to cause an app crash.

Screenshots
See above.

Platform (please complete the following information):

  • Library Version in use: 1.4.7
  • Platform being tested: iOS and iPadOS-- most crashes are on iPad, but many of our users are on iPad also.
  • Integrations in use: Firebase

Additional context
I'd like to resolve this ASAP. I'm hoping to get a patch into our production app. Thanks.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions