solang icon indicating copy to clipboard operation
solang copied to clipboard

Compiler panics instead of a clean error when function/parameter names exceed Soroban's 32-byte spec limit

Open ahmadsamehh opened this issue 3 months ago • 0 comments

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: Rust panic (panic!() / .expect() on a try_into() failure), exit code 101

Summary

When a Solidity function name (or function parameter name) exceeds 32 bytes, Solang panics with an unhandled Rust panic instead of returning a normal compiler diagnostic, when compiling for the soroban target. The 32-byte limit itself is a real, correctly-detected Soroban protocol constraint - the on-chain contract spec metadata uses a fixed-capacity string type for function/parameter names. The bug is purely in how the failure is handled: panic!() / .expect() instead of a proper Diagnostic error.

Severity / impact

Any contract with a function name, or a function parameter name, longer than 32 bytes fails to compile with an unhandled panic and a raw Rust backtrace, instead of a clear "name too long" diagnostic pointing at the offending declaration. 100% reproducible, deterministic; exact threshold confirmed at 32 bytes. Confirmed to affect both the function-name check and the parameter-name check (two separate call sites, same pattern - one uses .expect(), one uses .unwrap_or_else(|_| panic!(...)), functionally identical).

Root cause

try_into() fails (returns Err) when the string exceeds the target type's fixed capacity. Solang's code just panic!()s / .expect()s on that Err instead of returning a proper compile-time Diagnostic, even though the overflow is legitimately detected.

Found via fuzzing

Discovered via AFL++ fuzzing campaign (soroban-emit-multifuzz-v2); confirmed reproducible on both Solang v0.3.4 and v0.3.5.

ahmadsamehh avatar Aug 20 '26 11:08 ahmadsamehh