Home / Smart Contract Auditing / Solidity v0.8.39 Released: Critical Storage Bug Fixes, New EVM Limits, and the Final Step Before Solidity 0.9.0

Solidity v0.8.39 Released: Critical Storage Bug Fixes, New EVM Limits, and the Final Step Before Solidity 0.9.0

The development team behind Solidity, the leading programming language for writing smart contracts on the Ethereum blockchain and compatible networks, has officially announced the release of Solidity v0.8.39. This latest update introduces vital bug fixes for critical storage and compilation issues, adds experimental support for new Ethereum Improvement Proposals related to contract size limits, and paves the way for the much-anticipated transition to the Solidity 0.9.0 development series. As likely the final installment in the long-running 0.8 version cycle, v0.8.39 brings crucial stability improvements while signaling a major strategic shift in how future breaking changes and compiler releases will be handled.

Important Bugfixes

The v0.8.39 release addresses two noteworthy compilation bugs, the most severe of which involves a medium-severity storage corruption flaw.

Overlapping Recursive Storage Struct Copy Corruption

A significant focus of the new release is the remediation of a medium-severity bug that could silently corrupt contract storage under specific conditions. The issue manifested when a recursive struct—a data structure that can contain values of its own type, such as a node containing an array of child nodes—was copied within storage to a location that overlapped with or contained the source. Examples of this pattern include common state updates such as root = root.children[0] or roots = roots[0].children, where individual nodes or arrays of nodes are manipulated directly in storage.

Because the overlap was not always immediately apparent in the assignment syntax—especially when the source data was accessed through storage pointers, mapping keys, or array indices—the compiler could initiate a storage-to-storage copy that rewrote the storage area holding the source before the copy operation had finished reading it. As a result, nested elements within the source were lost entirely, and members declared after the array were silently reset to zero. Critically, the compiler reported no errors or warnings during this process.

The bug affected both the traditional evmasm pipeline and the modern IR (Intermediate Representation) pipeline, independent of optimizer settings or target EVM versions. For the evmasm pipeline, versions 0.4.9 through 0.8.38 were vulnerable, while the IR pipeline was affected across versions 0.8.13 through 0.8.38.

To resolve this safely, the Solidity team implemented a runtime check for every storage-to-storage copy involving a recursive struct or an array of recursive structs. While this guarantees data integrity, it introduces a minor gas overhead even when the source and target do not overlap. Additionally, because the runtime check utilizes stack space while traversing the target structure, copies into deeply nested targets may encounter stack-depth limitations sooner than before. In benchmark testing using the via-ir pipeline and the optimizer enabled, the maximum nesting depth dropped from 252 levels down to 126 levels.

Despite the broad version vulnerability window, automated scans of verified smart contracts deployed within the Sourcify database revealed no instances of active contracts performing an affected copy in production. The vulnerability was responsibly discovered and reported by security researcher cyberthirst through the Ethereum Foundation’s official bug bounty program. A detailed technical write-up has been published to accompany the release.

Other Miscompilations

In addition to the recursive storage bug, the v0.8.39 update resolves a miscompilation issue within the evmasm pipeline regarding nested tuple assignments. Under specific and uncommon circumstances, a tuple assignment could assign values to the wrong target variables. This behavior was triggered when a nested tuple on the right-hand side of an assignment contained a string literal alongside another value, and that literal was assigned to a bytes32, bytes, or string variable.

For instance, given variables of type bytes32 z and uint256 a, the assignment statement ((z, a), b) = (("x", 111), 222) incorrectly assigned 111 to z and the encoded string literal bytes32("x") to a, without generating any compilation errors or warnings. The IR pipeline remains unaffected by this issue, and optimizer configurations do not influence the behavior.

The Solidity team does not classify this miscompilation as a security vulnerability because the required coding pattern is highly unusual and rarely encountered in real-world smart contract development. Nested tuple assignments are primarily utilized for capturing multi-value returns from function calls, and standard function calls cannot return string literals. Furthermore, standard testing frameworks and integration suites would typically catch unexpected value swaps or out-of-gas reverts resulting from corrupted memory or calldata references.

Notable Features and Changes

Beyond bug remediation, Solidity v0.8.39 introduces important updates regarding EVM code size limits and experimental debugging tools.

When compiling contracts using the experimental –evm-version amsterdam flag, the compiler now issues warnings for contract bytecode exceeding 64 KiB and initcode exceeding 128 KiB. These thresholds align with upcoming protocol upgrades outlined in EIP-7954, which raises the legacy EIP-170 code size limit from 24 KiB to 64 KiB, and EIP-3860, which increases the initcode limit from 48 KiB to 128 KiB. For all other EVM versions, including Osaka, which remains the current default, warning thresholds adhere to traditional limits. Support for the Amsterdam EVM version itself remains experimental.

Additionally, the compiler now extends code size warnings to standalone Yul code compilation, mirroring the diagnostics already provided for standard Solidity source files.

ethdebug Type and Layout Information (Experimental)

The release also advances experimental tooling by introducing the –ethdebug-resources flag. This option instructs the compiler to emit the full info/resources schema defined by the ethdebug format specification. This schema provides external debuggers with detailed structural descriptions of types and their underlying memory or storage layouts, serving as an essential prerequisite for passing comprehensive debugging metadata through the Yul pipeline. Use of ethdebug output remains experimental and must be explicitly enabled using the –experimental flag.

Solidity 0.9.0 and the Future Release Schedule

For several years, the Solidity core team envisioned version 0.9.0 as a massive breaking release centered around making the modern IR pipeline the default code generator. Because of this perception, many developers anticipated that upgrading to 0.9.0 would require sweeping code rewrites across the ecosystem.

However, the team has updated its roadmap. While making the IR pipeline and the newer SSA CFG code generator the default remains a primary goal, these architectural transitions are no longer strictly tied to the 0.9.0 version milestone. Tying structural pipeline changes to a single major version had previously delayed other incremental breaking changes that the team was eager to introduce.

Moving forward, the Solidity project plans to adopt a more agile release cadence, delivering smaller and more frequent breaking releases. Under this revised approach, version numbers alone will no longer convey the scale of breaking modifications in a given update. More frequent breaking releases will allow the team to efficiently prune legacy features that were preserved throughout the extended 0.8 release lifecycle. A dedicated post outlining the new release schedule and its underlying rationale is forthcoming.

Most of the code changes merged thus far in preparation for 0.9.0 focus on deprecating and removing legacy features inherited from earlier 0.8 releases. Notable removals include ABI coder v1, virtual modifiers, the legacy ABIEncoderV2 pragma, the SMTChecker’s BMC verification engine, and support for EVM versions older than Constantinople. The team intends to publish a public pre-release of version 0.9.0 prior to the final rollout.

How to Install and Upgrade

Developers and smart contract engineers looking to upgrade to Solidity v0.8.39 can consult the official installation documentation provided by the Solidity team. Binaries and pre-compiled packages are available directly through the project’s GitHub repository.

When building the compiler from source code, developers are strongly advised to avoid utilizing the automatically generated source archives provided by GitHub, as these may lack necessary submodules or build dependencies. Instead, users should download the official solidity_0.8.39.tar.gz source tarball or check out the tagged v0.8.39 release via Git.

Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *