简体   繁体   English

在Xcode中使用NSTask在AppKit应用程序中运行时,Rust 1.4.0(或更高版本)货物/铁锈崩溃

[英]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; 当前状态是;

  • A command-line program with NSTask. 使用NSTask的命令行程序。 This works fine. 这很好。
  • An AppKit app with NSTask. 带有NSTask的AppKit应用。 This always crashes. 这总是崩溃。
  • An AppKit app just only links to AppKit. AppKit应用程序仅链接到AppKit。 No actuall AppKit code in app. 应用中没有实际的AppKit代码。 Also crashes. 也崩溃了。
  • AppKit app wrote in Objective-C. AppKit app用Objective-C编写。 Also crashes. 也崩溃了。
  • AppKit app that runs cargo with BSD level pty instead of NSTask. AppKit应用程序,该应用程序以BSD级别pty而非NSTask运行货物。 Works fine. 工作正常。

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

TL;DR TL; DR

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

Explanation 说明

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.

相关问题 NSTask在xcode运行中工作,但当我在xcode外部运行时无法运行 - NSTask works in xcode run but not when i run it outside xcode 当从 xcode 运行时,使用 NSTask 的 Swift 2.1 OSx shell 命令工作,但在导出时不起作用 - Swift 2.1 OSx shell commands using NSTask work when run from xcode, but not when exported 在功能中使用时NSTask崩溃 - NSTask crashes when used in function 在iPad 7.1上运行时,Xcode 6 Beta使用核心数据使应用程序崩溃 - Xcode 6 Beta crashes app using core data when run on iPad 7.1 当我在真实设备上运行应用程序时,Xcode崩溃 - Xcode crashes when i run the app on my real device Xcode 4.6.2应用程序每运行两次便崩溃 - Xcode 4.6.2 app crashes on every second run 当应用程序在设备上的 Xcode 中运行时,MKMapView 使应用程序崩溃,但如果通过应用程序图标点击在设备上运行则不会 - MKMapView crashes the app when app is run in Xcode on a device but not if running on device by application icon tap 将应用分发到应用商店时,Xcode崩溃 - Xcode crashes when distributing app to app store React Native 应用程序在从 Xcode 运行时工作,但在使用“react-native run-ios”运行时崩溃 - React Native app works when run from Xcode, but crashes when run with 'react-native run-ios' 验证或提交应用档案时Xcode 6崩溃 - Xcode 6 crashes when validating or submitting app archive
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM