Skip to content

Potential memory leak or dead recursive during auto completion #59998

@neko-para

Description

@neko-para

🔎 Search Terms

memory leak auto completion

🕗 Version & Regression Information

seems occur since first version that could compile those code.

Please forgive me for providing such a huge source code, as its complexity has to be kept to cause noticeable memory consumption rate (about 30MB/s, at least).

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/C4TwDgpgBAShDGB7AKuaBeAUFHUA+UA5ACICWATgsABKnCHa4GHIQC2YANgIbAQCyveAAsGufEQBiEXgFdKg4CLFMiAYUSdE5RcsY5mAeTUwVBogDkI87pyvAA7toDWangGd3pAGYgzEwisbOwhHF2JQqn9mNVl3YEQ2BkxQSCgAQXhgVDSscWZiRAtEYGFSADsAc2j1TlJ4ZxrCAGUHUkgmgGkIP30A1gAPej7mZuBucmB0sDAmscQwadmRonmwZG53RpXCWPjE5NToQ3IAEwhyACEQQTAodCgAbz7WDh4+XWEALiJqbVIAF6IcrjTiEAIANQuwHqtnBoyQlHhRBg3HKpwOfWkcgUQm+v3+QJBcMh0NhYICzUREGRhHSlG4tNR6Mx4g0Wh0eJ+hD+5EBwNBtKhk3JtKp2hpAXpMiZaIxST6xhg3N5-OJFOYwph8BJzGljICABkIFVSrKWQrxEFyLZ7E5yK4PF5fCrCQLdUQtaLKdTzfL-NbbaF7c4Inwsq6+UTBaSRTqNatfVKGX7MQBfTApNBQAAK7QgdXKEEuslInHO5DGvAgAB4AFLuYH3J5pgB8zee4gxRZ+DeBmDTUAAZFAABSEShISrlOikYHgiBDE2ndxQZw9RDeKB98p9AD8Lb6P074lPk8Q09nwJrMCgi746NXcCQOQgrdHfVPZ4QiB+ME-p4AJQ-HmkCFhAz4XjOMLAiWZYVlWfA1gBX44Duw5PChqHiOel4weUf5YV+aYADREae-7YTgrYAWmgHDn047cFkc7lAuS6PmuG5bjuWEHo8GbYce5HiMx+E1ukd4cSuGRZK+74iahYk-Okik4MBub5uBmT4XB5YXIhtZqae6EjieVEWVAYmsSpxniKRdm4Kplm4DRFl0Qx4jjkWQzsQ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BvYT4wL7GnSu9Phu1ORs2u14ZtIx0B+pxuZjNHxBQAZzNijgCRWSrhxXEGAQ5TBPjiZVnVdt7I5SYBAA

💻 Code

type RecoType =
    | 'DirectHit'
    | 'TemplateMatch'
    | 'FeatureMatch'
    | 'ColorMatch'
    | 'OCR'
    | 'NeuralNetworkClassify'
    | 'NeuralNetworkDetect'
    | 'Custom'

type ActType =
    | 'DoNothing'
    | 'Click'
    | 'Swipe'
    | 'Key'
    | 'Text'
    | 'StartApp'
    | 'StopApp'
    | 'StopTask'
    | 'Custom'

type OrderByMap = {
    TemplateMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Random'
    FeatureMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random'
    ColorMatch: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random'
    OCR: 'Horizontal' | 'Vertical' | 'Area' | 'Length' | 'Random'
    NeuralNetworkClassify: 'Horizontal' | 'Vertical' | 'Score' | 'Random'
    NeuralNetworkDetect: 'Horizontal' | 'Vertical' | 'Score' | 'Area' | 'Random'
}

