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

Regression Test for RangeError Crash #59594

Closed
LukeAbby opened this issue Aug 11, 2024 · 0 comments · Fixed by #59611
Closed

Regression Test for RangeError Crash #59594

LukeAbby opened this issue Aug 11, 2024 · 0 comments · Fixed by #59611
Labels
Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone

Comments

@LukeAbby
Copy link

🔎 Search Terms

RangeError regression test

🕗 Version & Regression Information

Somewhat unconventionally this particular issue was actually already fixed in 71fb864 but it's broken before c8a7d58. It shows up in TypeScript 5.5.4 but not TypeScript 5.4

I'm only still reporting this issue because it doesn't look like the commit that happened to fix it contained any regression tests for this crash or anything. As far as I can tell the fact that this crash was fixed by complete chance and I want to make sure that this doesn't happen again.

⏯ Playground Link

No response

💻 Code

This doesn't seem to crash in the Playground, presumably because it resolves differently than tsc and avoids the RangeError, but maybe I messed something up.

TSConfig:

{
  "compilerOptions": {
    "allowJs": true,
    "checkJs": false,
    "outDir": "./out"
  }
}

Minimal reproduction JavaScript file (run with checkJS):

var a$b = {};
var c, d;
d = a$b;
while (d !== a$b);
while ((c = a$b != a$b)) c.e;

I managed to take a much larger file and reduce it using CReduce, hence why it's so contrived. However this happened in the real world, I became aware of this while helping out with peggyjs/peggy#538. The full file causing the error is this: https://github.com/peggyjs/peggy/blob/4036dabd40bdb318876ba0f3ac6fd5b0ae317176/lib/parser.js

Alternatively use the zipped reproduction project - to reproduce run npm install and then ./node_modules/typescript/bin/tsc.

When I run with TypeScript == 5.5.4 this crashes, though on TypeScript@main it doesn't so as already mentioned it's already been fixed. This is the traceback:

node_modules/typescript/lib/tsc.js:120196
      throw e;
      ^

RangeError: Maximum call stack size exceeded
    at createObjectType (node_modules/typescript/lib/tsc.js:48681:28)
    at createAnonymousType (node_modules/typescript/lib/tsc.js:48728:37)
    at getJSContainerObjectType (node_modules/typescript/lib/tsc.js:54416:18)
    at getTypeForVariableLikeDeclaration (node_modules/typescript/lib/tsc.js:54202:37)
    at getWidenedTypeForVariableLikeDeclaration (node_modules/typescript/lib/tsc.js:54654:48)
    at getTypeOfVariableOrParameterOrPropertyWorker (node_modules/typescript/lib/tsc.js:54802:14)
    at getTypeOfVariableOrParameterOrProperty (node_modules/typescript/lib/tsc.js:54735:20)
    at getTypeOfSymbol (node_modules/typescript/lib/tsc.js:55064:14)
    at getNarrowedTypeOfSymbol (node_modules/typescript/lib/tsc.js:69809:18)
    at checkIdentifier (node_modules/typescript/lib/tsc.js:69948:16)

Terminal session running the reproduction:
RangeError Crash

🙁 Actual behavior

This (used to) crash and doesn't seem to have a regression test.

🙂 Expected behavior

No crash

Additional information about the issue

No response

@RyanCavanaugh RyanCavanaugh added Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases labels Aug 12, 2024
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants