{"record":{"id":"1ad25eac2ecab1cb","repo":"windmill-labs/windmill","slug":"aborted-from-c-1ad25e","errorCode":null,"errorMessage":"Aborted from C","messagePattern":"Aborted from C","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-r/src/wasm_libc.rs","lineNumber":15,"sourceCode":"use std::collections::BTreeMap;\nuse std::sync::{Mutex, OnceLock};\nuse std::{\n    alloc::{self, Layout},\n    ffi::{c_char, c_int, c_void},\n    mem::align_of,\n    ptr,\n};\nuse wasm_bindgen::prelude::*;\n\n/* -------------------------------- stdlib.h -------------------------------- */\n\n#[no_mangle]\npub unsafe extern \"C\" fn abort() {\n    panic!(\"Aborted from C\");\n}\n\nmacro_rules! console_log {\n    ($($t:tt)*) => (unsafe { log(&format_args!($($t)*).to_string()) })\n}\n\n#[wasm_bindgen]\nextern \"C\" {\n    #[wasm_bindgen(js_namespace = console)]\n    fn log(a: &str);\n}\n\n#[no_mangle]\npub unsafe extern \"C\" fn malloc(size: usize) -> *mut c_void {\n    if size == 0 {\n        return ptr::null_mut();\n    }\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-r/src/wasm_libc.rs#L1-L33","documentation":"The windmill-parser-r WASM module provides abort() as a libc shim that panics with \"Aborted from C\". When the C code compiled into the parser (tree-sitter runtime or scanner) calls abort(), the panic converts the C abort into a Rust panic that terminates the parse. This is a deliberate translation: the WASM sandbox has no real libc, so abort cannot actually terminate a process.","triggerScenarios":"Any C code path in the R parser that calls abort(): failed internal invariant checks in the tree-sitter C runtime, custom scanner error handling that gives up, or an assertion path that funnels into abort() instead of __assert_fail.","commonSituations":"Parsing pathological or very large R input that drives the grammar into an unexpected state; a scanner version mismatch with the tree-sitter runtime ABI; memory corruption earlier in the parse (e.g. from an incomplete shim such as a panicking fprintf/snprintf) that later triggers abort.","solutions":["Identify which C call site invokes abort() by building the parser with debug symbols or instrumenting the shim to log a wasm backtrace before panicking.","Validate/normalize the R input being parsed; try a minimal snippet to find the construct that trips the abort.","Check for an earlier panic in the same parse (fprintf/snprintf/clock stubs) that left state inconsistent — fix that root cause.","Align the tree-sitter runtime and grammar versions so scanner and runtime ABIs match."],"exampleFix":"// before (wasm_libc.rs)\n#[no_mangle]\npub unsafe extern \"C\" fn abort() {\n    panic!(\"Aborted from C\");\n}\n\n// after — log a backtrace before panicking to find the C call site\n#[no_mangle]\npub unsafe extern \"C\" fn abort() {\n    console_log!(\"abort() called from C\");\n    panic!(\"Aborted from C\");\n}","handlingStrategy":"try-catch","validationCode":"// Guard the entry point and isolate each parse:\nfunction prepareDoc(src) {\n  if (typeof src !== 'string' || src.length === 0) {\n    throw new TypeError('expected non-empty string document');\n  }\n  return src;\n}","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.length > 0;\n}","tryCatchPattern":"try {\n  const tree = parser.parse(prepareDoc(src));\n  return tree;\n} catch (e) {\n  if (String(e).includes('Aborted from C')) {\n    // C-level abort: recreate the parser and treat this document as unparseable\n    parser = new Parser();\n    return null;\n  }\n  throw e;\n}","preventionTips":["Instrument the abort shim to capture a wasm backtrace so the C call site is identifiable on first occurrence.","Bisect the failing document down to a minimal snippet and report it to the grammar maintainers.","Keep the tree-sitter runtime and grammar versions in lockstep; ABI mismatch is a classic abort source.","Treat any earlier shim panic in the same parse as the likely root cause — fix upstream stubs, not the abort itself."],"tags":["wasm","libc","abort","tree-sitter"],"backgroundTag":"wasm-libc-stub-panic","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}