ekiwi / wellen

wellen: waveform datastructures in Rust. Fast VCD, FST and GHW parsing for waveform viewers.
BSD 3-Clause "New" or "Revised" License
41 stars 8 forks source link

Small FST crash in WASM with "no filesystem on this platform" #25

Closed TheZoq2 closed 1 month ago

TheZoq2 commented 2 months ago

dump.zip

This file works in the desktop version but fails to load in the WASM version of surfer with

panicked at library/std/src/sys/pal/wasm/../unsupported/os.rs:108:5:
no filesystem on this platform

I'm not sure why the fst loader would need file system, and I will try to look into how to actually debug wasm files so we can find the root cause of this

TheZoq2 commented 2 months ago

image

Oh, there is a not totally useless backtrace here when running in debug mode. The lack of source locations is a bit annoying but it seems like it is trying to create a temporary file while loading fst

TheZoq2 commented 2 months ago

https://github.com/ekiwi/fst-native/blob/main/src/reader.rs#L254

Ah, there it is...

I guess on the web version we need a non-file based solution, could we just create a Vec instead if we're on wasm?

ekiwi commented 2 months ago

Awesome job debugging this! Thanks

TheZoq2 commented 1 month ago

Seems like it is still a problem

panicked at library/std/src/sys/pal/wasm/../unsupported/os.rs:108:5:
no filesystem on this platform

Stack:

__wbg_get_imports/imports.wbg.__wbg_new_6237e0bd840454fb@http://127.0.0.1:8080/surfer.js:578:21
surfer-3371ecb17e25c65f.wasm.surfer::wasm_panic::Error::new::hba0718a6bb1f957f@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[23784]:0x172d905
surfer-3371ecb17e25c65f.wasm.surfer::wasm_panic::panic_hook::h62a24dc56ea6f5e4@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[4389]:0x10ecf0f
surfer-3371ecb17e25c65f.wasm.surfer::wasm_panic::set_once::{{closure}}::{{closure}}::he4fae6ff3e41daf2@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[28314]:0x1783a53
surfer-3371ecb17e25c65f.wasm.eframe::web::panic_handler::PanicHandler::install::{{closure}}::hdc0902d629f7bbcb@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[7557]:0x135e631
surfer-3371ecb17e25c65f.wasm.std::panicking::rust_panic_with_hook::h33fe77d38d305ca3@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[15490]:0x160f7b5
surfer-3371ecb17e25c65f.wasm.std::panicking::begin_panic_handler::{{closure}}::h98de848d678bad07@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[18537]:0x1699616
surfer-3371ecb17e25c65f.wasm.std::sys::backtrace::__rust_end_short_backtrace::h2bcfc60c3cf0a312@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[37671]:0x17eeaf1
surfer-3371ecb17e25c65f.wasm.rust_begin_unwind@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[25623]:0x1753741
surfer-3371ecb17e25c65f.wasm.core::panicking::panic_fmt::hde8b7aa66e2831e1@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[26864]:0x176afcb
surfer-3371ecb17e25c65f.wasm.std::env::temp_dir::h64775a21a74dca27@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[33934]:0x17d1be1
surfer-3371ecb17e25c65f.wasm.tempfile::env::temp_dir::h4c6879f935e23c9c@http://127.0.0.1:8080/surfer_bg.wasm:wasm-function[15723]:0x161bac3

Looks like the error here is a panic not a Result<_>, so we may have to do a compile time check for #[target_arch = "wasm32"] instead of the dynamic check

ekiwi commented 1 month ago

Oh, it looks like this panic isn't actually from tempfile but from the wasm runtime, correct?

TheZoq2 commented 1 month ago

Yeah, looks like it

ekiwi commented 1 month ago

:(

Next attempt: https://github.com/ekiwi/fst-native/commit/1fc8fd7f69a0b3e59c12f56cf83e92e589f134d2

ekiwi commented 1 month ago

@TheZoq2 : please try this out: https://gitlab.com/surfer-project/surfer/-/merge_requests/487

TheZoq2 commented 1 month ago

That one works better, thanks!

ekiwi commented 1 month ago

Thanks for tracking all of this down!