Crash on Nintendo Switch

未关闭 适合新手
#3 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
macos, swift
领域
backend, desktop

调研方向

首先在 SwiftMTP 代码中找到 int64FromAny,并追踪其结果如何用于总容量计算。报告显示,UInt64.max 在转换时会导致崩溃,而 Int64(exactly:) 可以避免崩溃;请检查相关测试,或为这个值添加一个针对性测试用例。完成标准是转换不再崩溃,并且无效/未设置标记不会破坏容量总值。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Swift
星标
481
派生
11
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Neighbor-Z/SwiftMTP 的其他 Issue

查看 Neighbor-Z/SwiftMTP 的全部 Issue

相似的 Issue

更多 Swift Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。