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

runtime: windows/amd64 crash in -buildmode=c-shared library #59705

Closed
fzwoch opened this issue Apr 19, 2023 · 3 comments
Closed

runtime: windows/amd64 crash in -buildmode=c-shared library #59705

fzwoch opened this issue Apr 19, 2023 · 3 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows

Comments

@fzwoch
Copy link

fzwoch commented Apr 19, 2023

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

$ go version
go version go1.20.3 linux/amd64

Does this issue reproduce with the latest release?

Yes.
It is actually a regression compared to 1.19.8. Where this crash is not happening.

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

go env Output
$ go env
root@c300f22c186f:/# go version
go version go1.20.3 linux/amd64
root@c300f22c186f:/# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4015789462=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Cross compiling with -buildmode=c-shared from linux/amd64 for windows/amd64 with cgo enabled.

For cgo, regular MinGW/GCC as well as MinGW/LLVM compiler have been tried.

https://github.com/fzwoch/obs-teleport (project's code)

What did you expect to see?

The resulting .dll file is a plugin for https://github.com/obsproject/obs-studio

I expected that application to successfully load the shared library.

It does so when the plugin is compiled with go1.19.8 linux/amd64.

What did you see instead?

Getting the following runtime crash when loading the library in OBS Studio.

Unfortunately no more details. I have no particular good knowledge on how to produce proper debug versions/stack traces with MSVC.

Only got a stack trace with three frames in it:

runtime.abort()

--- /usr/local/go/src/runtime\asm_amd64.s --------------------------------------
00007FF9A23D50C1  add         ebp,ebx       <========== final crash
00007FF9A23D50C3  dec         ah  


runtime.wintls()

--- /usr/local/go/src/runtime\sys_windows_amd64.s ------------------------------
00007FF9A23D71C0  mov         rax,rsp  
00007FF9A23D71C3  and         rsp,0FFFFFFFFFFFFFFF0h  
00007FF9A23D71C7  sub         rsp,30h  
00007FF9A23D71CB  mov         qword ptr [rsp+20h],rax  
00007FF9A23D71D0  mov         rax,qword ptr [7FF9A26D58B0h]  
00007FF9A23D71D7  call        rax  
00007FF9A23D71D9  mov         rsp,qword ptr [rsp+20h]  
00007FF9A23D71DE  mov         rcx,rax  
00007FF9A23D71E1  cmp         rcx,40h  
00007FF9A23D71E5  jb          00007FF9A23D71EC  
00007FF9A23D71E7  call        00007FF9A23D50C0  
00007FF9A23D71EC  shl         rcx,3         <========== 2nd stack frame location
00007FF9A23D71F0  add         rcx,1480h  
00007FF9A23D71F7  mov         qword ptr [7FF9A2732838h],rcx  
00007FF9A23D71FE  ret  


runtime.rt0_go()

