tools icon indicating copy to clipboard operation
tools copied to clipboard

🐛 Rome VSCode extension crashes for closure function passing itself as an argument

Open LunaTK opened this issue 3 years ago • 3 comments

Environment information

yarn run v1.22.11
$ /Users/lunatk/Devsisters/rome-crash/node_modules/.bin/rome rage
CLI:
  Version:              10.0.1
  Color support:        true

Platform:
  CPU Architecture:     aarch64
  OS:                   macos

Environment:
  ROME_LOG_DIR:         unset
  NO_COLOR:             unset
  TERM:                 "xterm-256color"

Rome Configuration:
  Status:               loaded
  Formatter disabled:   false
  Linter disabled:      false

Workspace:
  Open Documents:       0

Discovering running Rome servers...

Running Rome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

i The client isn't connected to any server but rage discovered this running Rome server.

Server:
  Version:              10.0.1
  Name:                 rome_lsp
  CPU Architecture:     aarch64
  OS:                   macos

Workspace:
  Open Documents:       0

Rome Server Log:

! Please review the content of the log file before sharing it publicly as it may contain sensitive information:
  * Path names that may reveal your name, a project name, or the name of your employer.
  * Source code

... trimmed

  • Device : MacBook Air (M1, 2020)

    • OS : macOS Monterey 12.4
    • Memory : 8GB
  • Visual Studio Code

    Version: 1.72.2 (Universal)
    Commit: d045a5eda657f4d7b676dedbfa7aab8207f8a075
    Date: 2022-10-12T22:16:30.254Z (1 mo ago)
    Electron: 19.0.17
    Chromium: 102.0.5005.167
    Node.js: 16.14.2
    V8: 10.2.154.15-electron.0
    OS: Darwin arm64 21.5.0
    Sandboxed: No
    
  • Rome VSCode Extension

    • Identifier: "rome.rome"
    • Version: v0.18.1 (Preview)

What happened?

Reproduction repo : https://github.com/LunaTK/rome-crash-reproduction

The following TypeScript code makes Rome VSCode extension crash.

type Func = (callback: Func) => void;

const romeKiller = () => {
  const fn = (callback: Func) => {
    callback(fn);
  };
};

image

If fn stays in the top level, it doesn't kill Rome.

const fn = (callback: Func) => {
  callback(fn); // no problem
};

Expected result

Rome VSCode extension should not die.

Code of Conduct

  • [X] I agree to follow Rome's Code of Conduct

LunaTK avatar Nov 13 '22 04:11 LunaTK

Interesting. @xunilrj could this be related to the semantic model or cfg?

MichaReiser avatar Nov 13 '22 10:11 MichaReiser

It looks like this is related to the inlineVariable refactor: when the cursor is placed over the fn token we try to emit a code action to inline the variable, however the resulting mutation is obviously invalid since it requires inserting a node into itself so committing the mutation panics and crashes the server

leops avatar Nov 14 '22 08:11 leops

I will assign this to myself.

xunilrj avatar Nov 14 '22 11:11 xunilrj