eos icon indicating copy to clipboard operation
eos copied to clipboard

Handle circular type dependencies in AbiSerializer

Open elmato opened this issue 9 years ago • 4 comments

You can crash eosd submitting a json abi with

...
"types": [{}]
...

elmato avatar Aug 31 '17 15:08 elmato

I debugged this issue and found the following stack trace when it crashes:

eos::types::AbiSerializer::isArray(fc::fixed_string<fc::array<unsigned long, 4ul> > const&) const () eos::types::AbiSerializer::arrayType(fc::fixed_string<fc::array<unsigned long, 4ul> > const&) const () eos::types::AbiSerializer::isType(fc::fixed_string<fc::array<unsigned long, 4ul> > const&) const ()

Apparently AbiSerializer::isArray(...) needs to check for null Types I believe.

pavybez avatar Sep 07 '17 09:09 pavybez

Fixed and raised a pull request. It now displays following error instead of crashing node:

ubuntu@ip-172-31-23-80:~/eos/build/programs/eosc$ ./eosc --wallet-port 7777 set contract currency ../../contracts/currency/currency.wast ../../contracts/currency/currency.abi Reading WAST... Assembling WASM... Publishing contract... 2016284ms thread-0 main.cpp:768 main ] Failed with error: 10 assert_exception: Assert Exception status_code == 200: Error : 10 assert_exception: Assert Exception isType(td.type): invalid type {"type":""} thread-0 AbiSerializer.cpp:104 setAbi

pavybez avatar Sep 08 '17 03:09 pavybez

The described issue seems fixed. However, the subject suggests a feature improvement for ABI serializer about circular dependencies. @elmato if that is the case, please open a new issue with a full description of the enhancement you want to add to AbiSerializer

closed by #380

wanderingbort avatar Sep 12 '17 22:09 wanderingbort

@wanderingbort @pavybez The above PR finish this issue preventing circular references in types and structs and also enforcing structs to inherit only from struct

elmato avatar Sep 13 '17 09:09 elmato