--- /usr/local/go/src/runtime\asm_amd64.s --------------------------------------
00007FF9A23D2D20  mov         rax,rdi  
00007FF9A23D2D23  mov         rbx,rsi  
00007FF9A23D2D26  sub         rsp,28h  
00007FF9A23D2D2A  and         rsp,0FFFFFFFFFFFFFFF0h  
00007FF9A23D2D2E  mov         qword ptr [rsp+18h],rax  
00007FF9A23D2D33  mov         qword ptr [rsp+20h],rbx  
00007FF9A23D2D38  lea         rdi,[7FF9A26DFB40h]  
00007FF9A23D2D3F  lea         rbx,[rsp-0FF98h]  
00007FF9A23D2D47  mov         qword ptr [rdi+10h],rbx  
00007FF9A23D2D4B  mov         qword ptr [rdi+18h],rbx  
00007FF9A23D2D4F  mov         qword ptr [rdi],rbx  
00007FF9A23D2D52  mov         qword ptr [rdi+8],rsp  
00007FF9A23D2D56  mov         eax,0  
00007FF9A23D2D5B  cpuid  
00007FF9A23D2D5D  cmp         eax,0  
00007FF9A23D2D60  je          00007FF9A23D2D8E  
00007FF9A23D2D62  cmp         ebx,756E6547h  
00007FF9A23D2D68  jne         00007FF9A23D2D81  
00007FF9A23D2D6A  cmp         edx,49656E69h  
00007FF9A23D2D70  jne         00007FF9A23D2D81  
00007FF9A23D2D72  cmp         ecx,6C65746Eh  
00007FF9A23D2D78  jne         00007FF9A23D2D81  
00007FF9A23D2D7A  mov         byte ptr [7FF9A273260Bh],1  
00007FF9A23D2D81  mov         eax,1  
00007FF9A23D2D86  cpuid  
00007FF9A23D2D88  mov         dword ptr [7FF9A2732674h],eax  
00007FF9A23D2D8E  mov         rax,qword ptr [7FF9A26D52E8h]  
00007FF9A23D2D95  test        rax,rax  
00007FF9A23D2D98  je          00007FF9A23D2DDC  
00007FF9A23D2D9A  lea         rsi,[7FF9A23D21E0h]  
00007FF9A23D2DA1  mov         rdx,0  
00007FF9A23D2DA8  mov         rcx,0  
00007FF9A23D2DAF  lea         rdx,[7FF9A2732838h]  
00007FF9A23D2DB6  mov         r9,rcx  
00007FF9A23D2DB9  mov         r8,rdx  
00007FF9A23D2DBC  mov         rdx,rsi  
00007FF9A23D2DBF  mov         rcx,rdi  
00007FF9A23D2DC2  call        rax  
00007FF9A23D2DC4  lea         rcx,[7FF9A26DFB40h]  
00007FF9A23D2DCB  mov         rax,qword ptr [rcx]  
00007FF9A23D2DCE  add         rax,13A0h  
00007FF9A23D2DD4  mov         qword ptr [rcx+10h],rax  
00007FF9A23D2DD8  mov         qword ptr [rcx+18h],rax  
00007FF9A23D2DDC  call        00007FF9A23D71C0  
00007FF9A23D2DE1  lea         rdi,[7FF9A26DFF38h]       <========== first stack frame location
00007FF9A23D2DE8  call        00007FF9A23D7040  
00007FF9A23D2DED  mov         rbx,qword ptr [7FF9A2732838h]  
00007FF9A23D2DF4  mov         rbx,qword ptr gs:[rbx]  
00007FF9A23D2DF8  mov         qword ptr [rbx],123h  
00007FF9A23D2DFF  mov         rax,qword ptr [7FF9A26DFF38h]  
00007FF9A23D2E06  cmp         rax,123h  
00007FF9A23D2E0C  je          00007FF9A23D2E13  
00007FF9A23D2E0E  call        00007FF9A23D50C0  
00007FF9A23D2E13  mov         rbx,qword ptr [7FF9A2732838h]  
00007FF9A23D2E1A  mov         rbx,qword ptr gs:[rbx]  
00007FF9A23D2E1E  lea         rcx,[7FF9A26DFB40h]  
00007FF9A23D2E25  mov         qword ptr [rbx],rcx  
00007FF9A23D2E28  lea         rax,[7FF9A26DFEE0h]  
00007FF9A23D2E2F  mov         qword ptr [rax],rcx  
00007FF9A23D2E32  mov         qword ptr [rcx+30h],rax  
00007FF9A23D2E36  cld  
00007FF9A23D2E37  call        00007FF9A23D7A40  
00007FF9A23D2E3C  mov         eax,dword ptr [rsp+18h]  
00007FF9A23D2E40  mov         dword ptr [rsp],eax  
00007FF9A23D2E43  mov         rax,qword ptr [rsp+20h]  
00007FF9A23D2E48  mov         qword ptr [rsp+8],rax  
00007FF9A23D2E4D  call        00007FF9A23D7A00  
00007FF9A23D2E52  call        00007FF9A23D7760  
00007FF9A23D2E57  call        00007FF9A23D7940  
00007FF9A23D2E5C  lea         rax,[7FF9A25A97D0h]  
00007FF9A23D2E63  push        rax  
00007FF9A23D2E64  call        00007FF9A23D79C0  
00007FF9A23D2E69  pop         rax  
00007FF9A23D2E6A  call        00007FF9A23D2EE0  
00007FF9A23D2E6F  call        00007FF9A23D50C0  
00007FF9A23D2E74  ret  
00007FF9A23D2E75  mov         qword ptr [rsp],2  
00007FF9A23D2E7D  lea         rax,[7FF9A25AB7A0h]  
00007FF9A23D2E84  mov         qword ptr [rsp+8],rax  
00007FF9A23D2E89  mov         qword ptr [rsp+10h],54h  
00007FF9A23D2E92  call        00007FF9A23D7DA0  
00007FF9A23D2E97  mov         qword ptr [rsp],1  
00007FF9A23D2E9F  call        00007FF9A23D77E0  
00007FF9A23D2EA4  call        00007FF9A23D50C0  
00007FF9A23D2EA9  ret  
00007FF9A23D2EAA  lea         rax,[7FF9A23D5480h]  
00007FF9A23D2EB1  ret  
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Apr 19, 2023
@bcmills
Copy link
Contributor

bcmills commented Apr 19, 2023

(CC @golang/windows)

@bcmills bcmills added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 19, 2023
@qmuntal
Copy link
Contributor

qmuntal commented Apr 19, 2023

Same as #59213.

@mknyszek
Copy link
Contributor

Closing as duplicate of #59213.

@mknyszek mknyszek closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2023
@golang golang locked and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

No branches or pull requests

5 participants