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

"Exception 0xc0000005", "runtime: unknown pc" on program exit with loaded windows dll #42593

Closed
altermark opened this issue Nov 13, 2020 · 2 comments

Comments

@altermark
Copy link

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

$ go version
go version go1.15.5 windows/amd64

Does this issue reproduce with the latest release?

yes

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

Windows 10 Pro, 20H2, build 19042.630

go env Output
$ go env

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Marek\AppData\Local\go-build
set GOENV=C:\Users\Marek\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=d:\Go.external\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=d:\Go.external;d:\Go
set GOPRIVATE=
set GOPROXY=direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\Marek\AppData\Local\Temp\go-build143512754=/tmp/go-build -gno-record-gcc-switches

What did you do?

Our IS vendor provides us with DLL to access information system from scripts etc. Recently I recompiled one of our scripts and noticed, that after successful execution it ends with memory dump, registry dump, stacktrace and command window freeze.

When compiling with go 1.14.12 everything works. When compiling with any go from 1.15.x series it throws the error. To reproduce it's enough to load the DLL even without executing any function from it.

package main

import (
	"log"
	"golang.org/x/sys/windows"
)

func main() {
	ec := windows.NewLazyDLL("Econnect.dll")
	err := ec.Load()
	if err != nil {
		log.Println(err)
	}
}

Unfortunately I don't have source code for the library nor info about compilation options (the communication with our IS vendor is a bit difficult), so I'm attaching the binary and a test script. Any other DLL that I have tested on my system loads, works and exits cleanly.
Loading and calling the library from Python works without error too.

xtest.zip

What did you expect to see?

Clean program exit.

What did you see instead?

D:\Temp\test>go build xtest.go && .\xtest.exe
Exception 0xc0000005 0x0 0x1dbb16305c0 0xefea89
PC=0xefea89

runtime: unknown pc 0xefea89
stack: frame={sp:0x2ac3fff670, fp:0x0} stack=[0x0,0x2ac3fffec0)
0000002ac3fff570: 0000000000ef1390 0000000000f04c2f
0000002ac3fff580: 000001db8a190000 0000000000ef69f1
0000002ac3fff590: 000001dbb0feb770 0000000000000000
0000002ac3fff5a0: 000001dbb0fea9b0 0000000000f1e260
0000002ac3fff5b0: 0000000000000001 0000000000ef0000
0000002ac3fff5c0: 000000000299ec00 000000000277f490
0000002ac3fff5d0: 000001db89fed280 00007ffc28be5d21
0000002ac3fff5e0: 000000000299f260 000001db89fc0000
0000002ac3fff5f0: 0000002ac3fff7c0 0000000000000000
0000002ac3fff600: 0000000000000000 000000000299ed28
0000002ac3fff610: 000000000299ed28 00007ffc26744c2f
0000002ac3fff620: 000001db89fed280 0000002ac3fff9d0
0000002ac3fff630: 000000000299f130 000000000299f130
0000002ac3fff640: 000000000299ef88 00000000b1c1ef01
0000002ac3fff650: 000000000299ed28 0000000000f0b843
0000002ac3fff660: 0000000000000000 0000000002a509c0
0000002ac3fff670: <0000002ac3fff9d0 0000000002a4e3f0
0000002ac3fff680: 000000000299ed28 0000000000f0b7fc
0000002ac3fff690: 000001db89fed280 0000000000f38f78
0000002ac3fff6a0: ffffffffffffffff 0000002ac3fff9d0
0000002ac3fff6b0: 000000000299ed28 0000000000f0b3c2
0000002ac3fff6c0: 000001dbb16305c0 0000000000f00b26
0000002ac3fff6d0: 0000000002784858 000000000000001a
0000002ac3fff6e0: 0000000000000000 0000000000000000
0000002ac3fff6f0: 000000010eedfade 0000000000000000
0000002ac3fff700: 00007ffc284b847e 0000000000000007
0000002ac3fff710: 00007ffc284b847e 000001dbb16305c0
0000002ac3fff720: 0000000000000000 0000000000000000
0000002ac3fff730: 0000000000000000 0000000000000000
0000002ac3fff740: 0000000000000000 0000002ac3fff9d0
0000002ac3fff750: 0000000002784040 0000000000f0b6db
0000002ac3fff760: 0000000000000000 000001dbb0dc0000
runtime: unknown pc 0xefea89
stack: frame={sp:0x2ac3fff670, fp:0x0} stack=[0x0,0x2ac3fffec0)
0000002ac3fff570: 0000000000ef1390 0000000000f04c2f
0000002ac3fff580: 000001db8a190000 0000000000ef69f1
0000002ac3fff590: 000001dbb0feb770 0000000000000000
0000002ac3fff5a0: 000001dbb0fea9b0 0000000000f1e260
0000002ac3fff5b0: 0000000000000001 0000000000ef0000
0000002ac3fff5c0: 000000000299ec00 000000000277f490
0000002ac3fff5d0: 000001db89fed280 00007ffc28be5d21
0000002ac3fff5e0: 000000000299f260 000001db89fc0000
0000002ac3fff5f0: 0000002ac3fff7c0 0000000000000000
0000002ac3fff600: 0000000000000000 000000000299ed28
0000002ac3fff610: 000000000299ed28 00007ffc26744c2f
0000002ac3fff620: 000001db89fed280 0000002ac3fff9d0
0000002ac3fff630: 000000000299f130 000000000299f130
0000002ac3fff640: 000000000299ef88 00000000b1c1ef01
0000002ac3fff650: 000000000299ed28 0000000000f0b843
0000002ac3fff660: 0000000000000000 0000000002a509c0
0000002ac3fff670: <0000002ac3fff9d0 0000000002a4e3f0
0000002ac3fff680: 000000000299ed28 0000000000f0b7fc
0000002ac3fff690: 000001db89fed280 0000000000f38f78
0000002ac3fff6a0: ffffffffffffffff 0000002ac3fff9d0
0000002ac3fff6b0: 000000000299ed28 0000000000f0b3c2
0000002ac3fff6c0: 000001dbb16305c0 0000000000f00b26
0000002ac3fff6d0: 0000000002784858 000000000000001a
0000002ac3fff6e0: 0000000000000000 0000000000000000
0000002ac3fff6f0: 000000010eedfade 0000000000000000
0000002ac3fff700: 00007ffc284b847e 0000000000000007
0000002ac3fff710: 00007ffc284b847e 000001dbb16305c0
0000002ac3fff720: 0000000000000000 0000000000000000
0000002ac3fff730: 0000000000000000 0000000000000000
0000002ac3fff740: 0000000000000000 0000002ac3fff9d0
0000002ac3fff750: 0000000002784040 0000000000f0b6db
0000002ac3fff760: 0000000000000000 000001dbb0dc0000

