Skip to content

Crash on Nintendo Switch #3

@bexonpak

Description

@bexonpak

Operating on Nintendo Switch:

System Settings -> Data Management -> Manage Screenshots and Videos -> Copy to a Computer via USB Connection

Log:

private func int64FromAny(_ any: Any?) -> Int64? {
  switch any {
    case let v as Int64: return v
    case let v as UInt64: return Int64(v)     <- Thread 1: Fatal error: Not enough bits to represent the passed value
    case let v as Int: return Int64(v)
    case let v as Double: return Int64(v)
    case let v as Float: return Int64(v)
    case let v as NSNumber: return v.int64Value
    default: return nil
  }
}
(lldb) po v
18446744073709551615

After switching to the following approach, it no longer crashes:

case let v as UInt64: return Int64(exactly: v)

The value 18446744073709551615 (UInt64.max) returned by the Nintendo Switch usually indicates an "invalid/unset" marker value, but returning it as such would break the total capacity calculation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions