Recently, user na-an discovered that when opening a folder with Microsoft’s VSCode editor, many empty files with invalid code are automatically created in the directory. The user then posted a related issue to the VSCode GitHub repository, which randomly sparked a lively discussion, with many users saying they were also suffering from the bug.
Some of the file names are short, some are long, and the names of these files are not valid unicode, for example \312\316\361 in the figure is octal. Randomly created files appear to come from running process memory dumps, contain strings that normally appear in executable files, and look like pointers with stack corruption or out-of-bounds problems.
The worst thing is that besides creating empty files like crazy, VSCode will also modify user files randomly, for example, all the contents of user daantimmer’s headers are cleared and all of them become 0 KB (I hope there is a backup 🙏).
The bug is not limited to the current workspace folder, it can even empty some system files/folders.
The bug has appeared on different systems such as Windows and Linux, but the victims have one very interesting thing in common: they all write C++ code and use the C++ extensions of VSCode. The problem disappeared after someone tried to disable all extensions for all extensions; if you switch the C++ extension to a stable version (1.8.4), the problem also disappears.
This solved the case (issues 9041). It turns out that the source of the bug is the pre-release version of VSCode C++ extension 1.9.4, which is not stable and has the above file system bug. However, if you check the VSCode auto-update feature, it will automatically update to the pre-release version of C++ extension 1.9.4.
However, the developers of the C++ extension do not know exactly what is wrong with version 1.9.4. The memory corruption issue seems to be related to several long-standing but unresolved file corruption bugs in the C++ extension: #4573 and #5061. The current speculation is that version 1.9.4 accidentally used uninitialized memory, and that the pointer issue caused some file system problems due to modifications to external third-party subsystems that do not follow modern C++ coding guidelines and may prevent or detect the use of uninitialized pointers.
The solution to this problem is as simple as not installing the 1.9.4 version of the C++ extension, which is not present in 1.9.5, 1.9.3, 1.8.4, or the newly released 1.9.6.