-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
Description
Description
When I run wasmkit run --dir . --dir / <Wasm binary>
, it succeeds or fails randomly. When I use --dir .build --dir /
or --dir . --dir /Users
instead, it always succeeds. So I think --dir .
and --dir /
conflict with each other.
Steps to reproduce
-
Run
mkdir foo && cd foo
-
Run
swift package init --type library
-
Edit
Sources/foo/foo.swift
import Foundation @main struct foo { static func main() { print(try! String(contentsOf: URL(filePath: #filePath), encoding: .utf8)) print(Bundle.main) } }
-
Run
swift build --swift-sdk swift-DEVELOPMENT-SNAPSHOT-2025-10-02-a_wasm
-
Run
wasmkit run --dir . --dir / .build/wasm32-unknown-wasip1/debug/foo.wasm
several times
Expected behavior
It succeeds every time. Or it fails every time with the same error messages.
Actual behavior
It always fails, but its error messages randomly change each time it is executed.
Pattern 1:
import Foundation
@main
struct foo {
static func main() {
print(try! String(contentsOf: URL(filePath: #filePath), encoding: .utf8))
print(Bundle.main)
}
}
Error: Trap: unreachable
0: $s10Foundation6BundleC05_mainB033_6273FB07A96EB35BCC520B3A80F5C3CDLL_WZ
1: swift_once
2: $s10Foundation6BundleC4mainACvgZ
3: $s3fooAAV4mainyyFZ
4: $s3fooAAV5$mainyyFZ
5: main
6: __main_void
7: _start
8: unknown
Pattern 2:
foo/foo.swift:9: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file doesn’t exist."UserI
nfo={NSFilePath=/Users/kebo/foo/Sources/foo/foo.swift, NSURL=file:///Users/kebo/foo/Sources/foo/foo.swift, NSUnderlyingError=Error Domain=NSPOSIXErro
rDomain Code=44 "No such file or directory"}
Error: Trap: unreachable
0: $ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF
1: swift_unexpectedError
2: $s3fooAAV4mainyyFZ
3: $s3fooAAV5$mainyyFZ
4: main
5: __main_void
6: _start
7: unknown
Environemnt
$ uname -a
Darwin Xylotrupes-gideon.local 25.1.0 Darwin Kernel Version 25.1.0: Sun Oct 5 21:11:28 PDT 2025; root:xnu-12377.40.120~10/RELEASE_ARM64_T8132 arm64
$ which swift
/Users/kebo/Library/Application Support/swiftly/bin/swift
$ swiftly list
Installed release toolchains
----------------------------
Swift 6.2.0 (default)
Installed snapshot toolchains
-----------------------------
main-snapshot-2025-10-02 (in use)
main-snapshot-2025-09-20
main-snapshot-2025-09-06
$ swift --version
Apple Swift version 6.3-dev (LLVM 0d0246569621d5b, Swift 199240b3fe97eda)
Target: arm64-apple-macosx26.0
Build config: +assertions
$ which wasmkit
/Users/kebo/Library/Application Support/swiftly/bin/wasmkit
$ wasmkit --version
0.1.6