gradle/native-platform

Received `device or resource busy: device or resource busy` exception in watchpoint destructor

wolfs opened this issue · 4 comments

wolfs commented

When integrating the current version of native platform in Gradle, the test SimpleJavaContinuousIntegrationTest.dependencies as inputs from local filesystem
fails.

It seems trying to cancel a watch point in its destructor yields a std::system_error exception (build scan):

Virtual file system retention is an incubating feature.
Received 14 file system events since last build
Virtual file system retained information about 11 files, 3 directories and 1 missing files since last build
Couldn't cancel watch point <project-dir>\lib: class std::system_error device or resource busy: device or resource busy
> Configure project :

I currently don't understand how this happens, since I thought that only the C++ calls throws exceptions.

wolfs commented

The exception as is doesn't really matter, the test then fails because it doesn't pick up file changes at that location anymore and we don't detect that the watching is broken after that. There are two Gradle processes involved here, one building a library in the lib directory and another one consuming the library as a dependency.

wolfs commented

After adding some debug logging, it seems like SleepEx(0, true) causes the exception to be thrown.

wolfs commented

It seems like this is caused by unregistering a watch point under another watched directory. I switched around the order in which we update the watchers in the hierarchical watch registry and see if it fixes the problem: gradle/gradle@eac7bac

wolfs commented

The test seems to work now after stopping the watches first. We should add a test to the native side to show that the exception actually happens on Windows when you try stopping a watcher inside another watched directory.