[英]Rust 1.4.0 (or later) cargo/rustc crashes when run in an AppKit app using NSTask in Xcode
Rust 1.4.0 installation with multirust runs fine on command line, but crashes with signal 11 if it was being executed by NSTask in Apple AppKit. 使用multirust进行Rust 1.4.0安装可以在命令行上正常运行,但是如果信号被Apple AppKit中的NSTask执行,则会崩溃并显示信号11。
I wrote some test cases to reproduce them. 我写了一些测试用例来重现它们。 Current state is; 当前状态是;
This issue equally occurs Rust installation by building from source using Homebrew. 通过使用Homebrew从源代码构建,同样会出现Rust安装问题。 This issue does not occur with Rust 1.2.0 cargo and rustc. Rust 1.2.0货物和rustc不会发生此问题。 They worked fine. 他们工作得很好。 This DOES NOT occur if the app runs out of Xcode debugger. 如果应用程序用完了Xcode调试器,则不会发生这种情况。 So main reason seems to be the Xcode debugging context. 因此,主要原因似乎是Xcode调试上下文。 It seems it is setting something wrong... Running the app with command-line LLDB DOES NOT cause the issue. 似乎设置有问题...使用命令行LLDB运行应用程序不会导致此问题。 Ah... 啊...
I am using Xcode 7.1.1. 我正在使用Xcode 7.1.1。
Test code can be downloaded from here: https://github.com/eonil/Rust140InAppKitCrashTestCases 可以从此处下载测试代码: https : //github.com/eonil/Rust140InAppKitCrashTestCases
Before you launch NSTask
, do this. 在启动NSTask
之前,请执行此操作。
var envs = NSProcessInfo.processInfo().environment;
envs["DYLD_LIBRARY_PATH"] = nil
// print(NSProcessInfo.processInfo().environment["DYLD_LIBRARY_PATH"])
_remoteTask = NSTask()
_remoteTask.environment = envs
Sometimes Xcode overrides DYLD_LIBRARY_PATH
environment variable to a non-system directory (something like "/Users/Eonil/Workshop/Temp/Xcode/Derivations/EditorOnly-hfhkxuguvplpqvdcinldyuivhucp/Build/Products/Debug:/usr/lib/system/introspection"
) 有时Xcode DYLD_LIBRARY_PATH
环境变量覆盖到非系统目录(例如"/Users/Eonil/Workshop/Temp/Xcode/Derivations/EditorOnly-hfhkxuguvplpqvdcinldyuivhucp/Build/Products/Debug:/usr/lib/system/introspection"
)
And this environment variable is inherited as is to the NSTask
instance because .environment
was not set and remained as nil
. 由于未设置.environment
并将其保留为nil
,因此该环境变量将继承NSTask
实例。
The cleanest solution would be setting all needed environment variables carefully. 最干净的解决方案是仔细设置所有需要的环境变量。
I couldn't find a switch to turn off this Xcode behaviour. 我找不到开关来关闭此Xcode行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.