WASI pre-opened file descriptor failure

Brief description of the issue:
From within a WASM gauge, I am unable to open the .\ or \work directories or create any files under \work. The particular error reported indicates:

failed to find a pre-opened file descriptor through which “\work” could be opened

This appears to be due to no file descriptors being returned during the call to the WASI __wasilibc_find_relpath call.

Provide Screenshot(s)/video(s) of the issue encountered:

(The \\ instead of \ in the error report is just an implementation detail of how the debug print works on paths. The path being passed has only the one \.)

Detail steps to reproduce the issue encountered:

  • Download the Working Title CJ4 mod, extract into the Community folder.

  • Replace the SimObjects\Airplanes\Asobo_CJ4\panel\workingtitle-cj4-wasm.wasm with this WASM build artifact (you will need to rename it to workingtitle-cj4-wasm.wasm).

  • Update the layout.json file for the module to indicate a larger size for this file. I have been using 200000.

  • Load up the Sim and open the console.

  • On loading into the CJ4, the module will attempt to find/access directories and create a file from a variety of paths and report the result of those requests to the console, but will fail.

Note: This does involve use of the Rust compiler, however this is the first incompatibility I’ve found. The actual error is being generated by this bit of code inside the standard library, which receives -1 back as the file descriptor after calling __wasilibc_find_relpath.

I have confirmed that the . and \work directories are already pre-opened as file descriptors 3 and 4 by using the bare fd_prestat_get and fd_prestat_dir_name APIs. That just leads me to believe that it is this find_relpath call that is not returning the pre-opened FD which is the issue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.