-
Notifications
You must be signed in to change notification settings - Fork 18
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
Unexpected (nil, nil) result from wincred.GetGenericCredential #32
Comments
Sorry for the late response. That issue sounds interesting. I could imagine some out-of-memory issues. Can you reproduce that behaviour reliably on your end? Is there anything interesting returned from |
I have successfully reproduced this in GitHub CLI based on a user report cli/cli#7283, but have been pulling my hair for one whole day while trying to come up with an isolated reproduction case for this. As soon as I touched anything about the (large) program that reproduces this, GetGenericCredential would start working again as designed. Sprinkling in some debug statements revealed that the failure occurs for some pointer values of pcred but not for others: Line 68 in 90f7265
If my hunch is true, then this is a memory issue and is dependent on the current memory allocation state of the program at the time that the syscall runs. When reading the Windows API documentation on CredReadW, I wasn't really clear on whether it expects us to pre-allocate a struct in memory, so I've tried that and it seemed to work. I've sent a PR that illustrates my workaround, but please take it with a grain of salt. |
Thanks for the update. |
@danieljoos I've been able to reproduce this on both Windows 10 and Windows 11. To most reliably reproduce, you can try compiling Things I have tried that did not have any effect:
Something interesting I have noticed: a some prominent callers of
The internal function that does conversion from Windows to Go struct also has a guard that returns nil early if Lines 48 to 51 in 90f7265
|
@mislav Thank you for the details. I was able to reproduce it following your instructions. I really don't know what's happening here. For your particular example, this always happens for the What I investigated so far:
There seems to be something that the |
I traced the calls to |
I'm pretty sure to have found the issue. It is discussed here:
|
@danieljoos Thanks so much for diving into this. I was also looking at that Go issue, but it seemed that since that issue was opened, changes landed to Go that made it "safer" to use If switching to SyscallN addresses the issue, that would be very welcome. |
We've started hitting this as well. Looking forward to your PR. |
Please have a look at the changes if you like: If you're all fine with that, I'll merge it and tag a new version. |
Closing this for the moment. Issue is hopefully resolved in version |
Let me start off by saying that I don't think this is a bug in the package, but I'm hoping you might have an idea on why I'm getting both a nil credential and a nil error coming back. I've traced it to unexpected results in
sysCredRead
where the wrapped system call is returning 1 (indicating success), yet pcred remains nil. Unsurprisingly this unexpected output causes invalid output up the chain of calls and panics if a nil error is presumed to mean the credential pointer is valid. The only at all atypical thing I'm doing is calling it from within CGo, but I can't see any reason why that should make a difference.The text was updated successfully, but these errors were encountered: