Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled failure case for GetFileInformationByHandleEx when STD handles are pipes #43

Open
lacasseio opened this issue Nov 22, 2019 · 2 comments

Comments

@lacasseio
Copy link

This Gradle issue expose an interesting system configuration which cause GetFileInformationByHandleEx to fail with ERROR_INVALID_FUNCTION under a scenario where the STD handles are pipes 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 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. 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.

@lacasseio
Copy link
Author

This answer seems to be quite comprehensive on the difference of both NtQueryObject and GetFileInformationByHandleEx. I also quickly went through the Object Manager explanation in the Windows Internal book and it seems like my feeling was correct. The header of the object should contains the name and should be owned by the Kernel so no IRP to the underlying driver hence no ERROR_INVALID_FUNCTION should be returned.

@lacasseio
Copy link
Author

The issue may be caused by Powershell, see gradle/gradle#11205 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant