【问题标题】:Swift 5 Ubuntu 16.04 Crash with dateComponentsSwift 5 Ubuntu 16.04 与 dateComponents 崩溃
【发布时间】:2019-06-12 05:08:23
【问题描述】:

这是我的代码:

import Foundation

if let utc = TimeZone(abbreviation: "UTC") {
    let calendar = Calendar.current
    print("\(calendar.description)")
    print("Before dateComponents")
    let componentsDate1 = calendar.dateComponents(in: utc, from: Date())
    print("\(componentsDate1)")
}
else {
    print("Could not create timezone")
}

我在 Docker 下的 Ubuntu 16.04 上运行。结果是:

gregorian (current)
Before dateComponents
Segmentation fault

看起来 dateComponents 调用正在崩溃。

我的 Docker 容器基于 https://github.com/apple/swift-docker/blob/0aafffef619fb3b1824c968cbbe2fba4ba41bd26/5.0/ubuntu/16.04/Dockerfile

建议?


更新 1) 我刚刚在 Virtual box 下运行的 Ubuntu 16.04 系统上复制了这个,并安装了适用于 Ubuntu 16.04 的 Swift 5.0.1 版本:https://swift.org/builds/swift-5.0.1-release/ubuntu1604/swift-5.0.1-RELEASE/swift-5.0.1-RELEASE-ubuntu16.04.tar.gz

【问题讨论】:

  • 仅供参考 - 这在 macOS 上的 Xcode 中运行的 Swift Playground 中运行良好。所以这似乎是 Ubuntu 或 Linux 下 Swift 特有的问题。
  • Linux 上的 Calendar.datecomponents 似乎存在一些错误,bugs.swift.org/browse/SR-7011
  • @JoakimDanielson 该问题在16 Aug 2018 12:34 PM 上标记为已解决。

标签: swift docker swift5 server-side-swift


【解决方案1】:

我刚刚被告知这确实是一个已知的错误,具有已知的当前修复: https://forums.swift.org/t/possible-bug-in-datecomponents-method-running-on-ubuntu-16-04/25702

【讨论】:

    猜你喜欢
    • 2017-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-08
    • 2016-08-16
    • 2018-03-12
    • 1970-01-01
    相关资源
    最近更新 更多