Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE during Natspec generation when emitting an event from a foreign contract or interface #14430

Closed
Amxx opened this issue Jul 19, 2023 · 6 comments · Fixed by #14434
Closed
Assignees
Labels
bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. medium impact Default level of impact selected for development It's on our short-term development should compile without error Error is reported even though it shouldn't. Source is fine.
Milestone

Comments

@Amxx
Copy link

Amxx commented Jul 19, 2023

I moves the OZ contract repo to 0.8.21 to benefit from the new language features, but I'm getting the following error:

Internal exception in StandardCompiler::compile: /solidity/libsolidity/interface/Natspec.cpp(85): Throw in function static Json::Value solidity::frontend::Natspec::userDocumentation(const solidity::frontend::ContractDefinition&)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: Solidity assertion failed
[solidity::util::tag_comment*] = Solidity assertion failed

Environment

  • Compiler version: 0.8.21
  • Target EVM version (as per compiler settings): shanghai
  • Framework/IDE (e.g. Truffle or Remix): hardhat
  • EVM execution environment / backend / blockchain client: hardhat node
  • Operating system: linux

Steps to Reproduce

Minimal example:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

interface I {
    event E();
}

library L {
    function f() internal {
        emit I.E();
    }
}

contract C {
    function g() public {
        L.f();
    }
}
@Amxx Amxx added the bug 🐛 label Jul 19, 2023
@Amxx
Copy link
Author

Amxx commented Jul 19, 2023

This is the assert that fails:

solAssert(
	*eventOrigin == _contractDef ||
	(!eventOrigin->isLibrary() && _contractDef.derivesFrom(*eventOrigin)) ||
	(eventOrigin->isLibrary() && !_contractDef.derivesFrom(*eventOrigin))
);

In my case the event is declared in an interface and used (emited) by a library. Please don't tell me that is not supported ...

@Amxx Amxx changed the title 0.8.21 causes Internal exception in StandardCompiler::compile Solidity assertion failed when emitting an Interface event from a library Jul 19, 2023
@blitz-1306
Copy link

This happends when using WASM and linux-native compilers.

@blitz-1306
Copy link

blitz-1306 commented Jul 20, 2023

@Amxx It is not only libraries. I get the same error with even more minimalistic example:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

contract X {
    event E();
}

contract C {
    function g() public {
        emit X.E();
    }
}

Results:

Internal exception in StandardCompiler::compile: /solidity/libsolidity/interface/Natspec.cpp(89): Throw in function static Json::Value solidity::frontend::Natspec::userDocumentation(const ContractDefinition &)
Dynamic exception type: boost::wrapexcept<solidity::langutil::InternalCompilerError>
std::exception::what: Solidity assertion failed
[solidity::util::tag_comment*] = Solidity assertion failed

It seems to happen when event is referenced with qualifier.

@nikola-matic
Copy link
Collaborator

nikola-matic commented Jul 20, 2023

This is the assert that fails:

solAssert(
	*eventOrigin == _contractDef ||
	(!eventOrigin->isLibrary() && _contractDef.derivesFrom(*eventOrigin)) ||
	(eventOrigin->isLibrary() && !_contractDef.derivesFrom(*eventOrigin))
);

In my case the event is declared in an interface and used (emited) by a library. Please don't tell me that is not supported ...

Heya, so obviously, the compiler throwing an ICE is generally going to be considered a bug - however, the snippets that both you and @blitz-1306 posted do compile without throwing an ICE. Also, looking at the ICE, it's thrown in Natspec, and I can reproduce it by requesting user docs, i.e. solc --userdoc test.sol, so it's more of a Natspec bug than an event bug by the looks of it.

In any case, fix is on the way.

edit: same issue is present when requesting --devdoc, due to the same failing assertion.

@cameel cameel added should compile without error Error is reported even though it shouldn't. Source is fine. selected for development It's on our short-term development low effort There is not much implementation work to be done. The task is very easy or tiny. medium impact Default level of impact labels Jul 20, 2023
@NunoFilipeSantos NunoFilipeSantos added this to the 0.8.22 milestone Jul 20, 2023
@cameel cameel changed the title Solidity assertion failed when emitting an Interface event from a library ICE during Natspec generation when emitting an event from a foreign contract or interface Jul 20, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Solidity Focus Board Jul 21, 2023
@pcaversaccio
Copy link

You claim that compilation works fine but I'm having a hard time making a contract compile (without userdoc or devdoc), however; let's take the following contract (Test.sol):

// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

contract X {
    event E();
}

contract C {
    function g() public {
        emit X.E();
    }
}

Now invoking something like solc --asm .\Test.sol (not requesting userdoc nor devdoc), will still throw:

Internal compiler error:
C:\Users\circleci\project\libsolidity\interface\Natspec.cpp(89): Throw in function class Json::Value __cdecl solidity::frontend::Natspec::userDocumentation(const class solidity::frontend::ContractDefinition &)
Dynamic exception type: struct boost::wrapexcept<struct solidity::langutil::InternalCompilerError>
std::exception::what: Solidity assertion failed
[struct solidity::util::tag_comment * __ptr64] = Solidity assertion failed

Can you elaborate on what am doing wrong? The version I used is the Windows one 0.8.21+commit.d9974bed.Windows.msvc but I get the similar behaviour on Ubuntu & Debian.

@pcaversaccio
Copy link

pcaversaccio commented Jul 24, 2023

Cross-posting the answer by @nikola-matic here for clarity:

In that case nothing - essentially, any steps that require userdoc or devdoc (asm, metadata, etc.) will indeed fail - I was just commenting in case you just read the issue and didn't try to compile anything. I guess you'll have to wait for the 0.8.22 release like most everyone else :)

sklppy88 added a commit to AztecProtocol/aztec-packages that referenced this issue Mar 11, 2024
comments

comments

fix

fix

comments

comments

comments

test

test

comment

ethereum/solidity#14430

comments

test

comments

liberryfy

test

asdf

add manual test

asdf

test

fix

asdf

asdf

comments

comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. medium impact Default level of impact selected for development It's on our short-term development should compile without error Error is reported even though it shouldn't. Source is fine.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants