Skip to content

Formatting with a symlinked folder may randomly corrupt files #5061

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

Open
sean-mcmanus opened this issue Mar 5, 2020 · 11 comments
Open

Formatting with a symlinked folder may randomly corrupt files #5061

sean-mcmanus opened this issue Mar 5, 2020 · 11 comments
Labels
bug Feature: Code Formatting investigate: repro This issue's repro steps needs to be investigated/confirmed Language Service symlinks
Milestone

Comments

@sean-mcmanus
Copy link
Contributor

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 am affected by the bug. My working directory is a symlink, and once in a while when I reformat the code my file becomes corrupted. I am using /0.27.0-insiders2

Originally posted by @olzhas in #1073 (comment)

@sean-mcmanus sean-mcmanus added bug Feature: Code Formatting investigate: repro This issue's repro steps needs to be investigated/confirmed Language Service symlinks labels Mar 5, 2020
@sean-mcmanus
Copy link
Contributor Author

sean-mcmanus commented Mar 5, 2020

@olzhas Can you provide more info? What OS are you on? Does it repro with a single root workspace folder or does it require multiple root folders? Do you know of a way to make the "once in a while" more consistent?

The root cause might be related to other known symlink issues, such as #4573 or #3123 .

@mmoskal
Copy link
Member

mmoskal commented May 4, 2020

When I have the same file open through two different symlinks (cpp tools go to definition finds it differently than when I open it from the file explorer on the side), and I try to format one of the files, it gets corrupted. Closing one of the copies fixes the problem

I'm on macOS 10.14.6, VSCode 1.44.2.

@KnBrckr
Copy link

KnBrckr commented May 12, 2020

I've noticed I'm seeing this issue. On Windows 10, VSCode 1.44.2, cpptools 0.27.1, using WSL and a symlinked directory. I haven't sorted out how to recreate the problem reliably. I see it on some tabs, not others. On the tab I was seeing this reliably, closed the file and reopened in a new tab, no longer seeing the corruption. The file was only open in a single tab.

@rfjakob
Copy link

rfjakob commented Aug 8, 2021

A few more reports of data corruption that have been auto-closed: #2941 #3796 #3809 #1073

I just lost about an hour's work because of this. How is this not a P1 issue? Shouldn't formatting be disabled per default until this is sorted out?

@sean-mcmanus
Copy link
Contributor Author

@rfjakob The bug hasn't gotten many upvotes and only seems to happen when symlinked folders are used. I'm not sure if we have a repro yet too.

@rfjakob
Copy link

rfjakob commented Aug 10, 2021

Counting through the duplicates, there's independent reports from

I guess compared to the total user base of VS Code, that's few, but the impact is quite high (data loss).

If this were my project, I would disable code formatting per default until a reproducer is found.

@rfjakob
Copy link

rfjakob commented Aug 10, 2021

Ok, I found a reproducer:

(1) Prepare source code repo & symlink

mkdir /tmp/issue5061
cd /tmp/issue5061
git clone --branch v1.6.2 https://github.com/rfjakob/earlyoom.git
ln -s earlyoom earlyoom-symlink

(2) In VS Code: File -> New Window. Add Folder: /tmp/issue5061/earlyoom-symlink

(3) In the sidebar, open meminfo.c and main.c

(4) In main.c go to line 405 and Go To Definition of parse_meminfo()

(5) You now have meminfo.c open two times. Once via /tmp/issue5061/earlyoom-symlink/meminfo.c and 2nd time via /tmp/issue5061/earlyoom/meminfo.c . That's the first bug.

(6) Write "foo" to the bottom of the 2nd meminfo.c, save.

(7) Jump back to 1st meminfo.c, scroll to bottom. Don't change anything. Save. Garbage gets appended. That's the 2nd bug.

(8) Click save again for more garbage (each save appends more)

@rfjakob
Copy link

rfjakob commented Aug 10, 2021

Screenshots for steps 1-8 below:

Screenshot from 2021-08-10 12-09-53
Screenshot from 2021-08-10 12-10-39
Screenshot from 2021-08-10 12-10-40
Screenshot from 2021-08-10 12-11-47
Screenshot from 2021-08-10 12-12-11
Screenshot from 2021-08-10 12-12-19
Screenshot from 2021-08-10 12-12-24
Screenshot from 2021-08-10 12-12-47

@sean-mcmanus
Copy link
Contributor Author

@rfjakob I believe most of those previous clang-format corruption bugs were different/older bugs that have gotten fixed (with different root causes).

The root cause of this issue is #4573 .

@tuyisenge250
Copy link

what i can do when my complier my program in c and got error like The terminal process failed to launch (exit code: -1).
and my file mane don't belong in l launch.json

@rfjakob
Copy link

rfjakob commented Oct 12, 2023

The root cause of this issue is #4573 .

How can intellisense cause corruption in files? Does it write to source code files?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Feature: Code Formatting investigate: repro This issue's repro steps needs to be investigated/confirmed Language Service symlinks
Projects
None yet
Development

No branches or pull requests

5 participants