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

Maximum call stack size exceeded #22224

Closed
mysticatea opened this issue Feb 28, 2018 · 4 comments
Closed

Maximum call stack size exceeded #22224

mysticatea opened this issue Feb 28, 2018 · 4 comments
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@mysticatea
Copy link

TypeScript Version: 2.8.0-dev.20180228

Search Terms: Maximum call stack size exceeded

Code: https://github.com/mysticatea/regexpp/tree/wip/src (I'm not sure where is the cause.)

  1. git clone https://github.com/mysticatea/regexpp.git
  2. git checkout wip
  3. npm install
  4. npm run build

Expected behavior: Success or compile error

Actual behavior: tsc crashed.

C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:59957
                throw e;
                ^

RangeError: Maximum call stack size exceeded
    at identity (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:1281:22)
    at Object.binarySearch (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:1024:19)
    at computeLineAndCharacterOfPosition (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:4180:29)
    at Object.getLineAndCharacterOfPosition (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:4192:16)
    at emitPos (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:54003:36)
    at emitNodeWithSourceMap (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:54051:21)
    at pipelineEmitWithSourceMap (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:56513:17)
    at emitNodeWithComments (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:54192:17)
    at pipelineEmitWithComments (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:56505:17)
    at emitNodeWithNotification (C:\Users\starc\Documents\GitHub\regexpp\node_modules\typescript\lib\tsc.js:53768:21)
@weswigham
Copy link
Member

weswigham commented Mar 1, 2018

This right here is probably your problem. We run out of stack space during the emit for that expression, since it's hundreds (thousands?) of levels nested (it's a very imbalanced binary tree for each expression node), and we probably push ~7 frames onto the stack for each level of nesting right now. And node's max stack size is around 11k, if I remember right.

@mysticatea
Copy link
Author

Thank you for pointed out.
I will try another strategy to check Unicode properties ID_Start/ID_Continue.

@weswigham
Copy link
Member

Wrapping parenthesis around halves of the check to balance the expression tree may also work to reduce nesting.

@mhegazy mhegazy added the Design Limitation Constraints of the existing architecture prevent this from being fixed label Mar 1, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

4 participants