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

Run example code failed in Win 10 #60

Open
navono opened this issue Jul 15, 2020 · 8 comments
Open

Run example code failed in Win 10 #60

navono opened this issue Jul 15, 2020 · 8 comments

Comments

@navono
Copy link

navono commented Jul 15, 2020

Env

Win 10 (1909)

Description

Build example module, and run, error:

2020/07/15 10:02:52 [overseer master] run
2020/07/15 10:02:53 [overseer] disabled. run failed: cannot move binary back ([cmd /c move /y C:\Users\ping\AppData\Local\Temp\overseer-8a21b19139fe1a2b.exe D:\sourcecode\go\overseer\exa
mple\my_app]: "\xc1\xedһ\xb8\xf6\xb3\xcc\xd0\xf2\xd5\xfd\xd4\xdaʹ\xd3ô\xcb\xceļ\xfe\xa3\xac\xbd\xf8\xb3\xcc\xce\u07b7\xa8\xb7\xc3\xceʡ\xa3\r\n\xd2ƶ\xaf\xc1\xcb         0 \xb8\xf6\xceļ\xf
e\xa1\xa3": exit status 1)
app#1 () listening...
panic: runtime error: invalid memory address or nil pointer dereference
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x28 pc=0x65cbd4]

goroutine 1 [running]:
net/http.(*onceCloseListener).close(...)
        C:/Go/src/net/http/server.go:3337
sync.(*Once).doSlow(0xc00010c070, 0xc0000779c8)
        C:/Go/src/sync/once.go:66 +0xf3
sync.(*Once).Do(...)
        C:/Go/src/sync/once.go:57
net/http.(*onceCloseListener).Close(0xc00010c060, 0x0, 0x0)
        C:/Go/src/net/http/server.go:3333 +0x7e
panic(0x6ba600, 0x957040)
        C:/Go/src/runtime/panic.go:967 +0x16b
net/http.(*onceCloseListener).Accept(0xc00010c060, 0xc0000100d0, 0x6b52c0, 0x956fc0, 0x701740)
        <autogenerated>:1 +0x39
net/http.(*Server).Serve(0xc00012c000, 0x0, 0x0, 0x0, 0x0)
        C:/Go/src/net/http/server.go:2901 +0x264
net/http.Serve(...)
        C:/Go/src/net/http/server.go:2468
main.prog(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        D:/sourcecode/go/overseer/example/main.go:26 +0x210
github.com/jpillora/overseer.Run(0x0, 0x729820, 0x70f548, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        D:/sourcecode/go/overseer/overseer.go:106 +0x14e
main.main()
        D:/sourcecode/go/overseer/example/main.go:34 +0x16d

then setup a breakpoint in

func move(dst, src string) error {
	os.MkdirAll(filepath.Dir(dst), 0755)
	if err := os.Rename(src, dst); err == nil {
		return nil
	}
	//HACK: we're shelling out to move because windows
	//throws errors when crossing device boundaries.
	// https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/move.mspx?mfr=true

	// https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/
	R := func(s string) string { return replShellMeta.Replace(syscall.EscapeArg(s)) }
	cmd := exec.Command("cmd", "/c", `move /y "`+R(src)+`" "`+R(dst)+`"`)
	if b, err := cmd.CombinedOutput(); err != nil {
		return fmt.Errorf("%v: %q: %v", cmd.Args, bytes.TrimSpace(b), err)
	}
	return nil
}

and get the cmd args:

move /y "C:\Users\ping\AppData\Local\Temp\___go_build_main_go.exe" "C:\Users\ping\AppData\Local\Temp\overseer-01c8d5338e1b2dde.exe"

run the command in separate CMD window:

D:\>move /y "C:\Users\ping\AppData\Local\Temp\___go_build_main_go.exe" "C:\Users\ping\AppData\Local\Temp\overseer-01c8d5338e1b2dde.exe"
另一个程序正在使用此文件,进程无法访问。
移动了         0 个文件。

mean: "This file is being used by another program and cannot be accessed by the process."

@jpillora
Copy link
Owner

Sorry @tgulacsi and @audiolion have sent PRs for windows though I haven't been able to test. Are you guys able to look into this?

@jpillora
Copy link
Owner

Oh now that I look at the filepaths, did you run with go run? or go build -o ... then run output?

@audiolion
Copy link
Contributor

Will look into this tomorrow morning (10 hours)

@xiaodingding
Copy link

这个问题解决了吗?
Has the problem been solved?

@jtdaad
Copy link

jtdaad commented Jan 18, 2022

Is there any update on this issue?

@jtdaad
Copy link

jtdaad commented Jan 20, 2022

Hi @audiolion I know this is fairly old, wondering if you were able to work on it? I can offer a tip for jumping on this quickly! I have a client who's application is using this library and getting failing builds on Windows. I'm anxious to find a solution without having to swap out other architecture, etc. Any help would be greatly appreciated! Thanks.

@lucky-CCC
Copy link

Hello, brother. Has the problem been solved? Could you share? I also have this problem at present. This is normal on MacOS, but it appears on Windows 10.

Hello, brother. Has the problem been solved? Could you share? I also have this problem at present.
This is normal on MacOS, but it appears on Windows 10.

@navono

@oliverpool
Copy link

I had this issue as well, hence I developed a package for zero-downtime server upgrade, which also works on windows: https://code.pfad.fr/risefront

Code currently hosted on codeberg: https://codeberg.org/pfad.fr/risefront

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants