franneck94 / Vscode-C-Cpp-Runner

🚀 Compile, run and debug single or multiple C/C++ files with ease. 🚀
MIT License
53 stars 14 forks source link

[BUG] constantly updating settings.json #140

Closed bexrr closed 9 months ago

bexrr commented 10 months ago

When Cpp-Runner is enabled, settings.json is constantly updated, so that I cannot update settings.json manually.

VS code is constantly refreshing view of settings.json content. Here I'm trying to change the content in an external editor: image

Not sure if any other VS code extension is influencing this behaviour, but when I disable Cpp-Runner no automatic modifications to settings.json are made anymore. Using ubuntu 22.04.

starball5 commented 9 months ago

Someone on Stack Overflow is reporting a similar problem for launch configs: The path in the launch.json keep automatically changing. @bexrr Do you have the same issue with launch configs as well?

franneck94 commented 9 months ago

What happens if you click on "Save Anyway".

In general the settings file is only written once at startup. Maybe, the file saving is blocked on your system

bexrr commented 9 months ago

@starball5 No issues with launch.json (and c_cpp_properties.json). @franneck94 Saving does not work, when clicking "Save Anyway". Saving the settings.json file is possible when disabling the Cpp-Runner extension.. Maybe some interesting information: After some time having the settings.json open in my workspace, the content changes to some default settings (I guess?). I found a "workaround" how to edit the settings: By disabling the extension, editing settings.json and then enabling the extension again. Still I'm not content with settings.json being constantly updated.

franneck94 commented 9 months ago

Maybe its fixed in 9.4.1

bexrr commented 9 months ago

No, the issue still exists, unfortunately.

franneck94 commented 9 months ago

Please try 9.4.2 on a fresh workspace.

(I'm just guessing since i cannot reproduce the problem)

bexrr commented 9 months ago

Still not working. I've audited settings.json and found that the system call "openat" is called continuously (log abbreviated):

type=SYSCALL msg=audit(1704266246.810:2105): syscall=257 success=yes exit=44 a0=ffffff9c a1=7ffdca365120 a2=[..] a3=[..] items=2 ppid=8941 pid=9066 subj=[...].code SYSCALL=openat

The call is successful and returns a valid file descriptor. The arguments to the system call are the path to settings.json, so everything is fine regarding the call and its return.

franneck94 commented 9 months ago

I think the problem is not related to the extension at all

bexrr commented 9 months ago

I've started a debug session: I seems like there is a loop in the settingsProvider.changeCallback(): A callback is registered in case settings.json is changed. In this callback function, settings.json is written again which triggers the onChangeCallback again.. Writing settings.json in this changeCallback is triggered when handling the property msvcBatchPath. I have added an OS check when handling the msvcBatchPath (settingsProvider line 282): this.operatingSystem === OperatingSystems.windows && which fixes the problem for me.

franneck94 commented 9 months ago

image

So like this?

franneck94 commented 9 months ago

Fixed in 9.4.3