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

Crash after formatting selection #4539

Closed
sean-mcmanus opened this issue Nov 5, 2019 · 9 comments
Closed

Crash after formatting selection #4539

sean-mcmanus opened this issue Nov 5, 2019 · 9 comments
Assignees
Labels
bug Feature: Code Formatting fixed Check the Milestone for the release in which the fix is or will be available. Language Service reliability
Milestone

Comments

@sean-mcmanus
Copy link
Contributor

Any solutions to this yet?
I have a similar issue: VSCode on Ubuntu 19.1, with C/C++ 0.26.1 extension installed. When I try to format a selected part of my code, I receive the error:

[Error - 6:16:27 p.m.] Connection to server got closed. Server will not be restarted.
[Error - 6:16:27 p.m.] Request textDocument/rangeFormatting failed.

Originally posted by @kei2e in #1975 (comment)

@sean-mcmanus
Copy link
Contributor Author

@kei2e Our language server process is crashing. Can you attach a debugger to the Microsoft.VSCode.CPP.Extension.linux and provide a callstack or give more repro details? Are you using a multi-root workspace?

@kei2e
Copy link

kei2e commented Nov 6, 2019

@sean-mcmanus sorry, I am very new to this. Can you plz give me some instructions on how to attach a debugger to Microsoft.VSCode.CPP.Extension.linux?

No, I am not using a multi-root workspace.

@sean-mcmanus
Copy link
Contributor Author

sean-mcmanus commented Nov 6, 2019

There are some docs at https://code.visualstudio.com/docs/cpp/cpp-debug.

You basically just need to create a launch.json file with a "(gdb) attach" config and set the program to the full path of the Microsoft.VSCode.CPP.Extension.linux binary (e.g. /home/user/.vscode/extensions/ms-vscode.cpptools-0.26.1/bin/Microsoft.VSCode.CPP.Extension.linux). Then click the Start Debugging button and repro the crash. Let me know if you want more info.

@sean-mcmanus
Copy link
Contributor Author

sean-mcmanus commented Nov 6, 2019

Also, we have no known crashes involving formatting, so anything special about your environment or format settings you could think of could help (might be related to Ubuntu 19).

@sean-mcmanus
Copy link
Contributor Author

Also, if you could set the C_Cpp.clang_format_path to another clang-format such as from http://releases.llvm.org/download.html , it's possible that could fix/workaround the issue.

@sean-mcmanus
Copy link
Contributor Author

Looks like other users have hit this at #3559 .

@sean-mcmanus sean-mcmanus added this to the 0.26.2 milestone Nov 6, 2019
@sean-mcmanus sean-mcmanus added the investigate: repro This issue's repro steps needs to be investigated/confirmed label Nov 6, 2019
@kei2e
Copy link

kei2e commented Nov 6, 2019

@sean-mcmanus thanks for the instructions and help!
I am working on it to provide you with more info .. in the meantime, I tried the formatter on a separate test.cpp file and got the following:

Formatting failed:
/home/keyvan/.vscode/extensions/ms-vscode.cpptools-0.26.1/bin/../LLVM/bin/clang-format -style={ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 2, TabWidth: 2, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -2 } -fallback-style=LLVM -sort-includes=0 -offset=364 -length=77 -assume-filename=/home/keyvan/test.cpp
/home/keyvan/.vscode/extensions/ms-vscode.cpptools-0.26.1/bin/../LLVM/bin/clang-format: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
  

@kei2e
Copy link

kei2e commented Nov 6, 2019

Okay .. it was fixed by installing clang-format,
sudo apt install clang-format
and adding
{ "C_Cpp.clang_format_path": "/usr/bin/clang-format" }
to settings.json, as suggested by penguingovernor at #3174. Now the formatter appears to be working fine in both workspaces.

I still do not know what exactly is going on. But let me know if I can be of any help figuring that out.

@sean-mcmanus sean-mcmanus modified the milestones: 0.26.3, 1.0.0 Jan 22, 2020
@sean-mcmanus sean-mcmanus removed investigate: repro This issue's repro steps needs to be investigated/confirmed more info needed The issue report is not actionable in its current state labels Jan 22, 2020
@Colengms Colengms added the fixed Check the Milestone for the release in which the fix is or will be available. label Feb 4, 2020
@sean-mcmanus
Copy link
Contributor Author

Our Insiders release should fix this clang-format issue: https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders

@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Code Formatting fixed Check the Milestone for the release in which the fix is or will be available. Language Service reliability
Projects
None yet
Development

No branches or pull requests

3 participants