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

Javascript call stack exceeded #80

Open
axic opened this issue Sep 21, 2021 · 8 comments
Open

Javascript call stack exceeded #80

axic opened this issue Sep 21, 2021 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@axic
Copy link

axic commented Sep 21, 2021

On the same codebase whatever I do (like adding an invariant or a if_succeeds statement) I keep getting Javascript Maximum call stack size exceeded errors.

Two kinds in particular:

  1. The first seems to be inside type checking:
Internal error in type-checking: Maximum call stack size exceeded
  1. The seconds seems to be around recursive imports:
/Users/alex/Projects/scribble/dist/bin/scribble.js:494
            throw e;
            ^

RangeError: Maximum call stack size exceeded
    at ImportDirective.get vSymbolAliases [as vSymbolAliases] (/Users/alex/Projects/scribble/node_modules/solc-typed-ast/dist/ast/implementation/meta/import_directive.js:55:45)
    at lookupInSourceUnit (/Users/alex/Projects/scribble/node_modules/solc-typed-ast/dist/ast/definitions.js:101:28)
    at lookupInSourceUnit.next (<anonymous>)
    at new Set (<anonymous>)
    at lookupInScope (/Users/alex/Projects/scribble/node_modules/solc-typed-ast/dist/ast/definitions.js:229:12)
    at lookupInSourceUnit (/Users/alex/Projects/scribble/node_modules/solc-typed-ast/dist/ast/definitions.js:104:35)
    at lookupInSourceUnit.next (<anonymous>)
    at new Set (<anonymous>)
    at lookupInScope (/Users/alex/Projects/scribble/node_modules/solc-typed-ast/dist/ast/definitions.js:229:12)
    at lookupInSourceUnit (/Users/alex/Projects/scribble/node_modules/solc-typed-ast/dist/ast/definitions.js:104:35)

(It is a local install of 912a472)

I think the second case may be connected to #64.

I tried for a quite bit of time create a reduced example, but can't really spend too many hours on it. @cd1m0 do you have any idea based on the above?

@blitz-1306
Copy link
Contributor

@axic Thanks for the feedback. It appears that issue originates from solc-typed-ast. However, I'm not sure if Scribble manipulated AST somehow to make that happend. We will keep track the issue in case if we will be able to rootcause.

@cd1m0 There were few commits to the mentioned file in error trace. The current last one is Consensys/solc-typed-ast@f5f0d72.

@cd1m0
Copy link
Collaborator

cd1m0 commented Sep 21, 2021

@axic thanks for pointing this out! Do you have a sample/link to a codebase so we can reproduce it too? And yeah, this looks like its related to the fix to #64.

@cd1m0 cd1m0 self-assigned this Sep 21, 2021
@axic
Copy link
Author

axic commented Sep 21, 2021

Do you have a sample/link to a codebase so we can reproduce it too?

I have tried creating an example a few times, probably spent over an hour on it, but couldn't yet reduce it. I cannot share the source yet :(

@cd1m0
Copy link
Collaborator

cd1m0 commented Sep 21, 2021

Ok. Will try to look at the code and find anything suspicious

@cd1m0
Copy link
Collaborator

cd1m0 commented Oct 1, 2021

I was able to reproduce the issue by trying to look-up an identifier that doesn't exist. Here are the samples:
A.sol:

import "./B.sol";

/// #invariant dummy > 0;
contract A {
  function a(B arg) external returns (B) {return arg;}
}

B.sol:

import "./A.sol";

contract B {
  function a(A arg) external returns (A) { return arg; }
}

Doing scribble A.sol crashes with the same stack trace. The issue however is in solc-typed-ast. Essentially if we don't find a definition for the dummy at the root level of A.sol, we try looking it up at the root level of B.sol, and then we ping-pong back and forth.

@axic
Copy link
Author

axic commented Nov 5, 2021

Tried 0.5.7, but it still happens.

The repository however now is public: https://github.com/tempus-finance/tempus-protocol

@cd1m0 as an extremely simple example, add /// #invariant version == 1; at https://github.com/tempus-finance/tempus-protocol/blob/master/contracts/TempusPool.sol#L22

@cd1m0
Copy link
Collaborator

cd1m0 commented Nov 5, 2021

@axic thanks for following up! Will reproduce this and try to give you rootcause/fix :)

@axic
Copy link
Author

axic commented Nov 6, 2021

@cd1m0 much appreciated, can't wait to create some scribble specifications 😅

@cd1m0 cd1m0 added the bug Something isn't working label Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants