runtime: "panic: runtime error: growslice: cap out of range" when creating slice from an unsafe.Pointer in another part of program #34288
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes (1.13, also reproducible on 1.12.9)
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
As we are calling specific win32 API not available on previous versions, Windows 8.1+ is needed to reproduce.
main.go
What did you expect to see?
The commandline for all (non-elevated) processes on the host. Extract sample using WMI (current implementation in gopsutil master):
What did you see instead?
When running as an elevated user, the main.go sample is able to retrieve every possible process commandline it can retrieve like the WMI implementation. The issue occurs with non-elevated user with a panic runtime as explained in shirou/gopsutil#250 (comment).
Commenting out this line doesn't trigger the panic and hints that the issue resides in the unicodeString.String() function (got it from an UNICODE_STRING implementation in hillu/go-ntdll). What's puzzling is that it works properly running as an elevated user and that the stacktrace looks completely unrelated (in fmt stdlib), the stacktrace appears even for a PID where
buf.String()
is not even called, hinting about some memory/stack corruption maybe?The text was updated successfully, but these errors were encountered: