Closed hly2019 closed 4 months ago
This looks like an oversight/bug in musl's implementation of fclose. See: https://github.com/emscripten-core/emscripten/blob/1801e94f5f35aad3ba341897d619d8ca11d26e0f/system/lib/libc/musl/src/stdio/fclose.c#L11-L14 https://github.com/emscripten-core/emscripten/blob/1801e94f5f35aad3ba341897d619d8ca11d26e0f/system/lib/libc/musl/src/stdio/__stdio_close.c#L11-L18
Please include the following in your bug report:
Version of emscripten/emsdk: 3.1.54
Failing command line in full:
Hi, I found a problem regarding the behaviour of
::fclose
and::close
. Basically, if we first close a file with::close
, then call::fclose
to close it again, it is definitely a behavior not allowed and should report errors viaerrno
and the return value of the::fclose
should beEOF
according to https://man7.org/linux/man-pages/man3/fclose.3.html#RETURN_VALUE. However, it seems such operations don't set anything witherrno
, and the return value of::fclose
is also not set asEOF
, as shown below, which seems to be weird. Besides, if we reverse the order of::close
and::fclose
(i.e., first execute::fclose
, then::close
), then I could get a correct error message viaerrno
and the return value of::close
isEOF
. So it's quite weird.It'd be so appreciated if you could help check it. Thank you!
Code
Result
Here we can see in wasm execution results, there is no error information, and the return value of
::fclose
is also notEOF
.