type PipelineBuilderState<Json = {}> = {
    done: Json
} & ('recognition' extends keyof Json
    ? {}
    : {
          recognition<R extends RecoType>(
              reco: R
          ): PipelineRecognitionBuilderState<
              Json & {
                  recognition: R
              },
              R
          >
      }) &
    ('action' extends keyof Json
        ? {}
        : {
              action<A extends ActType>(
                  act: A
              ): PipelineActionBuilderState<
                  Json & {
                      action: A
                  },
                  A
              >
          }) &
    ('next' extends keyof Json
        ? {}
        : {
              next<N extends string[]>(...nxt: [...N]): PipelineBuilderState<Json & { next: N }>
          }) &
    ('interrupt' extends keyof Json
        ? {}
        : {
              interrupt<I extends string[]>(
                  ...int: [...I]
              ): PipelineBuilderState<Json & { interrupt: I }>
          }) &
    ('rate_limit' extends keyof Json
        ? {}
        : {
              rate_limit<R extends number>(rate: R): PipelineBuilderState<Json & { rate_limit: R }>
          }) &
    ('timeout' extends keyof Json
        ? {}
        : {
              timeout<R extends number>(time: R): PipelineBuilderState<Json & { timeout: R }>
          }) &
    ('on_error' extends keyof Json
        ? {}
        : {
              on_error<O extends string[]>(
                  ...err: [...O]
              ): PipelineBuilderState<Json & { on_error: O }>
          }) &
    ('inverse' extends keyof Json
        ? {}
        : {
              inverse<I extends boolean>(inv: I): PipelineBuilderState<Json & { inverse: I }>
          }) &
    ('enabled' extends keyof Json
        ? {}
        : {
              enabled<E extends boolean>(en: E): PipelineBuilderState<Json & { enabled: E }>
          }) &
    ('pre_delay' extends keyof Json
        ? {}
        : {
              pre_delay<P extends number>(pre: P): PipelineBuilderState<Json & { pre_delay: P }>
          }) &
    ('post_delay' extends keyof Json // <--- here two post_delay are provided, which is the root cause
        ? {}
        : {
              post_delay<P extends number>(post: P): PipelineBuilderState<Json & { post_delay: P }>
          }) &
    ('post_delay' extends keyof Json // <---
        ? {}
        : {
              post_delay<P extends number>(post: P): PipelineBuilderState<Json & { post_delay: P }>
          }) &
    ('pre_wait_freezes' extends keyof Json
        ? {}
        : {
              pre_wait_freezes: PipelineWaitFreezeBuilderState<Json, 'pre_wait_freezes'>
          }) &
    ('focus' extends keyof Json
        ? {}
        : {
              focus<F extends boolean>(focus: F): PipelineBuilderState<Json & { focus: F }>
          })

