linux - IBM Swift Sandbox 的超时时间是多少?

标签 linux swift ibm-swift-sandbox

我在尝试在 IBM's Swift Sandbox 上运行代码时遇到问题导致某种内部超时。

Swift Ver. 3.0.1 (Release)
Platform: Linux (x86_64)
Error running code: 
WARNING: Your kernel does not support swap limit capabilities, memory limited without swap.
/swiftfiles/doit.sh: line 51:    42 Illegal instruction     timeout ${TIMEOUT} .build/debug/TempCode

有问题的代码正在解码一个大的 Base64 编码字符串:

let base64EncodedInput = [really really long string]

let inputData = Data(base64Encoded: base64EncodedInput)!

let inputDecodedString = String(data: inputData, encoding: .utf8)!

let rowArray = inputDecodedString.components(separatedBy: "\n")

可以看到完整的数据串,在线运行代码here .

我是否用尽了分配给 Swift 进程的时间?什么是超时?

最佳答案

为了回答标题中的问题,我们实现了十秒的硬超时,但如果内存耗尽或堆栈溢出,代码可能会被更快地终止。但这并不是您在这里看到的问题。

经过一些调查,我们确定在您的沙盒链接中创建超大字符串的 base 64 编码服务使用 \r\n 作为换行符而不是 \n。当您使用 let rowArray = inputDecodedString.components(separatedBy: "\n") 时,这会导致错误,这似乎是 Foundation 中的错误。如果您改为使用 let rowArray = inputDecodedString.components(separatedBy: "\r\n"),您应该会看到您的问题消失了。同时,我们将向 Foundation 提交问题。

您看到 timeout 的原因是因为我们返回了一条不太好的错误消息。 timeout ${TIMEOUT} .build/debug/TempCode 行是我们如何执行 Sandbox 用户代码的一部分,当该行失败时,我们将其作为错误消息的一部分返回。我们将致力于为将来减少混淆的错误消息。

编辑:事实证明这是一个已知错误。 https://bugs.swift.org/browse/SR-2483

关于linux - IBM Swift Sandbox 的超时时间是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40955047/

相关文章:

linux - 为什么我会收到 "implicit declaration of function ' ndo_get_stats“错误?

ios - pangestures 交互就像 iOS 中的邮件应用程序

swift - 无法在 IBM Swift Sandbox 中保存或加载我的代码

linux - 如何将多行输出连接到一行?

linux - 谷歌浏览器 Linux 的永久标志

c++ - C++中的简单客户端服务器程序无法正常工作

swift - 在 NSUserDefaults 中存储可选的 bool

Swift 通过 unicode 将国家代码转换为表情符号标志

linux - IBM Swift 沙盒 : Running NSURLSession: Error running code: unknown error code 132