Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implements lstat and fixes inode stat on windows go 1.20 #1168

Merged
merged 1 commit into from
Feb 27, 2023

Conversation

codefromthecrypt
Copy link
Contributor

@codefromthecrypt codefromthecrypt commented Feb 26, 2023

This implements platform.Lstat and uses it in GOOS=js. Notably, directory listings need to run lstat on their entries to get the correct inodes back. In GOOS=js, directories are a fan-out of names, then lstat.

This also fixes stat for inodes on directories. We were missing a test so we didn't know it was broken on windows. The approach used now is reliable on go 1.20, and we should suggest anyone using windows to compile with go 1.20.

@codefromthecrypt codefromthecrypt marked this pull request as draft February 26, 2023 01:06
@codefromthecrypt codefromthecrypt force-pushed the lstat branch 3 times, most recently from 37bf7e5 to 2f9ae52 Compare February 26, 2023 12:16
@codefromthecrypt codefromthecrypt changed the title gojs: implements lstat implements lstat and fixes inode stat on windows go 1.20 Feb 26, 2023
@codefromthecrypt codefromthecrypt marked this pull request as ready for review February 26, 2023 12:17
Copy link
Contributor Author

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notes!

@@ -18,7 +18,7 @@ defaults:
shell: bash

env: # Update this prior to requiring a higher minor version in go.mod
GO_VERSION: "1.19" # 1.xx == latest patch of 1.xx
GO_VERSION: "1.20" # 1.xx == latest patch of 1.xx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was supposed to be latest, and also it is important because it means windows works fine.

