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

Generic error if FS.createPreloadedFile parent doesn't exist #21928

Open
curiousdannii opened this issue May 12, 2024 · 4 comments
Open

Generic error if FS.createPreloadedFile parent doesn't exist #21928

curiousdannii opened this issue May 12, 2024 · 4 comments

Comments

@curiousdannii
Copy link
Contributor

curiousdannii commented May 12, 2024

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.59 (0e4c5994eb5b8defd38367a416d0703fd506ad81)
clang version 19.0.0git (https:/github.com/llvm/llvm-project df762a1643bb5b0b3c907611d118c82d4b68a39d)

I'm trying to preload some files (in a pre-js file):

Module.preRun = () => {
    FS.createPreloadedFile('/data', 'journey-r83-s890706.z6', 'journey-r83-s890706.z6', true, false)
    FS.createPreloadedFile('/data', 'Journey.blb', 'Journey.blb', true, false)
}

Since I forgot to create the /data folder first I'm getting a console errors, but they're very generic and unhelpful. Enabling -sASSERTIONS doesn't make a difference.

sfrotz.js:3406 Uncaught <generic error, no stack>
sfrotz.html:195 [post-exception status] Exception thrown, see JavaScript console
sfrotz.js:3406 Uncaught <generic error, no stack>
@sbc100
Copy link
Collaborator

sbc100 commented May 17, 2024

I tried to reproduce this in node that is did show a reasonable error:

$ emcc --pre-js=pre.js test/hello_world.c -sFORCE_FILESYSTEM
$ node a.out.js 

/usr/local/google/home/sbc/dev/wasm/emscripten/a.out.js:134
      throw ex;
      ^
Loading data file "journey-r83-s890706.z6" failed.
(Use `node --trace-uncaught ...` to show where the exception was thrown)

In the browser I see Uncaught Loading data file "journey-r83-s890706.z6" failed. including a full stack trace.

Perhaps I'm misunderstanding something?

@curiousdannii
Copy link
Contributor Author

Huh. I was doing it in the browser. But even in an O0 build with ASSERTIONS on I never saw a specific error like that.

@sbc100
Copy link
Collaborator

sbc100 commented May 17, 2024

Can you share the full set of link flags you are using?

Are you saying you don't see any kind of stack trace in devtools?

@curiousdannii
Copy link
Contributor Author

curiousdannii commented May 18, 2024

There is a stack trace, it's just the main error message that's generic:

sfrotz.js:3593 Uncaught <generic error, no stack>
	(anonymous)	@	sfrotz.js:3593
	staticInit	@	sfrotz.js:3592
	(anonymous)	@	sfrotz.js:9677
	load (async)		
	readAsync	@	sfrotz.js:135
	asyncLoad	@	sfrotz.js:1729
	FS_createPreloadedFile	@	sfrotz.js:1787
	Module.preRun	@	sfrotz.js:41

Line 3593 is from here:

  staticInit() {
        // Some errors may happen quite a bit, to avoid overhead we reuse them (and suffer a lack of stack info)
        [44].forEach((code) => {
          FS.genericErrors[code] = new FS.ErrnoError(code);
          FS.genericErrors[code].stack = '<generic error, no stack>';
        });
  
        FS.nameTable = new Array(4096);
  
        FS.mount(MEMFS, {}, '/');
  
        FS.createDefaultDirectories();
        FS.createDefaultDevices();
        FS.createSpecialDirectories();
  
        FS.filesystems = {
          'MEMFS': MEMFS,
          'IDBFS': IDBFS,
        };
      },
/emsdk/upstream/emscripten/emcc src/common/frotz_common.a src/sdl/frotz_sdl.a src/blorb/blorblib.a 
src/common/frotz_common.a -o sfrotz.js --use-port=freetype --use-port=libjpeg --use-port=libpng
--use-port=sdl2 --use-port=sdl2_mixer --use-port=zlib -lidbfs.js --js-library ../src/frotz-library.js
--pre-js ../src/preamble.js --profiling-funcs -sALLOW_MEMORY_GROWTH -sASYNCIFY
-sENVIRONMENT=web -lm

Maybe ASNCIFY or ENVIRONMENT=web muddles things?

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

No branches or pull requests

2 participants