You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Wasm binary built with SwiftWasm can use Foundation's Data.write(to:). However, when the file already exists, the write itself succeeds but an error occurs.
$ tree ..├── Package.swift└── Sources └── main.swift2 directories, 2 files
$ cat Package.swift// swift-tools-version: 6.0import PackageDescriptionlet package = Package( name: "write_test", targets: [ .executableTarget(name: "write_test") ])
$ cat Sources/main.swiftimport Foundationtry! "test".data(using: .utf8)!.write(to: URL(fileURLWithPath: "./test.txt"))
$ swift build --swift-sdk wasm32-unknown-wasiBuilding for debugging...[1/1] Write swift-version-31C605C61487384.txtBuild complete! (0.13s)
$ wasmtime run --dir . .build/debug/write_test.wasm
$ cat test.txttest
$ wasmtime run --dir . .build/debug/write_test.wasmwrite_test/main.swift:3: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=512 "(null)"Error: failed to run main module `.build/debug/write_test.wasm`Caused by: 0: failed to invoke command default 1: error while executing at wasm backtrace: 0: 0x3a612 - <unknown>!$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF 1: 0xe04c8 - <unknown>!swift_unexpectedError 2: 0x24192 - <unknown>!main 3: 0xbd138c - <unknown>!__main_void 4: 0x23b2b - <unknown>!_start note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information 2: wasm trap: wasm `unreachable` instruction executed
Environment
$ uname -a
Linux Brown-rhinoceros-beetle 6.8.10-400.asahi.fc40.aarch64+16k #1 SMP PREEMPT_DYNAMIC Mon May 27 16:05:41 UTC 2024 aarch64 GNU/Linux
$ which swift
/home/kebo/.local/bin/swift
$ swiftly list
Installed release toolchains
----------------------------
Installed snapshot toolchains
-----------------------------
6.0-snapshot-2024-06-07
main-snapshot-2024-06-07
main-snapshot-2024-06-06 (in use)
$ swift --version
Swift version 6.0-dev (LLVM 70f5988c1c84591, Swift 4f8181dde6a5a62)
Target: aarch64-unknown-linux-gnu
$ swift sdk list
DEVELOPMENT-SNAPSHOT-2024-06-07-a-wasm32-unknown-wasi
$ wasmtime -V
wasmtime-cli 19.0.0
The text was updated successfully, but these errors were encountered:
kkebo
added a commit
to kkebo/swift-corelibs-foundation
that referenced
this issue
Jun 8, 2024
Description
The Wasm binary built with SwiftWasm can use Foundation's
Data.write(to:)
. However, when the file already exists, the write itself succeeds but an error occurs.That's because it tries to set permissions even though it does not have permission concept.
Steps to reproduce
Environment
The text was updated successfully, but these errors were encountered: