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

Crash when using struct as external function parameter using ABIEncoderV2 #4714

Closed
mattaereal opened this issue Aug 6, 2018 · 6 comments
Closed
Labels

Comments

@mattaereal
Copy link
Contributor

mattaereal commented Aug 6, 2018

This issue is being reported as part of the current audit being held by Zeppelin Solutions to Solidity's compiler (tag v0.4.24).

Description

Compiler crashes when using a struct as a parameter for an external function, with pragma experimental ABIEncoderv2.

Error in file

Empty message.
libsolidity/codegen/ABIFunctions.cpp(1268)

Displayed message

Unimplemented feature.
Throw in function std::__cxx11::string dev::solidity::ABIFunctions::abiDecodingFunctionStruct(const dev::solidity::StructType&, bool)

Example code

pragma experimental ABIEncoderV2;                                                                                                              
pragma solidity ^0.4.24;                                                                                                                       
                                                                                                                                              
library Test {                                                                                                                                 
   struct Nested { }                                                                                                                          
   function Y(Nested a) external {}                                                                                                           
}
@axic
Copy link
Member

axic commented Aug 6, 2018

In this form this is now longer allowed in 0.5.0:

4714.sol:5:4: Error: Defining empty structs is disallowed.
   struct Nested { }                                                                                                                          
   ^---------------^

Adding a member (uint a;) to the struct still produces the unimplemented feature exception:

Unimplemented feature:
/Users/alex/Projects/solidity/libsolidity/codegen/ABIFunctions.cpp(1268): Throw in function std::__1::string dev::solidity::ABIFunctions::abiDecodingFunctionStruct(const dev::solidity::StructType &, bool)
Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::UnimplementedFeatureError>
std::exception::what: 
[dev::tag_comment*] = 

@axic axic added the bug 🐛 label Aug 6, 2018
@axic
Copy link
Member

axic commented Aug 6, 2018

The problem here is that calldata encoding for structs isn't defined yet in the encoder and external forces that. Using public will make it work because then it is handled internally as encoding from memory.

There must be an issue tracking this already.

@mattaereal
Copy link
Contributor Author

#1603 ?

@chriseth
Copy link
Contributor

chriseth commented Aug 7, 2018

@mattaereal yes, this is basically the unticked box in #1603

@christianparpart
Copy link
Member

christianparpart commented Aug 27, 2018

pragma experimental ABIEncoderV2;
pragma solidity ^0.4.24;
library Test {
    struct Nested { int i; }
    function Y(Nested storage a) external { a.i = 42; }
}

@axic compiles fine on latest develop.

edit: same here as in #4713; it got fixed implicitly via #4738.

@leonardoalt
Copy link
Member

Closing since the crash is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants