Compilers aren't supposed to crash — especially not when compiling perfectly valid code like this:
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.25; contract A { function a () public pure returns ( uint256 ) { return 1 ** 2 ; } }
Yet running Solidity's compiler (solc) on this file on a standard Ubuntu 22.04 system (G++ 11.4, Boost 1.74) causes an immediate segmentation fault.
At first, this seemed absurd. The code just returns 1 to the power of 2 — no memory tricks, unsafe casting, or undefined behavior.
And yet, it crashes.
Another minimal example?
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.25; contract A { function a () public pure { uint256 [ 1 ] data; } }
Still crashes.
So what’s going on?
We traced it down to a seemingly unrelated C++ line deep in the compiler backend:
... continue reading