ethereum / solidity

Solidity, the Smart Contract Programming Language
https://soliditylang.org
GNU General Public License v3.0
23.01k stars 5.7k forks source link

Boost exception from emscripten binary: `Testing individual bits in negative values is not supported - results are undefined` #13924

Open Jack-Clark opened 1 year ago

Jack-Clark commented 1 year ago

Running solcjs --bin Test.sol produces:

Unknown exception during compilation: /emsdk/upstream/emscripten/cache/sysroot/usr/include/boost/multiprecision/cpp_int/misc.hpp(243): Throw in function typename enable_if_c<!is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>>::value, unsigned int>::type boost::multiprecision::backends::eval_msb(const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> &) [MinBits1 = 0U, MaxBits1 = 0U, SignType1 = boost::multiprecision::signed_magnitude, Checked1 = boost::multiprecision::unchecked, Allocator1 = std::allocator<unsigned long long>]
Dynamic exception type: boost::wrapexcept<std::range_error>
std::exception::what: Testing individual bits in negative values is not supported - results are undefined.

Here is Test.sol:

contract Test {

    function test() public pure
    {
        (10634634426792001081101511178246987599623141251366189690016263.62 % 1766847064778384329583297500742918515827483896875618958121606201292619775);
    }
}

This compiles successfully when using both v.0.8.15 and v0.8.18 of solc. solc --bin-runtime Test.sol:

======= Test.sol:Test =======
Binary of the runtime part:
6080604052348015600f57600080fd5b506004361060285760003560e01c8063f8a8fd6d14602d575b600080fd5b00fea26469706673582212209f0712d626ee13ac18ddfe6a4900a33bf14d8eae22facc01962e1a3e96f5e95f64736f6c634300080f0033
$ solcjs --version
0.8.16+commit.07a7930e.Emscripten.clang

This was run on Ubuntu 20.04.5 LTS.

cameel commented 1 year ago

Thanks for the report. This looks bad. Something like this should be happening in solc too so I suspect it could be caused by the emscripten binary being built with a different version of boost.

Moving the issue to the main Solidity repo. We'll need to investigate.

GAMECHANGE commented 1 month ago

:)