-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
clang-format based formatting breaks after a while since last VSCode update #3145
Comments
Note there is a previous similar report here but since it is a few years old and was closed with no apparent resolution: #1090 |
Also worth mentioning it breaks for all tabs once this happens. |
After playing some more, I don't think those particular log messages I saw were relevant. |
It sounds like the main input thread of the extension is stuck? The formatting work is done on the main input thread, so if some other main thread work could block the formatting. When formatting doesn't work, do any other features like hover or go to definition work? Is this a multi-root folder? It sounds like you're saying this is a regression? If you downgrade our extension to 0.20.1 does the bug still repro? |
@sean-mcmanus I was also experiencing this bug with clang-format not working with C/C++ Extension Version: 0.21.0.
|
Downgrading the C++ extension to the previous version (0.21.0) did not help. Downgrading VSCode to 1.30.2 does fix the issue. I haven't tried going to 0.20.1 of the extension. |
@MikeWeller Agreed. Although downgrading the C/C++ Extension initially seemed to help, I later had clang-format become unresponsive again. |
Yikes, it sounds like you guys are describing a regression with VS Code 1.31.0 and not our extension? I don't seem to be able to repro the issue. Our 0.22.0 release should fix the formatting getting blocked by IntelliSense operations (in most cases). |
Also seeing the same issue. I looked in the Problems tab but not seeing anything related to this. I also set loglevel to debug but I'm not sure where to look. Actually, one thing that sticks out in the Problems tab: It compiles fine (in VS, and Clang on Linux) so it isn't an actual error. But it is a rather convoluted macro, so maybe the VS Code parser can't handle it...? @sean-mcmanus May I ask when 0.22 is due? |
@Srekel 0.22.0 is planned for Thursday this week (unless issues delay it to next week), but I'm not sure yet if the fix for formatting getting blocked by IntelliSense processing will get checked in or not. The "expected a ')'" looks like a different intellisense bug and should be unrelated to clang-format issues. Can you provide more repro info, such as the definition of WC_VFUNC? |
Ok! Looking forward to it. :) The call site with the error:
Here's the full error popup:
This is the actual code:
|
@sean-mcmanus I also have the same issue with
|
@davydden If you're using multiple workspaces roots, we have a known issue where the didOpen won't be sent to all the folders, which can cause formatting to break. |
you mean when a workspace has multiple folders with C++ code? If so, yes, that's exactly my case. Could you perhaps point to the issue to track? |
Any updates on this? I'm stuck on an old vscode and plugin because this is quite important to my workflow. |
I also have the same issue and restart won't work.
|
@MikeWeller I don't think we understand yet what is going wrong in your scenario (i.e. we don't have a repro and have not yet witnessed the failure, even randomly). It sounds like the main process is hitting a deadlock? Do all other features fail when this occurs? Could you attach a debugger to the Microsoft.VSCode.CPP.Extension.exe process with "symbolSearchPath" to "https://msdl.microsoft.com/download/symbols" to get a call stack? Does it repro with our latest 0.23.0-insiders2 (which should be identical to the pending 0.23.0 we plan to release soon)? @Jacky-Lau Your issue sounds different (might be related to the multi-root issues #2107, #1073). The failure log is unrelated. |
Still happening to me on 0.23. Attaching VS to each of the 3 Microsoft.VSCode.CPP.Extension.exe processes I see shows pretty much the same thing: Main Thread:
And a couple dozen of other threads waiting, e.g.
Or
|
@sean-mcmanus But I've tried to open in singe-root folder and clang format still won't work. It seems to have something to do with the log name |
@MikeWeller Those call stacks are not doing any work (they're blocked waiting for work), i.e. not deadlocked threads. Usually, a call stack that is a deadlock will show a bunch of real work (i.e. a bigger call stack). Do you see any call stack that looks like it's doing actual work? @Jacky-Lau The log issue is unrelated. It's #3604 . |
@MikeWeller, @sean-mcmanus This has been plaguing me for several months. I kept assuming lots of people must experience this and it would get fixed very quickly. Can you give me some debug hints? When i attach to these processes I'm just in the middle of random asm. Did you download the source and do a debug build of the extension? (Is the source even available for this?) |
@peeeeter If you're on Windows you need to set |
@sean-mcmanus I am indeed using multiple workspace folders. Thanks, I got it going... let's see if I turn up anything. Of course now it seems to be working for the last 15 minutes.... |
@sean-mcmanus Before stops working, format doc has tons of log activity and shows the I/O from clang-format and such. After stops working, symptom which I believe is consistent with @MikeWeller, is that there is no log activity. Pressing Ctrl-Shift-I simply has no effect and there is no log activity. |
@sean-mcmanus Let me know if you have other ideas for debugging/more info I could provide. In some cases, formatting the document fails on the first try after restarting code and even just minor modifications to a file. |
@sean-mcmanus I dont really understand what multi-root workspace means, my workspace structure is as below. And the files are corrupting frequently. |
@Victsz Your issue could have a different cause. What is the [SSH: ...] next to the folder? It could be related to that. If you enable debug logging and you can look to make sure a didOpen message is sent for the same folder that gets the format or if there's some other error going on. |
Is there any progress or ETA on this issue at all? It's pretty critical to my workflow to the point where I'm looking at switching to a different programming environment because of the problems this has been causing. |
@kisielk No progress yet, but a lot of people are complaining about this, so I feel like it's something we should fix maybe for July/August. |
Yeah, still not sure exactly how my issue relates, I haven't done any work to test single directory workspaces. I have recently confirmed that there's nothing in the log that's unusual when it stops working. You just don't see clang I/O any more. Intellisense other stuff still scrolls by as normal. It breaks all the time. I use Ctrl-Shift-I pretty much constantly, and I have to restart vscode every 5 minutes it feels like. |
@kisielk @peeeeter Have you tried setting C_Cpp.formatting to "Disabled" and using the clang-format extension instead? @peeeeter Your issue might get fixed when we fix the multi-root issue...that would be the case if you see that the logs where formatting is occurring don't also show a didOpen message. Otherwise, we'd need to somehow get a repro or more diagnostics. The formatting runs on our "main thread" and basically just runs clang-format passing data via stdin/out, the results of which should appear in the debug logs. |
Yes, I tried that, but The Ctrl-Shift-I key binding just doesn't work, and
doesn't seem to work with the new extension. It just says:

…On Thu, Jun 20, 2019 at 6:09 PM Sean McManus ***@***.***> wrote:
@kisielk <https://github.com/kisielk> @peeeeter
<https://github.com/peeeeter> Have you tried setting C_Cpp.formatting to
"Disabled" and using the clang-format extension instead?
@peeeeter <https://github.com/peeeeter> Your issue might get fixed when
we fix the multi-root issue...that would be the case if you see that the
logs where formatting is occurring don't also show a didOpen message.
Otherwise, we'd need to somehow get a repro or more diagnostics. The
formatting runs on our "main thread" and basically just runs clang-format
passing data via stdin/out, the results of which should appear in the debug
logs.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3145?email_source=notifications&email_token=AB776WOWULABQJTJPI2FYK3P3QS4BA5CNFSM4GWBNIW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYHELQQ#issuecomment-504251842>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AB776WOOZWAVM466J74LZJ3P3QS4BANCNFSM4GWBNIWQ>
.
|
@peeeeter There is some bug with VS Code that is saving our extension as a the default formatter when it no longer a format provider (I wasn't able to repro it though). Other users have reported that using the "Configure Default Formatter..." to select "clang-format" fixes the issue. |
@sean-mcmanus Your suggestion was a good start, but now I am blocked by xaverh/vscode-clang-format#83, so I still don't have a workaround. I am still experiencing the issue when I revert to the cpp tools implementation. |
@peeeeter That is odd. I know the clang-format extension requires you to manually download the clang-format program and set the path to it manually...it sounds like it's failing to find the clang-format binary. |
@sean-mcmanus The EPIPE error was very generic and I just assumed that was the cause. With your hint I believe I solved the issue, a misplaced slash in the path. |
@peeeeter We just found/fixed a bug with named pipe creation not accessing static data in a thread safe manner which could lead to this EPIPE error (if another thread is trying to launch a process, such as for IntelliSense) -- it should be in our next release. Or...if you're saying your path had a bad slash that could be a different issue? |
Our latest Insiders release has a new multi-root implementation (which fixes this bug): https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders. Please let us know if you find any multi-root-related bugs or regressions so we can prioritize fixing those for 0.27.0. |
I'm encountering this bug on the latest VSCode and insiders CPP release. Clang format suddenly stops working until a restart. (not using multi-root) |
@jeremyong, we had reports of Clang format issues in 0.27.0-insiders2 and have a fix in the next 0.27.0-insiders3. Perhaps the issue you encountered is related to these:
|
Type: LanguageService
Since the VSCode update a day or two ago, clang-format based formatting of C++ code stops working after a few times invoking the "Reformat Selection" or "Reformat Document" commands. Once it gets into this state, even introducing a deliberate error in my .clang-format and trying to format doesn't print out an error in the Output window, which it usually does before it gets into this state. Closing and re-opening the window fixes the issue for a while before it happens again.
Describe the bug
To Reproduce
Unfortunately I haven't yet figured out precise reproduction steps. It just seems to stop working at random. I shall continue to try debugging this.
Expected behavior
The "Format Selection" and "Format Document" actions should continue to work.
Screenshots
N/A
Additional context
I turned on
"C_Cpp.loggingLevel": "Debug"
but triggering the format section/document actions don't produce any output in either the success or failure cases.I did however notice that if I restart the window, once I see this shortly afterwards, the format command is broken:
Sometimes though, I don't see the above messages and formatting works (I instead see these messages):
I don't know if this is relevant or not.
The text was updated successfully, but these errors were encountered: