Here is a simple program that should not crash. (Amazingly, it runs fine in Xcode Version 26.2 (17C52).) I am running Tahoe 26.2.
- Output
[I] release> ./subprocess-issue
Hi
Swift/ErrorType.swift:254: Fatal error: Error raised at top level: Failed to spawn the new process with underlying error: UnderlyingError(rawValue: 20)
fish: Job 1, './subprocess-issue' terminated by signal SIGTRAP (Trace or breakpoint trap)
- Swift
[I] SubprocessIssue> swift --version
swift-driver version: 1.127.14.1 Apple Swift version 6.2.3 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)
Target: arm64-apple-macosx26.0
- Program Structure
[I] SubprocessIssue> tree -L 2
.
โโโ Package.resolved
โโโ Package.swift
โโโ Sources
โโโ SubprocessIssue
- Program Package
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "SubprocessIssue",
platforms: [.macOS(.v26)],
dependencies: [
.package(url: "https://github.com/swiftlang/swift-subprocess.git", branch: "main")
],
targets: [
.executableTarget(
name: "subprocess-issue",
dependencies: [
.product(name: "Subprocess", package: "swift-subprocess")
]
)
]
)
- Program Code
import Subprocess
@main
struct SubprocessIssue {
static func main() async throws {
print("Hi")
let _ = try await run(.name("ls"), output: .discarded)
print("Goodbye")
}
}
- Build
[I] SubprocessIssue> rm -rf .build .swiftpm
[I] SubprocessIssue> swift build -c release
... bla bla ...
Building for production...
<module-includes>:1:9: note: in file included from <module-includes>:1:
1 | #import "process_shims.h"
| `- note: in file included from <module-includes>:1:
2 | #import "target_conditionals.h"
3 |
/Users/po/ZLocal/ZDev/Swift/Play/SubprocessIssue/.build/checkouts/swift-subprocess/Sources/_SubprocessCShims/include/process_shims.h:44:5: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
42 |
43 | int _subprocess_pthread_create(
44 | pthread_t * _Nonnull ptr,
| |- warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified)
| |- note: insert '_Nullable' if the pointer may be null
| `- note: insert '_Nonnull' if the pointer should never be null
45 | pthread_attr_t const * _Nullable attr,
46 | void * _Nullable (* _Nonnull start)(void * _Nullable),
[11/11] Linking subprocess-issue
Build complete! (8.60s)
- Output from debugger
[I] debug> ls -lF | grep "*"
-rwxr-xr-x 1 po staff 2137616 Jan 22 09:02 subprocess-issue*
[I] debug> ./subprocess-issue
Hi
Swift/ErrorType.swift:254: Fatal error: Error raised at top level: Failed to spawn the new process with underlying error: UnderlyingError(rawValue: 20)
๐ฃ Program crashed: System trap at 0x000000019e5b59d4
Platform: arm64 macOS 26.2 (25C56)
Thread 0 crashed:
0 0x000000019e5b59d4 _assertionFailure(_:_:file:line:flags:) + 176 in libswiftCore.dylib
1 0x000000019e661f8c swift_errorInMain + 604 in libswiftCore.dylib
...
Backtrace took 0.57s
fish: Job 1, './subprocess-issue' terminated by signal SIGTRAP (Trace or breakpoint trap)