Created
December 5, 2018 17:42
-
-
Save kikuchy/5d54e0374e925ee87f62b11704984268 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ GOOS=windows GOARCH=386 go get -u github.com/Microsoft/go-winio | |
$ GOOS=windows GOARCH=386 go build main.go | |
# 失敗のパターンは3つあって、どうやらgoroutineの実行タイミングで変わってきているようです。 | |
# 各パターンでwineがUnhandled page faultのメッセージを出している箇所以降は、goroutineが不正終了してListenしたものが閉じられていないためだと思われます。 | |
# クライアント側が失敗するパターン | |
$ wine main.exe | |
0009:fixme:process:SetProcessPriorityBoost (0xffffffff,1): stub | |
0037:fixme:file:SetFileCompletionNotificationModes 0x98 3 - stub | |
2018/12/06 02:34:33 Dial Error | |
2018/12/06 02:34:33 Accept Error | |
2018/12/06 02:34:33 open \\.\pipe\winiotestpipe: File not found. | |
wine: Unhandled page fault on read access to 0x4286e2d1 at address 0x428a070a (thread 0029), starting debugger... | |
0029:err:seh:start_debugger Couldn't start debugger ("winedbg --auto 32 192") (1115) | |
Read the Wine Developers Guide on how to set up winedbg or another debugger | |
0029:err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x939b08b5 | |
wine client error:29: write: Bad file descriptor | |
# おそらくサーバ側が失敗するパターン | |
$ wine main.exe | |
0009:fixme:process:SetProcessPriorityBoost (0xffffffff,1): stub | |
0009:fixme:file:SetFileCompletionNotificationModes 0x88 3 - stub | |
2018/12/06 02:36:59 ListenPipe Error | |
2018/12/06 02:36:59 Dial Error | |
2018/12/06 02:36:59 Call not implemented. | |
wine: Unhandled page fault on read access to 0x42fa854c at address 0x42a1f70a (thread 002e), starting debugger... | |
002e:err:seh:start_debugger Couldn't start debugger ("winedbg --auto 33 184") (1115) | |
Read the Wine Developers Guide on how to set up winedbg or another debugger | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
002a:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
# 両方出るパターン | |
$ wine main.exe | |
0009:fixme:process:SetProcessPriorityBoost (0xffffffff,1): stub | |
0034:fixme:file:SetFileCompletionNotificationModes 0x88 3 - stub | |
2018/12/06 02:38:40 Dial Error | |
2018/12/06 02:38:40 Accept Error | |
2018/12/06 02:38:40 open \\.\pipe\winiotestpipe: File not found. | |
2018/12/06 02:38:40 Call not implemented. | |
0029:err:hid_report:process_hid_report Device reports coming in too fast, last report not read yet! | |
wine: Unhandled page fault on read access to 0x42ea92d1 at address 0x4291f70a (thread 0029), starting debugger... | |
0029:err:seh:start_debugger Couldn't start debugger ("winedbg --auto 32 52") (1115) | |
Read the Wine Developers Guide on how to set up winedbg or another debugger | |
0029:err:seh:raise_exception Unhandled exception code c0000005 flags 0 addr 0x939b08b5 | |
wine client error:29: write: Bad file descriptor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"github.com/Microsoft/go-winio" | |
"github.com/pkg/errors" | |
"log" | |
"net" | |
"time" | |
) | |
var testPipeName = `\\.\pipe\winiotestpipe` | |
func PipeServerProcess() { | |
l, err := winio.ListenPipe(testPipeName, nil) | |
if err != nil { | |
log.Println("ListenPipe Error") | |
log.Fatal(errors.WithStack(err)) | |
} | |
defer l.Close() | |
for { | |
c, err := l.Accept() | |
if err != nil { | |
log.Println("Accept Error") | |
log.Fatal(errors.WithStack(err)) | |
} | |
go func(c net.Conn) { | |
rw := bufio.NewReadWriter(bufio.NewReader(c), bufio.NewWriter(c)) | |
str, err := rw.ReadString('\n') | |
if err != nil { | |
log.Println("Read Error") | |
log.Fatal(errors.WithStack(err)) | |
} | |
log.Println(str) | |
c.Close() | |
}(c) | |
} | |
} | |
func main() { | |
go PipeServerProcess() | |
var d = time.Duration(100 * time.Millisecond) | |
p, err := winio.DialPipe(testPipeName, &d) | |
if err != nil { | |
log.Println("Dial Error") | |
log.Fatal(errors.WithStack(err)) | |
} | |
rw := bufio.NewReadWriter(bufio.NewReader(p), bufio.NewWriter(p)) | |
_, err = rw.WriteString("Hello from parent") | |
if err != nil { | |
log.Println("Write Error") | |
log.Fatal(errors.WithStack(err)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ go version | |
go version go1.11 darwin/amd64 | |
$ wine --version | |
wine-3.0.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
go-winioでのPipeの実装はこちらにあります。
https://github.com/Microsoft/go-winio/blob/master/pipe.go
DLLのコールなのであまり失敗する要素はないように思うのですが…
コンパイルと実行に使用しているmacOSは10.14(18A391)です。