The Solidity development team has officially released version 0.8.36, resolving a medium-severity compiler bug discovered within the Yul optimizer’s call graph analysis system. Identified on May 11, 2026, by team member clonker, the defect caused mutually recursive functions to be incorrectly categorized as non-recursive. This misclassification bypassed vital safety exclusions, improperly exposing complex recursive functions to the compiler’s memory-spilling mechanism and leading to potential data corruption in affected smart contracts.
The vulnerability specifically targets the Intermediate Representation (IR) pipeline, leaving the legacy evmasm pipeline entirely unaffected. Because the flag required to activate the IR pipeline, --via-ir, is not enabled by default, development projects that have not explicitly opted into the modern compilation pathway remain safe from the issue. However, for projects utilizing the IR pipeline, the bug impacts a wide historical range of compiler versions spanning from Solidity 0.7.2 through 0.8.35.
Understanding the Scope and Affected Versions
The root cause of the cycle-detection flaw dates back to a compiler refactor introduced in version 0.6.12. Initially, the flawed analysis logic interacted exclusively with the SideEffectsPropagator, an internal consumer where a function misclassification produces no observable impact on final bytecode. However, the introduction of the StackLimitEvader in Solidity 0.7.2 created a second consumer where accurate call graph analysis is vital. Consequently, version 0.7.2 is marked as the beginning of the affected version range.
While the faulty code path has technically been reachable since version 0.7.2, rigorous testing revealed that precise conditions for actual miscompilation typically manifest from version 0.8.8 onward, or from version 0.8.10 when utilizing the experimental --experimental-via-ir entry point. In earlier iterations, typical reproducers encounter a traditional "Stack too deep" compilation error before the incorrect optimization behavior can structurally surface. Out of an abundance of caution, the Solidity team classifies all versions from 0.7.2 to 0.8.35 as vulnerable.
To gauge potential real-world exposure, researchers conducted a comprehensive automated scan of approximately 207,000 contracts compiled using --via-ir within the Sourcify database. The analysis identified just 272 contracts—representing roughly 0.1% of the scanned repository—containing a function misclassified by the flawed analysis. Crucially, none of these specific contracts relocated variables to memory inside the misclassified function, confirming that no known deployed smart contracts suffered exploitation or active runtime corruption as a result of the bug.
Technical Mechanics of the Stack-to-Memory Mover
To fully grasp the nature of the vulnerability, developers must understand how the Ethereum Virtual Machine (EVM) handles execution context and why the compiler relies on memory-spilling mechanisms. The EVM architecture limits direct stack access to the topmost 16 slots. When a Solidity function declares a high volume of simultaneously live local variables, it frequently exceeds this hardware-enforced threshold, historically resulting in the familiar "Stack too deep" compilation error.
To mitigate this restriction, the IR compilation pipeline integrates a stack-to-memory mover, formally known as the stack limit evader. When a function’s variable footprint exceeds available stack space, the compiler automatically relocates select variables to fixed memory offsets, substituting standard stack operations with low-level mstore and mload instructions directed at those predetermined memory slots.
This optimization technique is fundamentally sound for standard, non-recursive code, but it becomes catastrophic when applied to recursive functions. Because fixed memory offsets are shared statically across every sequential activation of a function, a recursive invocation introduces a severe risk. If a function maintains a variable in a fixed memory slot across an execution call that subsequently re-enters the exact same function—either directly or through an intricate cycle of mutual recursion—the inner activation overwrites the memory slot. When execution returns to the outer activation, the program reads back corrupted, overwritten data. To prevent this, the compiler must categorically exempt any function participating in a recursive call chain from stack-to-memory relocation.
The Flawed Cycle-Detection Logic
Determining whether a function is recursive requires constructing a Yul call graph and running a cycle-detection algorithm to identify strongly connected components. Prior to the 0.8.36 patch, the compiler’s CallGraphGenerator utilized a path-based depth-first search. While traversing the call graph, the algorithm maintained the active path on an internal stack. Upon encountering an invocation pointing to a function already present on that active path, it flagged that function and all intermediate callers as being part of a cycle. Once fully explored, the node was popped and added to a visited set, causing subsequent visits to short-circuit immediately.
This optimization-driven short-circuit proved unsound when handling intersecting cycles. Because the traversal recorded cycles exclusively by checking for edges looping back to functions remaining on the current active stack, fully explored nodes marked as visited were never re-evaluated. Consequently, if a function’s recursive cycle could only be closed by passing through a node that had already finished processing as part of an independent, earlier cycle, the traversal halted prematurely at the finished node. The compiler then incorrectly categorized the target function as non-recursive, despite its active participation in a complex cycle.
This vulnerability manifested in specific architectural patterns, such as a three-way mutual recursion cycle where function a calls b and c, function b calls a, and function c calls b. Within this topology, all three functions belong to a single strongly connected component and are inherently recursive. However, depending on the exact traversal order—which is dictated by internal data structure arrangements derived from Yul name hashes—the algorithm could prematurely mark intermediate nodes as visited, overlooking the overarching cycle and misclassifying the function.
When a complex function containing a high volume of live variables was wrongly classified as non-recursive, the stack-to-memory mover aggressively relocated its local variables to fixed memory offsets. Upon re-entry through the unmasked recursive cycle, these memory slots were overwritten, leading to unhandled data corruption during runtime execution.
Verification and Example Reproducer
Minimal reproducible examples demonstrate how silent corruption could occur without triggering compiler warnings or runtime transaction reverts. In vulnerable configurations, executing a triggered function sequence resulted in stored state variables retaining default initialization values rather than expected computation outputs, because corrupted stack-pointer memory offsets caused subsequent assignment operations to write to incorrect storage indexes.
Because the bug produced silent logical discrepancies rather than explicit transaction failures or compilation warnings, diagnosing the issue in complex production environments could prove challenging. However, development teams maintaining robust automated test suites executed under --via-ir conditions would typically surface the unexpected behavioral deviations during standard pre-deployment validation phases.
The Permanent Fix in Solidity 0.8.36
To permanently resolve the call analysis defect, the Solidity engineering team replaced the legacy path-based depth-first search with Tarjan’s strongly connected components algorithm, a mathematically rigorous and standard graph theory approach. Tarjan’s algorithm partitions the entire call graph in a single, unified pass that is completely independent of traversal ordering.
Under the updated implementation, a function is classified as recursive if and only if it is definitively contained within a strongly connected component comprising multiple nodes or a self-referential edge. This ensures that mutually recursive functions are never misidentified, guaranteeing that the stack-to-memory mover preserves their local variables securely on the execution stack.
As a direct consequence of this correct enforcement, developers upgrading existing complex codebases to Solidity 0.8.36 may occasionally encounter newly surfaced "Stack too deep" compilation errors. The development team emphasizes that this outcome reflects correct compiler behavior rather than a regression. Codebases encountering this error following the upgrade were previously relying on unsound, hazardous memory relocations that risked silent data corruption. Developers facing stack limitations under the updated compiler are advised to refactor their smart contract architecture—such as by modularizing internal helper functions or reducing local variable density—to achieve safe compilation without compromising execution integrity.






