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

Heap of out memory for recursive type #35776

Open
SirWojtek opened this issue Dec 19, 2019 · 0 comments
Open

Heap of out memory for recursive type #35776

SirWojtek opened this issue Dec 19, 2019 · 0 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@SirWojtek
Copy link

TypeScript Version:
3.8.0-dev.20191219

Search Terms:
heap out of memory, recursive, crash

Code

export type PathOf<
  T extends { [x: string]: any },
  Path extends [K1?, K2?, K3?, K4?, K5?, K6?, K7?, K8?, K9?, K10?, K11?, K12?, K13?],
  K1 extends keyof T,
  K2 extends keyof T[K1],
  K3 extends keyof T[K1][K2],
  K4 extends keyof T[K1][K2][K3],
  K5 extends keyof T[K1][K2][K3][K4],
  K6 extends keyof T[K1][K2][K3][K4][K5],
  K7 extends keyof T[K1][K2][K3][K4][K5][K6],
  K8 extends keyof T[K1][K2][K3][K4][K5][K6][K7],
  K9 extends keyof T[K1][K2][K3][K4][K5][K6][K7][K8],
  K10 extends keyof T[K1][K2][K3][K4][K5][K6][K7][K8][K9],
  K11 extends keyof T[K1][K2][K3][K4][K5][K6][K7][K8][K9][K10],
  K12 extends keyof T[K1][K2][K3][K4][K5][K6][K7][K8][K9][K10][K11],
  K13 extends keyof T[K1][K2][K3][K4][K5][K6][K7][K8][K9][K10][K11][K12],
  K14 extends keyof T[K1][K2][K3][K4][K5][K6][K7][K8][K9][K10][K11][K12][K13],
  K15 extends keyof T[K1][K2][K3][K4][K5][K6][K7][K8][K9][K10][K11][K12][K13][K14]
> = Path;

Expected behavior:
It should compile as it was in older version of tsc. It starts to happen from version > 3.4.
If I reduce the list of keys to 10 it compiles.

Actual behavior:
Heap out of size error:


<--- Last few GCs --->

[62544:0x55eeea5d1670]    54060 ms: Scavenge 1377.4 (1415.1) -> 1373.9 (1416.6) MB, 3.6 / 0.0 ms  (average mu = 0.250, current mu = 0.187) allocation failure 
[62544:0x55eeea5d1670]    54086 ms: Scavenge 1377.7 (1416.6) -> 1374.2 (1426.6) MB, 5.0 / 0.0 ms  (average mu = 0.250, current mu = 0.187) allocation failure 
[62544:0x55eeea5d1670]    54148 ms: Scavenge 1382.1 (1426.6) -> 1375.0 (1429.1) MB, 15.8 / 0.0 ms  (average mu = 0.250, current mu = 0.187) allocation failure 


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x319579adbe1d]
Security context: 0x06b12e21e6e9 <JSObject>
    1: getConstraintOfIndexedAccess(aka getConstraintOfIndexedAccess) [0x1791c358f071] [/home/mateusz/.config/yarn/global/node_modules/typescript/lib/tsc.js:~34610] [pc=0x319579ea17a8](this=0x353782f026f1 <undefined>,type=0x33d411a782c9 <Type map = 0x1f09a070b789>)
    2: getConstraintOfType(aka getConstraintOfType) [0x1791c358f031] [/home/mateusz/.config/ya...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x55eee7c6ba01 node::Abort() [node]
 2: 0x55eee7c6ba4f  [node]
 3: 0x55eee7e4f132 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
 4: 0x55eee7e4f387 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
 5: 0x55eee81f3e83  [node]
 6: 0x55eee81f3fd1  [node]
 7: 0x55eee8204768 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
 8: 0x55eee820510f v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 9: 0x55eee8207285 v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
10: 0x55eee82072d2 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
11: 0x55eee81d28b7 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node]
12: 0x55eee8464778 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node]
13: 0x319579adbe1d 

Playground Link:
https://github.com/SirWojtek/path-of-issue
Author's code: https://github.com/Morglod/ts-pathof

Related Issues:
#35289
#35156

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Dec 19, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Dec 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants