Skip to content

Commit 741d0f9

Browse files
authored
Fix for core_2gb.test_fs_js_api_wasmfs. NFC (#23885)
This tests is failing on the emscripten-releases waterfall. In 2Gb+ mode its no longer possible to fix the returning of pointers with the returning of `-errno` since negative number are valid pointers in this mode.
1 parent acb0442 commit 741d0f9

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.circleci/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ jobs:
662662
wasm64
663663
core_2gb.test_*em_asm*
664664
core_2gb.test_*embind*
665+
core_2gb.test_fs_js_api_wasmfs
665666
wasm64l.test_hello_world
666667
wasm64l.test_bigswitch
667668
wasm64l.test_module_wasm_memory

src/lib/libwasmfs.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,12 @@ addToLibrary({
242242
__wasmfs_symlink(stringToUTF8OnStack(target), stringToUTF8OnStack(linkpath))
243243
)),
244244
readlink(path) {
245-
var readBuffer = FS.handleError(withStackSave(() => __wasmfs_readlink(stringToUTF8OnStack(path))));
246-
return UTF8ToString(readBuffer);
245+
return withStackSave(() => {
246+
var bufPtr = stackAlloc({{{ POINTER_SIZE }}});
247+
FS.handleError(__wasmfs_readlink(stringToUTF8OnStack(path), bufPtr));
248+
var readBuffer = {{{ makeGetValue('bufPtr', '0', '*') }}};
249+
return UTF8ToString(readBuffer);
250+
});
247251
},
248252
statBufToObject(statBuf) {
249253
// i53/u53 are enough for times and ino in practice.

system/lib/wasmfs/js_api.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,16 @@ int _wasmfs_symlink(const char* old_path, const char* new_path) {
140140
return __syscall_symlinkat((intptr_t)old_path, AT_FDCWD, (intptr_t)new_path);
141141
}
142142

143-
intptr_t _wasmfs_readlink(const char* path) {
143+
int _wasmfs_readlink(const char* path, char** out_ptr) {
144144
static thread_local char* readBuf = (char*)malloc(PATH_MAX);
145145
int bytes =
146146
__syscall_readlinkat(AT_FDCWD, (intptr_t)path, (intptr_t)readBuf, PATH_MAX);
147147
if (bytes < 0) {
148148
return bytes;
149149
}
150150
readBuf[bytes] = '\0';
151-
return (intptr_t)readBuf;
151+
*out_ptr = readBuf;
152+
return 0;
152153
}
153154

154155
int _wasmfs_write(int fd, void* buf, size_t count) {

tools/emscripten.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ def create_pointer_conversion_wrappers(metadata):
10761076
'_emscripten_proxy_dlsync_async': '_pp',
10771077
'_emscripten_wasm_worker_initialize': '_p_',
10781078
'_wasmfs_rename': '_pp',
1079-
'_wasmfs_readlink': 'pp',
1079+
'_wasmfs_readlink': '_pp',
10801080
'_wasmfs_truncate': '_p_',
10811081
'_wasmfs_mmap': 'pp____',
10821082
'_wasmfs_munmap': '_pp',

0 commit comments

Comments
 (0)