gradle / gradle/native-platform
Unhandled failure case for GetFileInformationByHandleEx when STD handles are pipes
- Dominant language
- Java
- Stars
- 126
- Forks
- 44
- Avg merge
- 7h 44m
- Merged PRs (30d)
- 9
Description
[This Gradle issue](https://github.com/gradle/gradle/issues/11205) expose an interesting system configuration which cause [`GetFileInformationByHandleEx` to fail with `ERROR_INVALID_FUNCTION` under a scenario where the STD handles are pipes](https://github.com/adammurdoch/native-platform/blob/master/src/main/cpp/win.cpp#L652-L656) on, what appears to be, very specific driver usage. Unfortunately, the reproduction case is still unknown but I will document what have been found.
I could only successfully creating STD handles as pipe when running on mintty with Cygwin 3. However, even with this setup the `GetFileInformationByHandleEx` function succeeded properly. The most [plausible answer](https://stackoverflow.com/questions/46385457/getfinalpathnamebyhandle-fails-for-device-handles) for the API call to return invalid function error is the underlying driver doesn't handle the IRP sent to it or it simply fail for some other reason which cause the invalid function error to be returned. Assuming this is correct, the possible scenarios could be where custom drivers would be used which involves containers, some sort of virtualization, network drives or specialized hardware. It seems the Gradle errors is flaky which makes it harder to narrow the issue further.
A better alternative could be to[ use `NtQueryObject` API instead](https://github.com/git/git/blob/master/compat/winansi.c#L571). I can't confirmed yet if the API goes through the driver. The feeling is it's a Kernel call that return information from the object store.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.