Function with declared non-void return type and a bare return; crashes LLVM inliner (SIGABRT/SIGSEGV) in Soroban emit
Part of #1999 — soroban-emit-multifuzz-v2 campaign tracking issue
Solang version: confirmed on public v0.3.5 CLI (solang compile --target soroban) Target: Soroban Crash type: SIGABRT (LLVM assertion failure in debug builds) — the same root cause also produces SIGSEGV on other inputs (no assertion text, straight null-pointer dereference), confirming assertions are simply masking/unmasking the same underlying invalid-IR bug depending on build configuration.
Summary
A function that declares a non-void return type but executes a bare return; (no expression) crashes the compiler during the Soroban emit pass, inside LLVM's inliner. This happens regardless of whether the bare return is the only statement, guarded by a branch, or followed by other reachable/unreachable code - the only requirement is that a bare return; executes on some path through a function whose signature promises a value.
Minimal repro
contract Test {
function foo() public returns (uint64) {
return;
}
}
Crash output
warning: function can be declared 'pure'
solang: llvm/lib/IR/Value.cpp:502: void llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses): Assertion New && "Value::replaceAllUsesWith(<null>) is invalid!" failed.
Root cause
A bare return; is accepted by semantic analysis when it shouldn't be, given the function's signature promises a value. That gap surfaces downstream as invalid LLVM IR - a return with no value where LLVM expects one - which the inliner's RAUW (replace-all-uses-with) step chokes on when it tries to substitute the call site with the (missing) return value.
Confirmed via two separate fuzzer-found real-world contracts (one array-based, one plain arithmetic) hitting the exact same crash site in LLVM's InlineFunction, strong confirmation this is one root cause, not a coincidence. Confirmed it's specifically the combination of (declared return type) plus (a bare return; that actually executes) - doesn't matter if it's guarded by an if, doesn't matter what comes after it.
Why this matters
Solang is emitting genuinely invalid LLVM IR here, not just crashing on its own Rust-side logic - in a release build without assertions this could plausibly silently miscompile instead of crashing at all.
Found via fuzzing
Discovered via AFL++ fuzzing campaign (soroban-emit-multifuzz-v2), including a real-world push_pop()-style array-crash sample and a plain-arithmetic sample hitting the identical crash site.