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

syscall: win.GetMessage syscall.Syscall6 crash #41284

Open
zhaoya881010 opened this issue Sep 9, 2020 · 6 comments
Open

syscall: win.GetMessage syscall.Syscall6 crash #41284

zhaoya881010 opened this issue Sep 9, 2020 · 6 comments

Comments

@zhaoya881010
Copy link

@zhaoya881010 zhaoya881010 commented Sep 9, 2020

golang version 1.15
Windows server 2012
Exception 0xc0000005 0x0 0x1749111c 0x77e47594
PC=0x77e47594
signal arrived during external code execution

syscall.Syscall6(0x7598a5b0, 0x4, 0x27066f8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
C:/Go/src/runtime/syscall_windows.go:201 +0xbb
GoProxy/vendor/github.com/lxn/win.GetMessage(0x27066f8, 0x0, 0x0, 0x0, 0x1)
D:/svn_code/src/GoProxy/vendor/github.com/lxn/win/user32.go:2564 +0x8a
GoProxy/vendor/github.com/lxn/walk.(*FormBase).mainLoop(0x2eb9a000, 0x0)
D:/svn_code/src/GoProxy/vendor/github.com/lxn/walk/mainloop_default.go:20 +0x95
GoProxy/vendor/github.com/lxn/walk.(*FormBase).Run(0x2eb9a000, 0x0)
D:/svn_code/src/GoProxy/vendor/github.com/lxn/walk/form.go:373 +0xa3
main.main()

No problem has been found in win7 environment for the time being. This problem has been found in 2012 server. It's not a startup error, it's other groutines that call programs with a desktop.

@zhaoya881010 zhaoya881010 changed the title win.GetMessage syscall.Syscall6 win.GetMessage syscall.Syscall6 crash Sep 9, 2020
@zhaoya881010
Copy link
Author

@zhaoya881010 zhaoya881010 commented Sep 9, 2020

goroutine 54 [syscall, locked to thread]:
syscall.Syscall(0x77689050, 0x2, 0x92c, 0xffffffff, 0x0, 0x0, 0x0, 0x0)
C:/go-build/Go/src/runtime/syscall_windows.go:172 +0xcf
syscall.WaitForSingleObject(0x92c, 0xffffffff, 0x0, 0x0, 0x0)
C:/go-build/Go/src/syscall/zsyscall_windows.go:737 +0x53
os.(*Process).wait(0x2e936930, 0x0, 0x0, 0x0)
C:/go-build/Go/src/os/exec_windows.go:18 +0x5a
os.(*Process).Wait(0x2e936930, 0x2e820600, 0x0, 0x0)
C:/go-build/Go/src/os/exec.go:125 +0x21
os/exec.(*Cmd).Wait(0x2ebc8210, 0xb6bea8, 0x0)
C:/go-build/Go/src/os/exec/exec.go:465 +0x43
GoProxy/utils/shell.RunCmdWithTimeout.func5(0x2ebc8210, 0x2e92605c, 0x2eb0e1c0, 0x2eba3d00, 0x2eb8a000, 0x24)
D:/gseeproxy/src/GoProxy/utils/shell/shell.go:204 +0x43
created by GoProxy/utils/shell.RunCmdWithTimeout
D:/gseeproxy/src/GoProxy/utils/shell/shell.go:198 +0x7f4
eax 0xffffffff
ebx 0x0
ecx 0x30
edx 0x0
edi 0x24
esi 0x1
ebp 0xffffffff
esp 0x0
eip 0x77e47594
eflags 0x0
cs 0x0
fs 0x14f63580
gs 0xbfd70d2f

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Sep 9, 2020

This kind of crash will happen if you pass bad arguments, such as invalid pointers, to the Windows system call. There's no particular reason to think that it is a problem with Go. Different versions of Windows act differently.

If you are convinced that this is a bug with Go, we'll need a way to reproduce the problem ourselves.

@zhaoya881010
Copy link
Author

@zhaoya881010 zhaoya881010 commented Sep 10, 2020

@ianlancetaylor MSG is new i don't where invalid pointers?The problem has been hotly discussed. But it seems that the real reason has not been found, and I have this problem again.

https://github.com/lxn/walk/pull/493#issue-274104188
lxn/walk#483

type MSG struct { HWnd HWND Message uint32 WParam uintptr LParam uintptr Time uint32 Pt POINT }
` msg := (*win.MSG)(unsafe.Pointer(win.GlobalAlloc(0, unsafe.Sizeof(win.MSG{}))))
defer win.GlobalFree(win.HGLOBAL(unsafe.Pointer(msg)))

for fb.hWnd != 0 {
	switch win.GetMessage(msg, 0, 0, 0) {
	case 0:
		return int(msg.WParam)

	case -1:
		return -1
	}`
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Sep 10, 2020

The code you show isn't valid Go, but, more importantly, the MSG structure doesn't have the lPrivate field. Perhaps the structure is too small.

@zhaoya881010
Copy link
Author

@zhaoya881010 zhaoya881010 commented Sep 10, 2020

@ianlancetaylor I tried to add lprivate. The problem is still that this is not the cause.
winuser.h
`/*

  • Message structure
    */
    typedef struct tagMSG {
    HWND hwnd;
    UINT message;
    WPARAM wParam;
    LPARAM lParam;
    DWORD time;
    POINT pt;
    #ifdef _MAC
    DWORD lPrivate;
    #endif
    } MSG, *PMSG, NEAR *NPMSG, FAR *LPMSG;`
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Sep 10, 2020

In order to help you, we'll need a way to reproduce this problem ourselves.

@odeke-em odeke-em changed the title win.GetMessage syscall.Syscall6 crash syscall: win.GetMessage syscall.Syscall6 crash Sep 11, 2020
@odeke-em odeke-em added the OS-Windows label Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.