goroutine 1 [running]:
runtime.asmcgocall(0x7f6060, 0x91fbf8)
c:/go/src/runtime/asm_amd64.s:641 +0x47
runtime.stdcall(0x7ffc287ee0a0, 0x84ccd8)
c:/go/src/runtime/os_windows.go:916 +0x93
runtime.stdcall1(0x7ffc287ee0a0, 0x0, 0xc0000180b8)
c:/go/src/runtime/os_windows.go:936 +0x47
runtime.exit(0xc000000000)
c:/go/src/runtime/os_windows.go:579 +0x49
runtime.main()
c:/go/src/runtime/proc.go:226 +0x25d
runtime.goexit()
c:/go/src/runtime/asm_amd64.s:1374 +0x1
rax 0x0
rbx 0x2ac3fff6f0
rcx 0x1dbb16305c0
rdi 0x299ed28
rsi 0x7ffc284b847e
rbp 0x2ac3fff6d0
rsp 0x2ac3fff670
r8 0x1db8a191380
r9 0x1
r10 0x8000
r11 0x2ac3fff5b0
r12 0x277f490
r13 0x299ec00
r14 0xef0000
r15 0x1
rip 0xefea89
rflags 0x10206
cs 0x33
fs 0x53
gs 0x2b

@networkimprov
Copy link

You might try go build -buildmode=exe; the default changed recently.

cc @alexbrainman @mattn

@gopherbot add OS-Windows

@altermark altermark changed the title "runtime: unknown pc" error on program exit with loaded windows dll "Exception 0xc0000005", "runtime: unknown pc" on program exit with loaded windows dll Nov 18, 2020
@altermark
Copy link
Author

go build -buildmode=exe works. Thank you for suggestion.

Closing the issue as my problem is solved.

Mentioning for tracking purposes:
origin #35192
similar #41329

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

3 participants