@@ -143,11 +143,22 @@ func (jsfsLstat) invoke(ctx context.Context, mod api.Module, args ...interface{}
path := args[0].(string)
callback := args[1].(funcWrapper)

lstat, err := syscallStat(mod, path) // TODO switch to lstat syscall
lstat, err := syscallLstat(mod, path)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lstat is needed on GOOS=js because reading a directory involves fetching the dir names then an lstat per entry. This can't use stat because stat follows links.

var stat1 Stat_t
require.NoError(t, StatFile(d, &stat1))
requireDirectoryDevIno(t, stat1)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing test. before we had no idea directories weren't returning inodes on windows

@codefromthecrypt
Copy link
Contributor Author

zig windows test is taking forever now. will turn on host logging to see what's going on.

internal/sys/sys_test.go Outdated Show resolved Hide resolved
@codefromthecrypt
Copy link
Contributor Author

looks like windows is dying after this. I wonder if we can make sure that zig exits faster vs hanging? wdyt @mathetake?

961/2123 test.Dir.readLink... exit status 0xc000013a
[969](https://github.com/tetratelabs/wazero/actions/runs/4277347483/jobs/7446094975#step:5:970)
Error: The operation was canceled.

@codefromthecrypt
Copy link
Contributor Author

added timeout-minutes: 10 on #1169 which hangs the same way

@codefromthecrypt
Copy link
Contributor Author

ok this is now rebased on the same zig version that passes on main

@codefromthecrypt
Copy link
Contributor Author

hostlogging isn't really viable in zig since the tests can't be skipped at runtime. the compiled stdlib test wasm isn't tainted per PR, which means it runs all of them. the logs here are 2.3GB for example!

@codefromthecrypt
Copy link
Contributor Author

ok something is looping in test.Dir.readLink as it is the last test to execute and only at line 1904 in 2.3GB worth of logs.

$ cat -n  ~/Downloads/logs |grep ' test.'
--snip--
  1904	2023-02-27T01:23:17.1788043Z 961/2123 test.Dir.readLink... ==> wasi_snapshot_preview1.path_create_directory(fd=3,path=zig-cache)

@codefromthecrypt
Copy link
Contributor Author

yep something is calling path_unlink_file and path_open in a loop

2023-02-27T01:30:09.8011004Z ==> wasi_snapshot_preview1.path_unlink_file(fd=7,path=symlink2)
2023-02-27T01:30:09.8011081Z <== errno=EISDIR
2023-02-27T01:30:09.8012390Z ==> wasi_snapshot_preview1.path_open(fd=7,dirflags=,path=symlink2,oflags=DIRECTORY,fs_rights_base=FDSTAT_SET_FLAGS|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE,fs_rights_inheriting=FD_DATASYNC|FD_READ|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|FD_ADVISE|FD_ALLOCATE|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE|POLL_FD_READWRITE,fdflags=)
2023-02-27T01:30:09.8012495Z <== (opened_fd=,errno=ENOTDIR)
2023-02-27T01:30:09.8012658Z ==> wasi_snapshot_preview1.path_unlink_file(fd=7,path=symlink2)
2023-02-27T01:30:09.8012790Z <== errno=EISDIR
2023-02-27T01:30:09.8014091Z ==> wasi_snapshot_preview1.path_open(fd=7,dirflags=,path=symlink2,oflags=DIRECTORY,fs_rights_base=FDSTAT_SET_FLAGS|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE,fs_rights_inheriting=FD_DATASYNC|FD_READ|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|FD_ADVISE|FD_ALLOCATE|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE|POLL_FD_READWRITE,fdflags=)
2023-02-27T01:30:09.8014195Z <== (opened_fd=,errno=ENOTDIR)
2023-02-27T01:30:09.8014356Z ==> wasi_snapshot_preview1.path_unlink_file(fd=7,path=symlink2)
2023-02-27T01:30:09.8014436Z <== errno=EISDIR
2023-02-27T01:30:09.8015788Z ==> wasi_snapshot_preview1.path_open(fd=7,dirflags=,path=symlink2,oflags=DIRECTORY,fs_rights_base=FDSTAT_SET_FLAGS|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE,fs_rights_inheriting=FD_DATASYNC|FD_READ|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|FD_ADVISE|FD_ALLOCATE|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE|POLL_FD_READWRITE,fdflags=)

@codefromthecrypt
Copy link
Contributor Author

here's darwin

2023-02-27T01:21:32.4733190Z 961/2123 test.Dir.readLink... ==> wasi_snapshot_preview1.path_create_directory(fd=3,path=zig-cache)
2023-02-27T01:21:32.4733490Z <== errno=EEXIST
2023-02-27T01:21:32.4735980Z ==> wasi_snapshot_preview1.path_open(fd=3,dirflags=SYMLINK_FOLLOW,path=zig-cache,oflags=DIRECTORY,fs_rights_base=FDSTAT_SET_FLAGS|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE,fs_rights_inheriting=FD_DATASYNC|FD_READ|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|FD_ADVISE|FD_ALLOCATE|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE|POLL_FD_READWRITE,fdflags=)
2023-02-27T01:21:32.4737210Z <== (opened_fd=7,errno=ESUCCESS)
2023-02-27T01:21:32.4737540Z ==> wasi_snapshot_preview1.path_create_directory(fd=7,path=tmp)
2023-02-27T01:21:32.4738070Z <== errno=EEXIST
2023-02-27T01:21:32.4739590Z ==> wasi_snapshot_preview1.path_open(fd=7,dirflags=SYMLINK_FOLLOW,path=tmp,oflags=DIRECTORY,fs_rights_base=FDSTAT_SET_FLAGS|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE,fs_rights_inheriting=FD_DATASYNC|FD_READ|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|FD_ADVISE|FD_ALLOCATE|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE|POLL_FD_READWRITE,fdflags=)
2023-02-27T01:21:32.4740800Z <== (opened_fd=8,errno=ESUCCESS)
2023-02-27T01:21:32.4741120Z ==> wasi_snapshot_preview1.path_create_directory(fd=8,path=Q3BJHZH9O5v4xyYg)
2023-02-27T01:21:32.4741400Z <== errno=ESUCCESS
2023-02-27T01:21:32.4742830Z ==> wasi_snapshot_preview1.path_open(fd=8,dirflags=SYMLINK_FOLLOW,path=Q3BJHZH9O5v4xyYg,oflags=DIRECTORY,fs_rights_base=FDSTAT_SET_FLAGS|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE,fs_rights_inheriting=FD_DATASYNC|FD_READ|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|FD_ADVISE|FD_ALLOCATE|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE|POLL_FD_READWRITE,fdflags=)
2023-02-27T01:21:32.4744470Z <== (opened_fd=9,errno=ESUCCESS)
2023-02-27T01:21:32.4744720Z ==> wasi_snapshot_preview1.fd_close(fd=7)
2023-02-27T01:21:32.4744940Z <== errno=ESUCCESS
2023-02-27T01:21:32.4745760Z ==> wasi_snapshot_preview1.path_open(fd=9,dirflags=,path=file.txt,oflags=CREAT|TRUNC,fs_rights_base=FD_DATASYNC|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|FD_ADVISE|FD_ALLOCATE|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES,fs_rights_inheriting=,fdflags=)
2023-02-27T01:21:32.4746320Z <== (opened_fd=7,errno=ESUCCESS)
2023-02-27T01:21:32.4746590Z ==> wasi_snapshot_preview1.fd_write(fd=7,iovs=1047832,iovs_len=1)
2023-02-27T01:21:32.4746870Z <== (nwritten=8,errno=ESUCCESS)
2023-02-27T01:21:32.4747170Z ==> wasi_snapshot_preview1.fd_close(fd=7)
2023-02-27T01:21:32.5142700Z <== errno=ESUCCESS
2023-02-27T01:21:32.5143850Z ==> wasi_snapshot_preview1.path_create_directory(fd=9,path=subdir)
2023-02-27T01:21:32.5145490Z <== errno=ESUCCESS
2023-02-27T01:21:32.5145860Z ==> wasi_snapshot_preview1.path_symlink(old_path=file.txt,fd=9,new_path=symlink1)
2023-02-27T01:21:32.5146140Z <== errno=ESUCCESS
2023-02-27T01:21:32.5146450Z ==> wasi_snapshot_preview1.path_readlink(fd=9,path=symlink1,buf=1043864,buf_len=4096)
2023-02-27T01:21:32.5146740Z <== (bufused=8,errno=ESUCCESS)
2023-02-27T01:21:32.5147050Z ==> wasi_snapshot_preview1.path_symlink(old_path=subdir,fd=9,new_path=symlink2)
2023-02-27T01:21:32.5147700Z <== errno=ESUCCESS
2023-02-27T01:21:32.5148560Z ==> wasi_snapshot_preview1.path_readlink(fd=9,path=symlink2,buf=1043864,buf_len=4096)
2023-02-27T01:21:32.5148910Z <== (bufused=6,errno=ESUCCESS)
2023-02-27T01:21:32.5149380Z ==> wasi_snapshot_preview1.fd_close(fd=9)
2023-02-27T01:21:32.5150050Z <== errno=ESUCCESS
2023-02-27T01:21:32.5150640Z ==> wasi_snapshot_preview1.path_unlink_file(fd=8,path=Q3BJHZH9O5v4xyYg)
2023-02-27T01:21:32.5150940Z <== errno=EISDIR
2023-02-27T01:21:32.5152840Z ==> wasi_snapshot_preview1.path_open(fd=8,dirflags=,path=Q3BJHZH9O5v4xyYg,oflags=DIRECTORY,fs_rights_base=FDSTAT_SET_FLAGS|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE,fs_rights_inheriting=FD_DATASYNC|FD_READ|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|FD_ADVISE|FD_ALLOCATE|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE|POLL_FD_READWRITE,fdflags=)
2023-02-27T01:21:32.5154060Z <== (opened_fd=7,errno=ESUCCESS)
2023-02-27T01:21:32.5154400Z ==> wasi_snapshot_preview1.fd_readdir(fd=7,buf=1023292,buf_len=1024,cookie=0)
2023-02-27T01:21:32.5154670Z <== (bufused=177,errno=ESUCCESS)
2023-02-27T01:21:32.5154950Z ==> wasi_snapshot_preview1.path_unlink_file(fd=7,path=file.txt)
2023-02-27T01:21:32.5155210Z <== errno=ESUCCESS
2023-02-27T01:21:32.5155480Z ==> wasi_snapshot_preview1.path_unlink_file(fd=7,path=symlink1)
2023-02-27T01:21:32.5155730Z <== errno=ESUCCESS
2023-02-27T01:21:32.5157130Z ==> wasi_snapshot_preview1.path_open(fd=7,dirflags=,path=subdir,oflags=DIRECTORY,fs_rights_base=FDSTAT_SET_FLAGS|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE,fs_rights_inheriting=FD_DATASYNC|FD_READ|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|FD_ADVISE|FD_ALLOCATE|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE|POLL_FD_READWRITE,fdflags=)
2023-02-27T01:21:32.5158710Z <== (opened_fd=9,errno=ESUCCESS)
2023-02-27T01:21:32.5159010Z ==> wasi_snapshot_preview1.fd_readdir(fd=9,buf=1024356,buf_len=1024,cookie=0)
2023-02-27T01:21:32.5159290Z <== (bufused=51,errno=ESUCCESS)
2023-02-27T01:21:32.5159860Z ==> wasi_snapshot_preview1.fd_readdir(fd=9,buf=1024356,buf_len=1024,cookie=2)
2023-02-27T01:21:32.5160180Z <== (bufused=0,errno=ESUCCESS)
2023-02-27T01:21:32.5160430Z ==> wasi_snapshot_preview1.fd_close(fd=9)
2023-02-27T01:21:32.5160650Z <== errno=ESUCCESS
2023-02-27T01:21:32.5160930Z ==> wasi_snapshot_preview1.path_remove_directory(fd=7,path=subdir)
2023-02-27T01:21:32.5161190Z <== errno=ESUCCESS
2023-02-27T01:21:32.5161460Z ==> wasi_snapshot_preview1.path_unlink_file(fd=7,path=symlink2)
2023-02-27T01:21:32.5161700Z <== errno=ESUCCESS
2023-02-27T01:21:32.5161970Z ==> wasi_snapshot_preview1.fd_readdir(fd=7,buf=1023292,buf_len=1024,cookie=6)
2023-02-27T01:21:32.5162240Z <== (bufused=0,errno=ESUCCESS)
2023-02-27T01:21:32.5162480Z ==> wasi_snapshot_preview1.fd_close(fd=7)
2023-02-27T01:21:32.5162700Z <== errno=ESUCCESS
2023-02-27T01:21:32.5162990Z ==> wasi_snapshot_preview1.path_remove_directory(fd=8,path=Q3BJHZH9O5v4xyYg)
2023-02-27T01:21:32.5163260Z <== errno=ESUCCESS
2023-02-27T01:21:32.5163750Z ==> wasi_snapshot_preview1.fd_close(fd=8)
2023-02-27T01:21:32.5164290Z <== errno=ESUCCESS
2023-02-27T01:21:32.5164690Z OK

@codefromthecrypt
Copy link
Contributor Author

@mathetake so this seems the root cause is our implementation is struggling to delete a symlink on windows. I have to run for a couple hours in case you have time to try this in this PR or a separate one.

here's the start of the loop on windows. I think possibly the EISDIR is misleading (as it is a link) or something else amuck when trying to path_unlink_file symlink2

2023-02-27T01:23:17.1819639Z ==> wasi_snapshot_preview1.path_remove_directory(fd=7,path=subdir)
2023-02-27T01:23:17.1819924Z <== errno=ESUCCESS
2023-02-27T01:23:17.1820219Z ==> wasi_snapshot_preview1.path_unlink_file(fd=7,path=symlink1)
2023-02-27T01:23:17.1820490Z <== errno=ESUCCESS
2023-02-27T01:23:17.1820766Z ==> wasi_snapshot_preview1.path_unlink_file(fd=7,path=symlink2)
2023-02-27T01:23:17.1821039Z <== errno=EISDIR
2023-02-27T01:23:17.1822548Z ==> wasi_snapshot_preview1.path_open(fd=7,dirflags=,path=symlink2,oflags=DIRECTORY,fs_rights_base=FDSTAT_SET_FLAGS|PATH_CREATE_DIRECTORY|PATH_CREATE_F
ILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTAT_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_
FILESTAT_GET|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE,fs_rights_inheriting=FD_DATASYNC|FD_READ|FD_SEEK|FDSTAT_SET_FLAGS|FD_SYNC|FD_TELL|FD_WRITE|F
D_ADVISE|FD_ALLOCATE|PATH_CREATE_DIRECTORY|PATH_CREATE_FILE|PATH_LINK_SOURCE|PATH_LINK_TARGET|PATH_OPEN|FD_READDIR|PATH_READLINK|PATH_RENAME_SOURCE|PATH_RENAME_TARGET|PATH_FILESTA
T_GET|PATH_FILESTAT_SET_SIZE|PATH_FILESTAT_SET_TIMES|FD_FILESTAT_GET|FD_FILESTAT_SET_SIZE|FD_FILESTAT_SET_TIMES|PATH_SYMLINK|PATH_REMOVE_DIRECTORY|PATH_UNLINK_FILE|POLL_FD_READWRITE,fdflags=)
2023-02-27T01:23:17.1823967Z <== (opened_fd=,errno=ENOTDIR)
2023-02-27T01:23:17.1824286Z ==> wasi_snapshot_preview1.path_unlink_file(fd=7,path=symlink2)
2023-02-27T01:23:17.1824562Z <== errno=EISDIR
2023-02-27T01:23:17.1826027Z ==> wasi_snapshot_p

@mathetake
Copy link
Member

#1172 here's a repro

This implements platform.Lstat and uses it in GOOS=js. Notably,
directory listings need to run lstat on their entries to get the correct
inodes back. In GOOS=js, directories are a fan-out of names, then lstat.

This also fixes stat for inodes on directories. We were missing a test
so we didn't know it was broken on windows. The approach used now is
reliable on go 1.20, and we should suggest anyone using windows to
compile with go 1.20.

Signed-off-by: Takeshi Yoneda <[email protected]>
Co-authored-by: Adrian Cole <[email protected]>
@codefromthecrypt codefromthecrypt merged commit 3d5b6d6 into main Feb 27, 2023
@codefromthecrypt codefromthecrypt deleted the lstat branch February 27, 2023 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants