Skip to content

NSDictionary's serializableDeepCopy does not catch Infinite Double/Float values, causes crash #1045

@dfed

Description

@dfed

This repo does a good job of transforming Dictionary types from non-JSON-compatible types to JSON-compatible types prior to sending analytics dictionaries to your backend via the serializableDeepCopy method.

However, if an infinite Double or Float value (created by dividing a Double or Float by zero) slips through the serializableDeepCopy method. The result of sending an infinite value is that this repo crashes with the error SIGABRT (#0): Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid number value (infinite) in JSON write'. Worse yet, this crash happens on Segment's own queue, making it difficult for teams to find the source of the corrupted log. Here's a screen grab from the stack trace showing Segment on its own queue:
image

Ideally, this repo would detect an Infinite value as part of -[NSDictionary serializableDeepCopy:] and either crash (since this method is called synchronously from -[SEGAnalytics track:properties:options:], crashing here would yield a stack trace can help identify the source of the bad log) or remove/modify the infinite value.

Let me know which approach seems reasonable to you – I'd be happy to create a PR with a fix here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions