Skip to content

Commit cb0f0a8

Browse files
committed
Windows: fix spurious crashes in configuration_loader
When event_loop gives the IOCP result to change_detecting_filesystem_win32, it sometimes gives a bogus error value. This is because we call GetLastError after calling GetQueuedCompletionStatus, even if GQCS succeeds. If GQCS succeeds, it doesn't set LastError, so we end up getting whatever error was set prior on the thread. Sometimes this is WAIT_TIMEOUT (which we stubbornly handle), and sometimes this is ERROR_PATH_NOT_FOUND (due to initialize_global_loggers_if_needed failing internally) (which causes an assertion failure). Fix spurious crashes and workarounds by giving change_detecting_filesystem_win32::handle_event ERROR_SUCCESS if GetQueuedCompletionStatus succeeds. Thanks to https://twitch.tv/EmptyGroceryBag for suggesting that I look at Process Monitor to see where ERROR_PATH_NOT_FOUND was coming from.
1 parent 68bddc3 commit cb0f0a8

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Beta release.
3030
* Various crashes on invalid code have been fixed.
3131
* quick-lint-js consumes less memory for pathlogical code patterns.
3232
* VS Code: The extension no longer tries to load an ARM64 DLL on Windows x64.
33+
* VS Code and LSP server: In Windows debug builds, crashes no longer occur
34+
supriously when the filesystem changes.
3335

3436
## 0.5.0 (2021-10-12)
3537

src/change-detecting-filesystem-win32.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ bool change_detecting_filesystem_win32::handle_event(
130130
watched_directory::from_oplock_overlapped(overlapped);
131131
switch (error) {
132132
case ERROR_SUCCESS:
133-
case WAIT_TIMEOUT: // FIXME(strager): Why do we sometimes get WAIT_TIMEOUT?
134133
this->handle_oplock_broke_event(dir, number_of_bytes_transferred);
135134
return true;
136135

test/test-configuration-loader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,7 @@ void change_detecting_configuration_loader::run_io_thread() {
26562656
/*lpNumberOfBytesTransferred=*/&number_of_bytes_transferred,
26572657
/*lpCompletionKey=*/&completion_key, /*lpOverlapped=*/&overlapped,
26582658
/*dwMilliseconds=*/0);
2659-
DWORD error = ::GetLastError();
2659+
DWORD error = ok ? ERROR_SUCCESS : ::GetLastError();
26602660

26612661
if (!overlapped) {
26622662
switch (error) {

0 commit comments

Comments
 (0)