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

dll call Parse array memory crash #42624

Closed
pandatest2023 opened this issue Nov 16, 2020 · 2 comments
Closed

dll call Parse array memory crash #42624

pandatest2023 opened this issue Nov 16, 2020 · 2 comments

Comments

@pandatest2023
Copy link

What version of Go are you using (go version)?

$ go version
go1.2

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

windows AMD64

go env Output
$ go env

What did you do?

This is the code for reproduce:
https://play.golang.org/p/XDkeaALSdaY

Here's the output:

path: 1.zip
RmStartSession SUCCESS 0
RmRegisterResources SUCCESS 0
nProcInfo 0
nProcInfoNeeded 1
         Need structure RM_PROCESS_INFO 1 individual...
RmGetList  0
15199867816557521
[SUCCESS] Getting the list of affected processes (services) succeeded...
         The list is as follows:
unexpected fault address 0xffffffffffffffff
fatal error: fault
[signal 0xc0000005 code=0x0 addr=0xffffffffffffffff pc=0x4a3b9d]

goroutine 1 [running]:
runtime.throw(0x4d87a1, 0x5)
        D:/GO/src/runtime/panic.go:608 +0x79 fp=0xc00007fc68 sp=0xc00007fc38 pc=0x429c79
runtime.sigpanic()
        D:/GO/src/runtime/signal_windows.go:207 +0x139 fp=0xc00007fc98 sp=0xc00007fc68 pc=0x43a899
main.main()
        E:/2.go:151 +0x98d fp=0xc00007ff98 sp=0xc00007fc98 pc=0x4a3b9d
runtime.main()
        D:/GO/src/runtime/proc.go:201 +0x207 fp=0xc00007ffe0 sp=0xc00007ff98 pc=0x42b617
runtime.goexit()
        D:/GO/src/runtime/asm_amd64.s:1333 +0x1 fp=0xc00007ffe8 sp=0xc00007ffe0 pc=0x450f91
exit status 2

What did you expect to see?

What did you see instead?

I'm a novice programmer, and I'm trying to write this function in golang, and I've run into some problems
Unable to parse RmGetList return array
reference
C# Code https://docs.microsoft.com/en-us/archive/msdn-magazine/2007/april/net-matters-restart-manager-and-generic-method-compilation
C++ Code https://www.fatalerrors.org/a/windows-restartmaneger-restart-manager.html

@AlexRouSg
Copy link
Contributor

AlexRouSg commented Nov 16, 2020

uintptr(unsafe.Pointer(&_RM_PROCESS_INFO)),
This is wrong, _RM_PROCESS_INFO is a slice not a array.
A slice is something like a managed array (see https://blog.golang.org/slices-intro), so you need to do &(_RM_PROCESS_INFO[0])

Please see https://github.com/golang/go/wiki/Questions for a better place to ask questions.

@ALTree
Copy link
Member

ALTree commented Nov 17, 2020

Yes, we only really use the github issue tracker to track confirmed bugs in Go (or proposals to change the language). If this crash is caused by misuses of unsafe and cgo (I wouldn't be surprised, they're really hard to use correctly for a beginner), is not something that qualifies as a Go bug.

@ALTree ALTree closed this as completed Nov 17, 2020
@golang golang locked and limited conversation to collaborators Nov 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants