64 lines
1.8 KiB
Markdown
64 lines
1.8 KiB
Markdown
# XML tree-sitter Grammar Wasm Crash Reproduction
|
|
|
|
For: <https://github.com/tree-sitter/tree-sitter/issues/4813>
|
|
|
|
## Run
|
|
|
|
```
|
|
cargo r -- ChaoYanZeCuHeiTif-1.xml
|
|
```
|
|
|
|
With `~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tree-sitter-0.25.9/src/wasm_store.c`
|
|
patched to enable the log messages on wasm errors
|
|
|
|
```c
|
|
wasmtime_error_t *error = wasmtime_func_call_unchecked(context, &func, args_and_results, args_and_results_len, &trap);
|
|
if (error) {
|
|
wasm_message_t message;
|
|
wasmtime_error_message(error, &message);
|
|
fprintf(
|
|
stderr,
|
|
"error in wasm module: %.*s\n",
|
|
(int)message.size, message.data
|
|
);
|
|
wasmtime_error_delete(error);
|
|
self->has_error = true;
|
|
} else if (trap) {
|
|
wasm_message_t message;
|
|
wasm_trap_message(trap, &message);
|
|
fprintf(
|
|
stderr,
|
|
"trap in wasm module: %.*s\n",
|
|
(int)message.size, message.data
|
|
);
|
|
wasm_trap_delete(trap);
|
|
self->has_error = true;
|
|
}
|
|
```
|
|
|
|
this output is seen:
|
|
|
|
```
|
|
Running `target/debug/zed-ts-wasm /home/wmoore/Work/prince/ChaoYanZeCuHeiTif-1.ttx`
|
|
trap in wasm module: error while executing at wasm backtrace:
|
|
0: 0x649 - stdlib.wasm!memcpy
|
|
1: 0x4900 - <unknown>!tree_sitter_xml_external_scanner_serialize
|
|
|
|
Caused by:
|
|
wasm trap: out of bounds memory access
|
|
trap in wasm module: error while executing at wasm backtrace:
|
|
0: 0x3a2 - stdlib.wasm!free
|
|
1: 0x49b8 - <unknown>!tree_sitter_xml_external_scanner_deserialize
|
|
|
|
Caused by:
|
|
0: memory fault at wasm address 0x70796c43 in linear memory of size 0x430000
|
|
1: wasm trap: out of bounds memory access
|
|
|
|
thread 'main' panicked at src/main.rs:24:50:
|
|
unable to parse
|
|
```
|
|
|
|
## Notes
|
|
|
|
The wasm module was generated by Zed and copied from:
|
|
`~/.local/share/zed/extensions/installed/xml/grammars/xml.wasm`.
|