Fix infinite loop when failed to find path for volume on Windows - #2066
Conversation
|
thanks for the fix, but are you able to add a test to simulate the problem ? |
|
I've refactored it to allow inserting custom functions I'm not very familiar with Go. In Python people would monkey-patch |
shirou
left a comment
There was a problem hiding this comment.
Thank you for your PR. The fix for the infinite loop is a nice catch!
I appreciate you adding the test based on the review feedback. However, the test only verifies the if/else control flow, which is fairly straightforward. I think changing the function signature to 9 arguments just for this test is a bit much.
Sorry for the extra work, but could you revert to your original minimal fix? That's all we need here. Thanks!
This reverts commit a257800.
|
Ok I've reverted the test and kept it a minimal change. |
When
getVolumePathsreturns an error, we should not just continue the for loop. We should skipprocessMountsForVolume, then updatevolNameBufusingprocFindNextVolumeW. Otherwise it would loop forever.I discovered this bug when running wandb, which uses gopsutil to collect system info, and there is a virtual CD program on my machine that leaves a stale volume that causes an error in
getVolumePaths. It's discussed in #1911 but not really fixed yet.