有人试过在开多个goroutine 调用dll吗?
单 goroutine 调用dll 处理数据是没问题的,如果开多个goroutine就不行 ;
一开始我把加载起来的 dll 和 proc 定义为 全局变量,多个goroutine 共同使用,会崩溃,以为会冲突;
然后又尝试在每个goroutine 中各自加载dll ,声明proc ,还是会崩溃;
网上说的三种调用 dll 的方法均尝试了,一样的。
这个 dll 文件内定义了一些全局字符串数组,还有宏,只读不写的,应该没事吧?
有大牛能解释是怎么回事吗?
```go
var dllParse, _ = syscall.LoadLibrary(DLL_RBSFILE)
var rHeader, _ = syscall.GetProcAddress(dllParse, "r_header")
var rChHeaders, _ = syscall.GetProcAddress(dllParse, "r_ch_headers")
var rChData, _ = syscall.GetProcAddress(dllParse, "r_ch_data")
```
```
PC=0x70769240
signal arrived during external code execution
syscall.Syscall6(0x6fbc3b27, 0x5, 0xfffc, 0xc0002cc000, 0x1424, 0x64, 0x7d0, 0x0, 0x0, 0x0, ...)
C:/Go/src/runtime/syscall_windows.go:197 +0xed
main.run(0xc000010560)
E:/Projects/cmsd/cmsd.go:464 +0x2090
created by main.(*Program).Run
E:/Projects/cmsd/cmsd.go:132 +0x7de
goroutine 1 [chan receive]:
github.com/kardianos/service.(*windowsService).Run(0xc000099410, 0x714ec0, 0x8a9500)
C:/Users/ANDY/go/pkg/mod/github.com/kardianos/service@v1.0.0/service_windows.go:280 +0x114
main.main()
E:/Projects/cmsd/cmsd.go:226 +0x1f3
goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
C:/Go/src/runtime/sigqueue.go:139 +0xa3
os/signal.loop()
C:/Go/src/os/signal/signal_unix.go:23 +0x29
created by os/signal.init.0
C:/Go/src/os/signal/signal_unix.go:29 +0x48
```
#1