{"record":{"id":"114b532b9915ef65","repo":"windmill-labs/windmill","slug":"oh-no-114b53","errorCode":null,"errorMessage":"oh no","messagePattern":"oh no","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-java/src/wasm_libc.rs","lineNumber":206,"sourceCode":"    _args: ...\n) -> c_int {\n    panic!(\"vsnprintf is not supported\");\n}\n\n#[no_mangle]\npub extern \"C\" fn clock_gettime(ptr: usize, new_size: usize) {\n    panic!(\"clock_gettime is not supported\");\n}\n\n// int snprintf( char* restrict buffer, size_t bufsz, const char* restrict format, ... );\n#[no_mangle]\npub extern \"C\" fn snprintf() {\n    panic!(\"snprintf is not supported\");\n}\n\n#[no_mangle]\npub extern \"C\" fn __assert_fail(_: *const i32, _: *const i32, _: *const i32, _: *const i32) {\n    panic!(\"oh no\");\n}\n","sourceCodeStart":188,"sourceCodeEnd":208,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-java/src/wasm_libc.rs#L188-L208","documentation":"__assert_fail in the windmill-parser-java WASM libc shim is a stub that panics with the unhelpful message \"oh no\". In real libc, __assert_fail is invoked when a C assert() macro fails; here it means the compiled tree-sitter C code hit a failed assertion at runtime. The stub ignores the assertion message, file, line and function arguments (typed as *const i32), so the real cause is lost.","triggerScenarios":"C code inside the WASM parser (tree-sitter runtime or a custom scanner) evaluates assert(expr) with a false expression, causing the linker to call __assert_fail, which unconditionally panics with \"oh no\".","commonSituations":"Malformed or truncated input that drives the scanner into an invalid state; a corrupted/misaligned pointer caused by another shim bug (e.g. the layout-prepended allocator or a stubbed stdio function returning garbage); a grammar version whose assertions no longer hold in the sandboxed environment.","solutions":["Improve the stub to surface diagnostics first: read the assert message/file/line pointers and include them in the panic, so you know which assertion failed.","Reproduce with the same input document and check whether the input is malformed, truncated, or not valid UTF-8/ASCII where the scanner expects it.","Audit the other libc stubs: a prior panic or bogus return value from fprintf/snprintf/fwrite stubs can corrupt state that later trips an assert — fix the root stub, not just the assert.","Pin or upgrade the tree-sitter-java grammar version to one known to run cleanly under the WASM shim set."],"exampleFix":"// before (wasm_libc.rs)\n#[no_mangle]\npub extern \"C\" fn __assert_fail(_: *const i32, _: *const i32, _: *const i32, _: *const i32) {\n    panic!(\"oh no\");\n}\n\n// after — surface the real assertion message\n#[no_mangle]\npub unsafe extern \"C\" fn __assert_fail(\n    assertion: *const c_char,\n    file: *const c_char,\n    line: c_int,\n    _func: *const c_char,\n) {\n    let msg = if assertion.is_null() { \"?\" } else { std::ffi::CStr::from_ptr(assertion).to_string_lossy().into_owned() };\n    let f = if file.is_null() { \"?\" } else { std::ffi::CStr::from_ptr(file).to_string_lossy().into_owned() };\n    panic!(\"assertion failed: {} ({}:{})\", msg, f, line);\n}","handlingStrategy":"try-catch","validationCode":"// Pre-check input shape before handing it to the parser to reduce\n// odds of driving the scanner into assertion territory:\nfunction validateJavaDoc(doc) {\n  if (typeof doc !== 'string') return false;\n  // reject NUL bytes / obviously truncated content that scanners choke on\n  return !doc.includes('\\u0000');\n}","typeGuard":"function isStringDoc(doc) {\n  return typeof doc === 'string' && !doc.includes('\\u0000');\n}","tryCatchPattern":"let result;\ntry {\n  result = parser.parse(doc);\n} catch (e) {\n  if (String(e).includes('oh no')) {\n    // assertion failed in C code; message is opaque — recreate parser,\n    // log the offending document for reproduction, and skip/queue it\n    parser = new Parser();\n    quarantine(doc);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Improve the __assert_fail shim to include the assertion text and file:line so failures are diagnosable — an opaque \"oh no\" makes every incident a guessing game.","Sanitize inputs (strip NUL bytes, ensure well-formed text) before parsing.","Keep parser instances per-request/per-worker; never reuse one that panicked.","Upgrade the shim plus grammar together; mismatches between scanner ABI and runtime surface as assertions."],"tags":["wasm","libc","assert","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"}