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 in LegacyTupleExpressionProcessor.extractComponentsFromTypeString #157

Open
cd1m0 opened this issue Oct 12, 2022 · 0 comments
Open
Assignees
Labels
bug Something isn't working cac Issue discovered from running over the contract archive

Comments

@cd1m0
Copy link
Contributor

cd1m0 commented Oct 12, 2022

When given legacy JSON ASTs, there is some fragile code in LegacyTupleExpressionProcessor.extractComponentsFromTypeString that tries to guess what the components of a tuple are based on the type string. When this fails, we get a crash like this one:

     Error: Expected component of type uint256 but got component of type tuple(uint256,uint256)
      at LegacyTupleExpressionProcessor.extractComponentsFromTypeString (src/ast/legacy/tuple_expression_processor.ts:78:27)
      at LegacyTupleExpressionProcessor.process (src/ast/legacy/tuple_expression_processor.ts:22:20)
      at ASTReader.convert (src/ast/ast_reader.ts:244:32)
      at ASTReader.convertArray (src/ast/ast_reader.ts:263:35)
      at LegacyReturnProcessor.process (src/ast/legacy/return_processor.ts:13:48)
      at ASTReader.convert (src/ast/ast_reader.ts:244:32)
      at ASTReader.convertArray (src/ast/ast_reader.ts:263:35)
      at LegacyBlockProcessor.process (src/ast/legacy/block_processor.ts:14:35)
      at ASTReader.convert (src/ast/ast_reader.ts:244:32)
      at ASTReader.convertArray (src/ast/ast_reader.ts:263:35)
      at LegacyFunctionDefinitionProcessor.process (src/ast/legacy/function_definition_processor.ts:21:33)
      at ASTReader.convert (src/ast/ast_reader.ts:244:32)
      at ASTReader.convertArray (src/ast/ast_reader.ts:263:35)
      at LegacyContractDefinitionProcessor.process (src/ast/legacy/contract_definition_processor.ts:15:33)
      at ASTReader.convert (src/ast/ast_reader.ts:244:32)
      at ASTReader.convertArray (src/ast/ast_reader.ts:263:35)
      at LegacySourceUnitProcessor.process (src/ast/legacy/source_unit_processor.ts:13:33)
      at ASTReader.convert (src/ast/ast_reader.ts:244:32)
      at ASTReader.read (src/ast/ast_reader.ts:220:37)
      at Context.<anonymous> (test/integration/types/infer.spec.ts:705:40)
      at processImmediate (node:internal/timers:471:21)

This happens relatively rarely (seen 7 times over 75K contracts), and only on old compiler versions (0.4.x) and only when directly given legacy JSON without source code.

We might consider fixing this if there are complaints about it, otherwise might leave as unfixed.

@cd1m0 cd1m0 self-assigned this Oct 12, 2022
@cd1m0 cd1m0 added bug Something isn't working cac Issue discovered from running over the contract archive labels Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cac Issue discovered from running over the contract archive
Projects
None yet
Development

No branches or pull requests

1 participant