rahulchaphalkar added the bug label to Issue #6923.
rahulchaphalkar opened issue #6923:
Test Case
Modified
examples/gcd.c
to utilize C-API as directed hereint main() { int ret = 0; // Set up our context //wasm_engine_new(); wasm_config_t* wasmtime_configuration = wasm_config_new(); wasmtime_config_profiler_set(wasmtime_configuration, WASMTIME_PROFILING_STRATEGY_VTUNE); wasm_engine_t *engine = wasm_engine_new_with_config(wasmtime_configuration); assert(engine != NULL); wasmtime_store_t *store = wasmtime_store_new(engine, NULL, NULL); assert(store != NULL); wasmtime_context_t *context = wasmtime_store_context(store);
Steps to Reproduce
Add VTune feature to c-api crate's Cargo.toml
wasmtime/crates/c-api/Cargo.toml
:[features] . . . vtune = ["wasmtime/vtune"]
Build wasmtime-c-api
cargo build --release -p wasmtime-c-api --features vtune
Build gcd binary :
cc examples/gcd.c \ -I crates/c-api/include \ -I crates/c-api/wasm-c-api/include \ target/release/libwasmtime.a \ -lpthread -ldl -lm \ -o gcd
Now, run the binary by launching it with VTune, from command line it like below -
vtune -collect hotspots -knob sampling-mode=hw -r out_dir ./gcd
Expected Results
VTune runs to completion with no errors from gcd binary, and then VTune shows [Dynamic Code] module with wasm functions inside it.
Actual Results
GCD binary does not run to completion. Normal execution time is a few seconds (I had loops inside of the original gcd.c, tested without vtune hooks) , this one crashes in a second or so with following output from VTune, with data file corrupted.
vtune -collect hotspots -knob sampling-mode=hw -r vtune-gcd-hardcoded2 ./gcd-mod vtune: Warning: To enable hardware event-based sampling, VTune Profiler has disabled the NMI watchdog timer. The watchdog timer will be re-enabled after collection completes. vtune: Collection started. To stop the collection, either press CTRL-C or enter from another console window: vtune -r /home/oem/public_repos/wasmtime/vtune-gcd-hardcoded2 -command stop. vtune: Collection stopped. vtune: Using result path `/home/oem/public_repos/wasmtime/vtune-gcd-hardcoded2' vtune: Executing actions 12 % Loading 'userapicollector-2992789-09cf7a40.trace' vtune: Error: Cannot load data file `/home/oem/public_repos/wasmtime/vtune-gcd-hardcoded2/data.0/userapicollector-2992789-09cf7a40.trace' (Data file is corrupted). vtune: Executing actions 19 % Resolving information for `libittnotify_collector
Versions and Environment
Wasmtime version or commit: Main branch, commit
8efcb9851602287fd07a1a1e91501f51f2653d7e
Operating system: Ubuntu
Architecture: x86
Extra Info
- The above failure actually does produce .JIT file in VTune directory.
- When no VTune collection is ongoing, and you simply run
./gcd
, we get the following errorRUST_BACKTRACE=FULL ./gcd thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: error when notifying event', crates/jit/src/profiling/vtune.rs:57:14 stack backtrace: 0: rust_begin_unwind at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/panicking.rs:593:5 1: core::panicking::panic_fmt at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/panicking.rs:67:14 2: core::result::unwrap_failed at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/result.rs:1651:5 3: core::result::Result<T,E>::unwrap at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/result.rs:1076:23 4: wasmtime_jit::profiling::vtune::State::notify_code at ./crates/jit/src/profiling/vtune.rs:51:9 5: wasmtime_jit::profiling::vtune::State::register_function at ./crates/jit/src/profiling/vtune.rs:78:9 6: <wasmtime_jit::profiling::vtune::VTuneAgent as wasmtime_jit::profiling::ProfilingAgent>::register_function at ./crates/jit/src/profiling/vtune.rs:69:9 7: wasmtime_jit::profiling::ProfilingAgent::register_module at ./crates/jit/src/profiling.rs:92:17 8: wasmtime_jit::instantiate::CompiledModule::register_debug_and_profiling at ./crates/jit/src/instantiate.rs:481:9 9: wasmtime_jit::instantiate::CompiledModule::from_artifacts at ./crates/jit/src/instantiate.rs:468:9 10: wasmtime::module::Module::from_parts_raw at ./crates/wasmtime/src/module.rs:577:22 11: wasmtime::module::Module::from_parts at ./crates/wasmtime/src/module.rs:568:9 12: wasmtime::module::Module::from_binary at ./crates/wasmtime/src/module.rs:333:16 13: wasmtime_module_new at ./crates/c-api/src/module.rs:140:9 14: main at ./examples/gcd.c:70:11 15: __libc_start_main at /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16 16: _start note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. fatal runtime error: failed to initiate panic, error 5 Aborted (core dumped)
- Looks somewhat similar to what @abrown reported for CLI https://github.com/bytecodealliance/wasmtime/issues/5628
Last updated: Nov 22 2024 at 16:03 UTC