abbec opened Issue #2493:
I am using this simple C program to test:
#include <dirent.h> #include <stdio.h> #include <errno.h> int main(int argc, char **argv) { DIR *d; char * target = "."; if (argc == 2) { target = argv[1]; } struct dirent *dir; d = opendir(target); if (d) { while ((dir = readdir(d)) != NULL) { printf("%s\n", dir->d_name); } printf("errno: %d\n", errno); closedir(d); } return(0); }
I then use this bash script to generate a directory with
N
files inrm -rf testfolder mkdir -p testfolder for n in $(seq 1 ${1:-100}); do touch testfolder/$(printf %04d "$n") done
This is what happens when I run it
$ bash generate-files.sh 100 $ ls testfolder/ 0001 0005 0009 0013 0017 0021 0025 0029 0033 0037 0041 0045 0049 0053 0057 0061 0065 0069 0073 0077 0081 0085 0089 0093 0097 0002 0006 0010 0014 0018 0022 0026 0030 0034 0038 0042 0046 0050 0054 0058 0062 0066 0070 0074 0078 0082 0086 0090 0094 0098 0003 0007 0011 0015 0019 0023 0027 0031 0035 0039 0043 0047 0051 0055 0059 0063 0067 0071 0075 0079 0083 0087 0091 0095 0099 0004 0008 0012 0016 0020 0024 0028 0032 0036 0040 0044 0048 0052 0056 0060 0064 0068 0072 0076 0080 0084 0088 0092 0096 0100 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 103 # 100 files + "." ".." and the "errno" print $ bash generate-files.sh 200 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 147 # lots of files missing # for example 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0011 0011
Running wasmer on the same input works as expected:
$ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | wc -l 201 # wasmer does not return "." and ".." $ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | grep 0012 0012
Expected Behavior
Calls to
readdir
returns all directory entries, even for folders with more than 150 files.
abbec labeled Issue #2493:
I am using this simple C program to test:
#include <dirent.h> #include <stdio.h> #include <errno.h> int main(int argc, char **argv) { DIR *d; char * target = "."; if (argc == 2) { target = argv[1]; } struct dirent *dir; d = opendir(target); if (d) { while ((dir = readdir(d)) != NULL) { printf("%s\n", dir->d_name); } printf("errno: %d\n", errno); closedir(d); } return(0); }
I then use this bash script to generate a directory with
N
files inrm -rf testfolder mkdir -p testfolder for n in $(seq 1 ${1:-100}); do touch testfolder/$(printf %04d "$n") done
This is what happens when I run it
$ bash generate-files.sh 100 $ ls testfolder/ 0001 0005 0009 0013 0017 0021 0025 0029 0033 0037 0041 0045 0049 0053 0057 0061 0065 0069 0073 0077 0081 0085 0089 0093 0097 0002 0006 0010 0014 0018 0022 0026 0030 0034 0038 0042 0046 0050 0054 0058 0062 0066 0070 0074 0078 0082 0086 0090 0094 0098 0003 0007 0011 0015 0019 0023 0027 0031 0035 0039 0043 0047 0051 0055 0059 0063 0067 0071 0075 0079 0083 0087 0091 0095 0099 0004 0008 0012 0016 0020 0024 0028 0032 0036 0040 0044 0048 0052 0056 0060 0064 0068 0072 0076 0080 0084 0088 0092 0096 0100 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 103 # 100 files + "." ".." and the "errno" print $ bash generate-files.sh 200 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 147 # lots of files missing # for example 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0011 0011
Running wasmer on the same input works as expected:
$ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | wc -l 201 # wasmer does not return "." and ".." $ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | grep 0012 0012
Expected Behavior
Calls to
readdir
returns all directory entries, even for folders with more than 150 files.
abbec edited Issue #2493:
I am using this simple C program to test:
#include <dirent.h> #include <stdio.h> #include <errno.h> int main(int argc, char **argv) { DIR *d; char * target = "."; if (argc == 2) { target = argv[1]; } struct dirent *dir; d = opendir(target); if (d) { while ((dir = readdir(d)) != NULL) { printf("%s\n", dir->d_name); } printf("errno: %d\n", errno); closedir(d); } return(0); }
I then use this bash script to generate a directory with
N
files inrm -rf testfolder mkdir -p testfolder for n in $(seq 1 ${1:-100}); do touch testfolder/$(printf %04d "$n") done
This is what happens when I run it
$ bash generate-files.sh 100 $ ls testfolder/ 0001 0005 0009 0013 0017 0021 0025 0029 0033 0037 0041 0045 0049 0053 0057 0061 0065 0069 0073 0077 0081 0085 0089 0093 0097 0002 0006 0010 0014 0018 0022 0026 0030 0034 0038 0042 0046 0050 0054 0058 0062 0066 0070 0074 0078 0082 0086 0090 0094 0098 0003 0007 0011 0015 0019 0023 0027 0031 0035 0039 0043 0047 0051 0055 0059 0063 0067 0071 0075 0079 0083 0087 0091 0095 0099 0004 0008 0012 0016 0020 0024 0028 0032 0036 0040 0044 0048 0052 0056 0060 0064 0068 0072 0076 0080 0084 0088 0092 0096 0100 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 103 # 100 files + "." ".." and the "errno" print $ bash generate-files.sh 200 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 147 # lots of files missing # for example 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0011 0011
Running wasmer on the same input works as expected:
$ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | wc -l 201 # wasmer does not return "." and ".." $ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | grep 0012 0012
Expected Behavior
Calls to
readdir
returns all directory entries, even for folders with more than ~150 files.
abbec commented on Issue #2493:
Tested wasmtime versions are 0.19 and 0.21 (both with the same result)
pchickey assigned Issue #2493:
I am using this simple C program to test:
#include <dirent.h> #include <stdio.h> #include <errno.h> int main(int argc, char **argv) { DIR *d; char * target = "."; if (argc == 2) { target = argv[1]; } struct dirent *dir; d = opendir(target); if (d) { while ((dir = readdir(d)) != NULL) { printf("%s\n", dir->d_name); } printf("errno: %d\n", errno); closedir(d); } return(0); }
I then use this bash script to generate a directory with
N
files inrm -rf testfolder mkdir -p testfolder for n in $(seq 1 ${1:-100}); do touch testfolder/$(printf %04d "$n") done
This is what happens when I run it
$ bash generate-files.sh 100 $ ls testfolder/ 0001 0005 0009 0013 0017 0021 0025 0029 0033 0037 0041 0045 0049 0053 0057 0061 0065 0069 0073 0077 0081 0085 0089 0093 0097 0002 0006 0010 0014 0018 0022 0026 0030 0034 0038 0042 0046 0050 0054 0058 0062 0066 0070 0074 0078 0082 0086 0090 0094 0098 0003 0007 0011 0015 0019 0023 0027 0031 0035 0039 0043 0047 0051 0055 0059 0063 0067 0071 0075 0079 0083 0087 0091 0095 0099 0004 0008 0012 0016 0020 0024 0028 0032 0036 0040 0044 0048 0052 0056 0060 0064 0068 0072 0076 0080 0084 0088 0092 0096 0100 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 103 # 100 files + "." ".." and the "errno" print $ bash generate-files.sh 200 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 147 # lots of files missing # for example 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0011 0011
Running wasmer on the same input works as expected:
$ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | wc -l 201 # wasmer does not return "." and ".." $ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | grep 0012 0012
Expected Behavior
Calls to
readdir
returns all directory entries, even for folders with more than ~150 files.
pchickey commented on Issue #2493:
What toolchain and libc did you compile the example with?
When I compiled with wasi-sdk 12, I was unable to reproduce.
issue2493.zip
pchickey deleted a comment on Issue #2493:
What toolchain and libc did you compile the example with?
When I compiled with wasi-sdk 12, I was unable to reproduce.
issue2493.zip
pchickey commented on Issue #2493:
I was able to reproduce, this is a wasi-common bug
pchickey labeled Issue #2493 (assigned to pchickey):
I am using this simple C program to test:
#include <dirent.h> #include <stdio.h> #include <errno.h> int main(int argc, char **argv) { DIR *d; char * target = "."; if (argc == 2) { target = argv[1]; } struct dirent *dir; d = opendir(target); if (d) { while ((dir = readdir(d)) != NULL) { printf("%s\n", dir->d_name); } printf("errno: %d\n", errno); closedir(d); } return(0); }
I then use this bash script to generate a directory with
N
files inrm -rf testfolder mkdir -p testfolder for n in $(seq 1 ${1:-100}); do touch testfolder/$(printf %04d "$n") done
This is what happens when I run it
$ bash generate-files.sh 100 $ ls testfolder/ 0001 0005 0009 0013 0017 0021 0025 0029 0033 0037 0041 0045 0049 0053 0057 0061 0065 0069 0073 0077 0081 0085 0089 0093 0097 0002 0006 0010 0014 0018 0022 0026 0030 0034 0038 0042 0046 0050 0054 0058 0062 0066 0070 0074 0078 0082 0086 0090 0094 0098 0003 0007 0011 0015 0019 0023 0027 0031 0035 0039 0043 0047 0051 0055 0059 0063 0067 0071 0075 0079 0083 0087 0091 0095 0099 0004 0008 0012 0016 0020 0024 0028 0032 0036 0040 0044 0048 0052 0056 0060 0064 0068 0072 0076 0080 0084 0088 0092 0096 0100 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 103 # 100 files + "." ".." and the "errno" print $ bash generate-files.sh 200 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 147 # lots of files missing # for example 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0011 0011
Running wasmer on the same input works as expected:
$ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | wc -l 201 # wasmer does not return "." and ".." $ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | grep 0012 0012
Expected Behavior
Calls to
readdir
returns all directory entries, even for folders with more than ~150 files.
sunfishcode commented on Issue #2493:
Me too. #2494 is a fix for this.
abbec commented on Issue #2493:
Nice, that was fast! :smile:
sunfishcode closed Issue #2493 (assigned to pchickey):
I am using this simple C program to test:
#include <dirent.h> #include <stdio.h> #include <errno.h> int main(int argc, char **argv) { DIR *d; char * target = "."; if (argc == 2) { target = argv[1]; } struct dirent *dir; d = opendir(target); if (d) { while ((dir = readdir(d)) != NULL) { printf("%s\n", dir->d_name); } printf("errno: %d\n", errno); closedir(d); } return(0); }
I then use this bash script to generate a directory with
N
files inrm -rf testfolder mkdir -p testfolder for n in $(seq 1 ${1:-100}); do touch testfolder/$(printf %04d "$n") done
This is what happens when I run it
$ bash generate-files.sh 100 $ ls testfolder/ 0001 0005 0009 0013 0017 0021 0025 0029 0033 0037 0041 0045 0049 0053 0057 0061 0065 0069 0073 0077 0081 0085 0089 0093 0097 0002 0006 0010 0014 0018 0022 0026 0030 0034 0038 0042 0046 0050 0054 0058 0062 0066 0070 0074 0078 0082 0086 0090 0094 0098 0003 0007 0011 0015 0019 0023 0027 0031 0035 0039 0043 0047 0051 0055 0059 0063 0067 0071 0075 0079 0083 0087 0091 0095 0099 0004 0008 0012 0016 0020 0024 0028 0032 0036 0040 0044 0048 0052 0056 0060 0064 0068 0072 0076 0080 0084 0088 0092 0096 0100 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 103 # 100 files + "." ".." and the "errno" print $ bash generate-files.sh 200 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | wc -l 147 # lots of files missing # for example 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0012 $ wasmtime run ls.wasm --dir=./testfolder -- testfolder | grep 0011 0011
Running wasmer on the same input works as expected:
$ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | wc -l 201 # wasmer does not return "." and ".." $ ~/.wasmer/bin/wasmer run ls.wasm --dir=./testfolder -- testfolder | grep 0012 0012
Expected Behavior
Calls to
readdir
returns all directory entries, even for folders with more than ~150 files.
Last updated: Nov 22 2024 at 17:03 UTC