type PipelineRecognitionBuilderState<PBJson, Reco extends RecoType, Json = {}> = {
    done: PipelineBuilderState<PBJson & Json>
} & (Reco extends 'DirectHit'
    ? {}
    : ('roi' extends keyof Json
          ? {}
          : {
                roi<R extends [string] | [number, number, number, number]>(
                    ...roi: R
                ): PipelineRecognitionBuilderState<
                    PBJson,
                    Reco,
                    Json & { roi: R extends [number, number, number, number] ? R : R[0] }
                >
            }) &
          ('roi_offset' extends keyof Json
              ? {}
              : {
                    roi_offset<R extends [number, number, number, number]>(
                        ...roi: R
                    ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { roi_offset: R }>
                })) &
    (Reco extends 'TemplateMatch' | 'FeatureMatch'
        ? 'template' extends keyof Json
            ? {}
            : {
                  template<T extends string[]>(
                      ...templ: [...T]
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { template: T }>
              }
        : {}) &
    (Reco extends 'TemplateMatch' | 'NeuralNetworkDetect'
        ? 'threshold' extends keyof Json
            ? {}
            : {
                  threshold<T extends number[]>(
                      ...thres: [...T]
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { threshold: T }>

                  threshold$<T extends number>(
                      thres: T
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { threshold: T }>
              }
        : {}) &
    (Reco extends keyof OrderByMap
        ? 'order_by' extends keyof Json
            ? {}
            : {
                  order_by<O extends OrderByMap[Reco]>(
                      order: O
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { order_by: O }>
              }
        : {}) &
    (Reco extends keyof OrderByMap
        ? 'index' extends keyof Json
            ? {}
            : {
                  index<T extends number>(
                      idx: T
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { index: T }>
              }
        : {}) &
    (Reco extends 'TemplateMatch'
        ? 'method' extends keyof Json
            ? {}
            : {
                  method<M extends 1 | 3 | 5>(
                      method: M
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { method: M }>
              }
        : {}) &
    (Reco extends 'ColorMatch'
        ? 'method' extends keyof Json
            ? {}
            : {
                  method<M extends 4 | 40 | 6>(
                      method: M
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { method: M }>
              }
        : {}) &
    (Reco extends 'TemplateMatch' | 'FeatureMatch'
        ? 'green_mask' extends keyof Json
            ? {}
            : {
                  green_mask<G extends boolean>(
                      mask: G
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { green_mask: G }>
              }
        : {}) &
    (Reco extends 'FeatureMatch' | 'ColorMatch'
        ? 'count' extends keyof Json
            ? {}
            : {
                  count<C extends number>(
                      count: C
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { count: C }>
              }
        : {}) &
    (Reco extends 'FeatureMatch'
        ? 'detector' extends keyof Json
            ? {}
            : {
                  detector<D extends 'SIFT' | 'KAZE' | 'AKAZE' | 'BRISK' | 'ORB'>(
                      det: D
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { detector: D }>
              }
        : {}) &
    (Reco extends 'FeatureMatch'
        ? 'ratio' extends keyof Json
            ? {}
            : {
                  ratio<R extends number>(
                      ratio: R
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { ratio: R }>
              }
        : {}) &
    (Reco extends 'ColorMatch'
        ? 'method' extends keyof Json
            ? ('lower' extends keyof Json
                  ? {}
                  : Json['method'] extends 4 | 40
                    ? {
                          lower<L extends [number, number, number][]>(
                              ...lower: [...L]
                          ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { lower: L }>
                      }
                    : {
                          lower<L extends [number][]>(
                              ...lower: [...L]
                          ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { lower: L }>
                      }) &
                  ('upper' extends keyof Json
                      ? {}
                      : Json['method'] extends 4 | 40
                        ? {
                              upper<L extends [number, number, number][]>(
                                  ...upper: [...L]
                              ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { upper: L }>
                          }
                        : {
                              upper<U extends [number][]>(
                                  ...upper: [...U]
                              ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { upper: U }>
                          })
            : {}
        : {}) &
    (Reco extends 'ColorMatch'
        ? 'connected' extends keyof Json
            ? {}
            : {
                  connected<C extends boolean>(
                      conn: C
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { connected: C }>
              }
        : {}) &
    (Reco extends 'OCR'
        ? 'expected' extends keyof Json
            ? {}
            : {
                  expected<E extends string[]>(
                      ...exp: [...E]
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { expected: E }>
              }
        : {}) &
    (Reco extends 'NeuralNetworkClassify' | 'NeuralNetworkDetect'
        ? 'expected' extends keyof Json
            ? {}
            : {
                  expected<E extends number[]>(
                      ...exp: [...E]
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { expected: E }>
              }
        : {}) &
    (Reco extends 'OCR'
        ? 'replace' extends keyof Json
            ? {}
            : {
                  replace<R extends [string, string][]>(
                      ...exp: [...R]
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { replace: R }>
              }
        : {}) &
    (Reco extends 'OCR'
        ? 'only_rec' extends keyof Json
            ? {}
            : {
                  only_rec<O extends boolean>(
                      rec: O
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { only_rec: O }>
              }
        : {}) &
    (Reco extends 'OCR' | 'NeuralNetworkClassify' | 'NeuralNetworkDetect'
        ? 'model' extends keyof Json
            ? {}
            : {
                  model<M extends string>(
                      model: M
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { model: M }>
              }
        : {}) &
    (Reco extends 'NeuralNetworkClassify' | 'NeuralNetworkDetect'
        ? 'labels' extends keyof Json
            ? {}
            : {
                  labels<L extends string[]>(
                      ...label: [...L]
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { labels: L }>
              }
        : {}) &
    (Reco extends 'Custom'
        ? 'custom_recognition' extends keyof Json
            ? {}
            : {
                  custom_recognition<C extends string>(
                      reco: C
                  ): PipelineRecognitionBuilderState<PBJson, Reco, Json & { custom_recognition: C }>
              }
        : {}) &
    (Reco extends 'Custom'
        ? 'custom_recognition_param' extends keyof Json
            ? {}
            : {
                  custom_recognition_param<C extends Record<string, unknown>>(
                      param: C
                  ): PipelineRecognitionBuilderState<
                      PBJson,
                      Reco,
                      Json & { custom_recognition_param: C }
                  >
              }
        : {})

type PipelineActionBuilderState<PBJson, Act extends ActType, Json = {}> = {
    done: PipelineBuilderState<PBJson & Json>
} & (Act extends 'Click' | 'Custom'
    ? 'target' extends keyof Json
        ? {}
        : {
              target<T extends [true] | [string] | [number, number, number, number]>(
                  ...target: T
              ): PipelineActionBuilderState<
                  PBJson,
                  Act,
                  Json & { target: T extends [number, number, number, number] ? T : T[0] }
              >
          }
    : {}) &
    (Act extends 'Click' | 'Custom'
        ? 'target_offset' extends keyof Json
            ? {}
            : {
                  target_offset<O extends [number, number, number, number]>(
                      ...offset: O
                  ): PipelineActionBuilderState<PBJson, Act, Json & { target_offset: O }>
              }
        : {}) &
    (Act extends 'Swipe'
        ? 'begin' extends keyof Json
            ? {}
            : {
                  begin<B extends [true] | [string] | [number, number, number, number]>(
                      ...begin: B
                  ): PipelineActionBuilderState<
                      PBJson,
                      Act,
                      Json & { begin: B extends [number, number, number, number] ? B : B[0] }
                  >
              }
        : {}) &
    (Act extends 'Swipe'
        ? 'begin_offset' extends keyof Json
            ? {}
            : {
                  begin_offset<B extends [number, number, number, number]>(
                      ...offset: B
                  ): PipelineActionBuilderState<PBJson, Act, Json & { begin_offset: B }>
              }
        : {}) &
    (Act extends 'Swipe'
        ? 'end' extends keyof Json
            ? {}
            : {
                  end<E extends [true] | [string] | [number, number, number, number]>(
                      ...end: E
                  ): PipelineActionBuilderState<
                      PBJson,
                      Act,
                      Json & { end: E extends [number, number, number, number] ? E : E[0] }
                  >
              }
        : {}) &
    (Act extends 'Swipe'
        ? 'end_offset' extends keyof Json
            ? {}
            : {
                  end_offset<E extends [number, number, number, number]>(
                      ...offset: E
                  ): PipelineActionBuilderState<PBJson, Act, Json & { end_offset: E }>
              }
        : {}) &
    (Act extends 'Key'
        ? 'key' extends keyof Json
            ? {}
            : {
                  key<K extends number[]>(
                      ...key: [...K]
                  ): PipelineActionBuilderState<PBJson, Act, Json & { key: K }>
              }
        : {}) &
    (Act extends 'InputText'
        ? 'input_text' extends keyof Json
            ? {}
            : {
                  input_text<T extends string>(
                      text: T
                  ): PipelineActionBuilderState<PBJson, Act, Json & { input_text: T }>
              }
        : {}) &
    (Act extends 'StartApp' | 'StopApp'
        ? 'package' extends keyof Json
            ? {}
            : {
                  package<P extends string>(
                      pkg: P
                  ): PipelineActionBuilderState<PBJson, Act, Json & { package: P }>
              }
        : {}) &
    (Act extends 'Custom'
        ? 'custom_action' extends keyof Json
            ? {}
            : {
                  custom_action<C extends string>(
                      act: C
                  ): PipelineActionBuilderState<PBJson, Act, Json & { custom_action: C }>
              }
        : {}) &
    (Act extends 'Custom'
        ? 'custom_action_param' extends keyof Json
            ? {}
            : {
                  custom_action_param<C extends Record<string, unknown>>(
                      param: C
                  ): PipelineActionBuilderState<PBJson, Act, Json & { custom_action_param: C }>
              }
        : {})

type PipelineWaitFreezeBuilderState<
    PBJson,
    Key extends 'pre_wait_freezes' | 'post_wait_freezes',
    Json = {}
> = {
    done: PipelineBuilderState<
        PBJson & {
            [key in Key]: Json
        }
    >
} & ('time' extends keyof Json
    ? {}
    : {
          time<T extends number>(
              time: T
          ): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { time: T }>
      }) &
    ('target' extends keyof Json
        ? {}
        : {
              target<T extends [true] | [string] | [number, number, number, number]>(
                  ...target: T
              ): PipelineWaitFreezeBuilderState<
                  PBJson,
                  Key,
                  Json & { target: T extends [number, number, number, number] ? T : T[0] }
              >
          }) &
    ('target_offset' extends keyof Json
        ? {}
        : {
              target_offset<O extends [number, number, number, number]>(
                  ...offset: O
              ): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { target_offset: O }>
          }) &
    ('threshold' extends keyof Json
        ? {}
        : {
              threshold<T extends number>(
                  thres: T
              ): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { threshold: T }>
          }) &
    ('method' extends keyof Json
        ? {}
        : {
              method<M extends 1 | 3 | 5>(
                  met: M
              ): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { method: M }>
          }) &
    ('rate_limit' extends keyof Json
        ? {}
        : {
              rate_limit<R extends number>(
                  rate: R
              ): PipelineWaitFreezeBuilderState<PBJson, Key, Json & { rate_limit: R }>
          })

const v = ({} as PipelineBuilderState).action('Click').done.

🙁 Actual behavior

When requesting auto completion in the last row (via dot), the heap raise quickly.

I've checked out that it is caused by the miss duplication of post_delay property state changing edge.

QQ_1726660185885
0d21ebf95cd073005933175c61f60b50

🙂 Expected behavior

The completion should either fail or succeed quickly. The duplicate edge shouldn't affect completing.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs InvestigationThis issue needs a team member to investigate its status.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions