Windows API issue with Nordic BLE
While integrating a 3rd party BLE device on Windows 10, I encountered a repeated crash after 3-4 minutes of data transmission. The device continues to work normally, but the app crashes. Based on the logs, it appears that the issue is coming from the CGO side. The crash also happens when the app's memory footprint reaches ~32.5MB.
Any help is appreciated.
Here's the source code
package main
import (
"encoding/hex"
"fmt"
"strings"
"time"
"tinygo.org/x/bluetooth"
)
var bleAdapter = bluetooth.DefaultAdapter
var startCmd = []byte{0x68, 0x68, 0x97, 0x03, 0x03, 0x01, 0x00, 0x01}
var stopCmd = []byte{0x68, 0x68, 0x97, 0x03, 0x03, 0x01, 0x00, 0x00}
func main() {
bleAdapter.Enable()
go bleSearch()
select {}
}
var dev *bluetooth.Device
var srvc bluetooth.DeviceService
var rxChar bluetooth.DeviceCharacteristic
var txChar bluetooth.DeviceCharacteristic
func bleSearch() {
ch := make(chan bluetooth.ScanResult, 1)
err := bleAdapter.Scan(func(adapter *bluetooth.Adapter, result bluetooth.ScanResult) {
if strings.Contains(result.LocalName(), "RF-BLE-") {
fmt.Println("found device:", result.Address.String(), result.RSSI, result.LocalName())
ch <- result
bleAdapter.StopScan()
}
})
if err != nil {
fmt.Println(err)
}
select {
case result := <-ch:
dev, err = bleAdapter.Connect(result.Address, bluetooth.ConnectionParams{})
if err != nil {
fmt.Println(err)
return
}
var srvcs []bluetooth.DeviceService
var chars []bluetooth.DeviceCharacteristic
srvcs, err = dev.DiscoverServices([]bluetooth.UUID{bluetooth.ServiceUUIDNordicUART})
if err != nil {
fmt.Println(err)
return
}
if len(srvcs) == 0 {
dev.Disconnect()
fmt.Println("cannot find UART service")
return
}
srvc = srvcs[0]
chars, err = srvc.DiscoverCharacteristics([]bluetooth.UUID{bluetooth.CharacteristicUUIDUARTRX})
if err != nil {
return
}
if len(chars) == 0 {
dev.Disconnect()
fmt.Println("cannot find RX characteristic")
return
}
rxChar = chars[0]
chars, err = srvc.DiscoverCharacteristics([]bluetooth.UUID{bluetooth.CharacteristicUUIDUARTTX})
if err != nil {
return
}
if len(chars) == 0 {
dev.Disconnect()
fmt.Println("cannot find TX characteristic")
return
}
txChar = chars[0]
err = txChar.EnableNotifications(func(data []byte) {
fmt.Printf("data from: %s \n", hex.EncodeToString(data))
})
if err != nil {
fmt.Println(err)
return
}
time.Sleep(1 * time.Second)
write(stopCmd)
time.Sleep(5 * time.Second)
write(startCmd)
}
}
func write(data []byte) {
_, err := rxChar.WriteWithoutResponse(data)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("data out: %s \n", hex.EncodeToString(data))
}
Here's the log
...
data received: 68689703840c000c200206208809a04704e085023e
data received: 68689703840c000c200206208809a04704e085023e
Exception 0xc0000005 0x8 0xc000090b70 0xc000090b70
PC=0xc000090b70
runtime: g 17: unknown pc 0xc000090b70
stack: frame={sp:0xc00005fde0, fp:0x0} stack=[0xc00005c000,0xc000060000)
0x000000c00005fce0: 0x0000000000465a85 <runtime.racefuncexit+0x0000000000000005> 0x00000000004fba3f <github.com/saltosystems/winrt-go.(*RefCount).Release.func1+0x000000000000003f>
0x000000c00005fcf0: 0x000000c00008b0e0 0x000000c00008b0e0
0x000000c00005fd00: 0x000000c00005fd40 0x0000000000435e33 <runtime.deferreturn+0x0000000000000033>
0x000000c00005fd10: 0x000000c00005fd68 0x00000000004fb801 <github.com/saltosystems/winrt-go.(*RefCount).AddRef.func1+0x0000000000000001>
0x000000c00005fd20: 0x000000c000042340 0x000000c00005fdb8
0x000000c00005fd30: 0x0000000000447a95 <runtime.raceacquireg+0x0000000000000075> 0x000000000052a7a0
0x000000c00005fd40: 0x0000000001d20008 0x000000c00005a010
0x000000c00005fd50: 0x0000000000000000 0x0000000000000000
0x000000c00005fd60: 0x0000000000000000 0x000000c00005fd90
0x000000c00005fd70: 0x0000000000407e85 <runtime.checkptrBase+0x0000000000000045> 0x00000000004fb8f8 <github.com/saltosystems/winrt-go.(*RefCount).Release+0x0000000000000078>
0x000000c00005fd80: 0x0000000000000000 0x0000000000000000
0x000000c00005fd90: 0x000000c00005fdb8 0x0000000000407cfd <runtime.checkptrStraddles+0x000000000000005d>
0x000000c00005fda0: 0x0000000001a481ff 0x0000000000000000
0x000000c00005fdb0: 0x0000000001a481ff 0x000000c00005fdd8
0x000000c00005fdc0: 0x0000000000407c2d <runtime.checkptrAlignment+0x000000000000004d> 0x0000000000465a57 <runtime.racefuncenter+0x0000000000000017>
0x000000c00005fdd0: 0x00000000004047ef <runtime.cgocallbackg1+0x00000000000002cf> 0x000000c00005fe20
0x000000c00005fde0: <0x00000000004fe458 <_cgoexp_eec08437a0e4_winrt_TypedEventHandler_Invoke+0x00000000000000b8> 0x0000000000447a95 <runtime.raceacquireg+0x0000000000000075>
0x000000c00005fdf0: 0x000000000052a7a0 0x0000000001d20008
0x000000c00005fe00: 0x0000000000191740 0x0000000001a481e0
0x000000c00005fe10: 0x00000000001aa6a0 0x000000000070b338
0x000000c00005fe20: 0x000000c00005fef0 0x00000000004047ef <runtime.cgocallbackg1+0x00000000000002cf>
0x000000c00005fe30: 0x0000000028effae0 0x0000000000000000
0x000000c00005fe40: 0x0000000000000000 0x0000000000000000
0x000000c00005fe50: 0x0000000000000000 0x0000000000000000
0x000000c00005fe60: 0x0000000000000000 0x000000c00005feb0
0x000000c00005fe70: 0x0505010000441871 0x000000c00005fe90
0x000000c00005fe80: 0x0100000000000000 0x00000000004fe3a0 <_cgoexp_eec08437a0e4_winrt_TypedEventHandler_Invoke+0x0000000000000000>
0x000000c00005fe90: 0x0000000000441920 <runtime.exitsyscallfast.func1+0x0000000000000000> 0x000000c00005fe87
0x000000c00005fea0: 0x000000c000042340 0x0000000028effae0
0x000000c00005feb0: 0x00000000004048c0 <runtime.cgocallbackg1.func3+0x0000000000000000> 0x000000c00005fe75
0x000000c00005fec0: 0x000000c000042340 0x0000000200000003
0x000000c00005fed0: 0x000000c000042340 0x000000c00005feb0
runtime: g 17: unknown pc 0xc000090b70
stack: frame={sp:0xc00005fde0, fp:0x0} stack=[0xc00005c000,0xc000060000)
0x000000c00005fce0: 0x0000000000465a85 <runtime.racefuncexit+0x0000000000000005> 0x00000000004fba3f <github.com/saltosystems/winrt-go.(*RefCount).Release.func1+0x000000000000003f>
0x000000c00005fcf0: 0x000000c00008b0e0 0x000000c00008b0e0
0x000000c00005fd00: 0x000000c00005fd40 0x0000000000435e33 <runtime.deferreturn+0x0000000000000033>
0x000000c00005fd10: 0x000000c00005fd68 0x00000000004fb801 <github.com/saltosystems/winrt-go.(*RefCount).AddRef.func1+0x0000000000000001>
0x000000c00005fd20: 0x000000c000042340 0x000000c00005fdb8
0x000000c00005fd30: 0x0000000000447a95 <runtime.raceacquireg+0x0000000000000075> 0x000000000052a7a0
0x000000c00005fd40: 0x0000000001d20008 0x000000c00005a010
0x000000c00005fd50: 0x0000000000000000 0x0000000000000000
0x000000c00005fd60: 0x0000000000000000 0x000000c00005fd90
0x000000c00005fd70: 0x0000000000407e85 <runtime.checkptrBase+0x0000000000000045> 0x00000000004fb8f8 <github.com/saltosystems/winrt-go.(*RefCount).Release+0x0000000000000078>
0x000000c00005fd80: 0x0000000000000000 0x0000000000000000
0x000000c00005fd90: 0x000000c00005fdb8 0x0000000000407cfd <runtime.checkptrStraddles+0x000000000000005d>
0x000000c00005fda0: 0x0000000001a481ff 0x0000000000000000
0x000000c00005fdb0: 0x0000000001a481ff 0x000000c00005fdd8
0x000000c00005fdc0: 0x0000000000407c2d <runtime.checkptrAlignment+0x000000000000004d> 0x0000000000465a57 <runtime.racefuncenter+0x0000000000000017>
0x000000c00005fdd0: 0x00000000004047ef <runtime.cgocallbackg1+0x00000000000002cf> 0x000000c00005fe20
0x000000c00005fde0: <0x00000000004fe458 <_cgoexp_eec08437a0e4_winrt_TypedEventHandler_Invoke+0x00000000000000b8> 0x0000000000447a95 <runtime.raceacquireg+0x0000000000000075>
0x000000c00005fdf0: 0x000000000052a7a0 0x0000000001d20008
0x000000c00005fe00: 0x0000000000191740 0x0000000001a481e0
0x000000c00005fe10: 0x00000000001aa6a0 0x000000000070b338
0x000000c00005fe20: 0x000000c00005fef0 0x00000000004047ef <runtime.cgocallbackg1+0x00000000000002cf>
0x000000c00005fe30: 0x0000000028effae0 0x0000000000000000
0x000000c00005fe40: 0x0000000000000000 0x0000000000000000
0x000000c00005fe50: 0x0000000000000000 0x0000000000000000
0x000000c00005fe60: 0x0000000000000000 0x000000c00005feb0
0x000000c00005fe70: 0x0505010000441871 0x000000c00005fe90
0x000000c00005fe80: 0x0100000000000000 0x00000000004fe3a0 <_cgoexp_eec08437a0e4_winrt_TypedEventHandler_Invoke+0x0000000000000000>
0x000000c00005fe90: 0x0000000000441920 <runtime.exitsyscallfast.func1+0x0000000000000000> 0x000000c00005fe87
0x000000c00005fea0: 0x000000c000042340 0x0000000028effae0
0x000000c00005feb0: 0x00000000004048c0 <runtime.cgocallbackg1.func3+0x0000000000000000> 0x000000c00005fe75
0x000000c00005fec0: 0x000000c000042340 0x0000000200000003
0x000000c00005fed0: 0x000000c000042340 0x000000c00005feb0
goroutine 1 [select (no cases)]:
runtime.gopark(0x441f00?, 0x5ace08?, 0x0?, 0x20?, 0x512c45?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000063f38 sp=0xc000063f18 pc=0x439d16
runtime.block()
C:/Users/miklaine/go/go1.19/src/runtime/select.go:104 +0x2c fp=0xc000063f68 sp=0xc000063f38 pc=0x448aac
main.main()
C:/Users/miklaine/.../ble-test/main.go:22 +0x4a fp=0xc000063f80 sp=0xc000063f68 pc=0x512c4a
runtime.main()
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:250 +0x1fe fp=0xc000063fe0 sp=0xc000063f80 pc=0x43997e
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000063fe8 sp=0xc000063fe0 pc=0x462fc1
goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000045fb0 sp=0xc000045f90 pc=0x439d16
runtime.goparkunlock(...)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:369
runtime.forcegchelper()
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:302 +0xb1 fp=0xc000045fe0 sp=0xc000045fb0 pc=0x439bb1
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000045fe8 sp=0xc000045fe0 pc=0x462fc1
created by runtime.init.6
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:290 +0x25
goroutine 3 [GC sweep wait]:
runtime.gopark(0x1?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000047f90 sp=0xc000047f70 pc=0x439d16
runtime.goparkunlock(...)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/mgcsweep.go:297 +0xd7 fp=0xc000047fc8 sp=0xc000047f90 pc=0x424897
runtime.gcenable.func1()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:178 +0x26 fp=0xc000047fe0 sp=0xc000047fc8 pc=0x419606
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000047fe8 sp=0xc000047fe0 pc=0x462fc1
created by runtime.gcenable
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:178 +0x6b
goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc00001c070?, 0x623660?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000057f70 sp=0xc000057f50 pc=0x439d16
runtime.goparkunlock(...)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x6b74c0)
C:/Users/miklaine/go/go1.19/src/runtime/mgcscavenge.go:389 +0x53 fp=0xc000057fa0 sp=0xc000057f70 pc=0x4228f3
runtime.bgscavenge(0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/mgcscavenge.go:622 +0x65 fp=0xc000057fc8 sp=0xc000057fa0 pc=0x422ee5
runtime.gcenable.func2()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:179 +0x26 fp=0xc000057fe0 sp=0xc000057fc8 pc=0x4195a6
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000057fe8 sp=0xc000057fe0 pc=0x462fc1
created by runtime.gcenable
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:179 +0xaa
goroutine 5 [finalizer wait]:
runtime.gopark(0xc000042d00?, 0x0?, 0x0?, 0x64?, 0xc000049f70?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000049e28 sp=0xc000049e08 pc=0x439d16
runtime.goparkunlock(...)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:369
runtime.runfinq()
C:/Users/miklaine/go/go1.19/src/runtime/mfinal.go:180 +0x14f fp=0xc000049fe0 sp=0xc000049e28 pc=0x41870f
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000049fe8 sp=0xc000049fe0 pc=0x462fc1
created by runtime.createfing
C:/Users/miklaine/go/go1.19/src/runtime/mfinal.go:157 +0x45
goroutine 19 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000053f50 sp=0xc000053f30 pc=0x439d16
runtime.gcBgMarkWorker()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1235 +0xf1 fp=0xc000053fe0 sp=0xc000053f50 pc=0x41b611
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000053fe8 sp=0xc000053fe0 pc=0x462fc1
created by runtime.gcBgMarkStartWorkers
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1159 +0x25
goroutine 7 [GC worker (idle)]:
runtime.gopark(0x0?, 0xc00004bfe0?, 0x40?, 0x23?, 0xc00004c000?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc00004bf50 sp=0xc00004bf30 pc=0x439d16
runtime.gcBgMarkWorker()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1235 +0xf1 fp=0xc00004bfe0 sp=0xc00004bf50 pc=0x41b611
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00004bfe8 sp=0xc00004bfe0 pc=0x462fc1
created by runtime.gcBgMarkStartWorkers
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1159 +0x25
goroutine 8 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000497f50 sp=0xc000497f30 pc=0x439d16
runtime.gcBgMarkWorker()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1235 +0xf1 fp=0xc000497fe0 sp=0xc000497f50 pc=0x41b611
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000497fe8 sp=0xc000497fe0 pc=0x462fc1
created by runtime.gcBgMarkStartWorkers
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1159 +0x25
goroutine 9 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000499f50 sp=0xc000499f30 pc=0x439d16
runtime.gcBgMarkWorker()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1235 +0xf1 fp=0xc000499fe0 sp=0xc000499f50 pc=0x41b611
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000499fe8 sp=0xc000499fe0 pc=0x462fc1
created by runtime.gcBgMarkStartWorkers
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1159 +0x25
goroutine 20 [GC worker (idle)]:
runtime.gopark(0x13eb185494c80?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000055f50 sp=0xc000055f30 pc=0x439d16
runtime.gcBgMarkWorker()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1235 +0xf1 fp=0xc000055fe0 sp=0xc000055f50 pc=0x41b611
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000055fe8 sp=0xc000055fe0 pc=0x462fc1
created by runtime.gcBgMarkStartWorkers
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1159 +0x25
goroutine 10 [GC worker (idle)]:
runtime.gopark(0x13eb185494c80?, 0x3?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000493f50 sp=0xc000493f30 pc=0x439d16
runtime.gcBgMarkWorker()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1235 +0xf1 fp=0xc000493fe0 sp=0xc000493f50 pc=0x41b611
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000493fe8 sp=0xc000493fe0 pc=0x462fc1
created by runtime.gcBgMarkStartWorkers
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1159 +0x25
goroutine 11 [GC worker (idle)]:
runtime.gopark(0x13eb185494c80?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc000495f50 sp=0xc000495f30 pc=0x439d16
runtime.gcBgMarkWorker()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1235 +0xf1 fp=0xc000495fe0 sp=0xc000495f50 pc=0x41b611
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000495fe8 sp=0xc000495fe0 pc=0x462fc1
created by runtime.gcBgMarkStartWorkers
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1159 +0x25
goroutine 12 [GC worker (idle)]:
runtime.gopark(0x13eb185494c80?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Users/miklaine/go/go1.19/src/runtime/proc.go:363 +0xd6 fp=0xc0004a1f50 sp=0xc0004a1f30 pc=0x439d16
runtime.gcBgMarkWorker()
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1235 +0xf1 fp=0xc0004a1fe0 sp=0xc0004a1f50 pc=0x41b611
runtime.goexit()
C:/Users/miklaine/go/go1.19/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0004a1fe8 sp=0xc0004a1fe0 pc=0x462fc1
created by runtime.gcBgMarkStartWorkers
C:/Users/miklaine/go/go1.19/src/runtime/mgc.go:1159 +0x25
rax 0x1a481e0
rbx 0x191740
rcx 0x1aa6a0
rdi 0x6b5040
rsi 0xc000090b70
rbp 0xc00005fe20
rsp 0xc00005fde0
r8 0x4fe43d
r9 0x70b338
r10 0xc0000421a0
r11 0x4047ef
r12 0xc00005fdc0
r13 0xc00004c000
r14 0xc000042340
r15 0x0
rip 0xc000090b70
rflags 0x10206
cs 0x33
fs 0x53
gs 0x2b
Experiencing the same on Windows 10 22H2 (19045.2486) with similar usage. It seems to be happening after a certain amount of data is transmitted. Also sometimes I don't get a crash, it just stops receiving data.
Similar problem here. My program kept crashing after starting sending data
Same is for me. My app connects to 2 Switchbots, subscribes to notifications and writes to each device at least once per 2 minutes (to keep connection alive). Crashes after 2-7 minutes without panicing, like ExitProcess is called inside WinRT, it only prints "Process xxx has exited with status 0xc0000005".
But sometimes the app doesn't crash, it stops receiving notifications instead. And if I don't enable notifications at all it just works fine (a poor way out though).
I also have problems with my app crashing on windows after receiving data for a few seconds, i don't get a stack trace however, just exit status 0xc0000005 (Access Violation)
Have you checked whether the latest release of the bluetooth package fixes this issue? It may have been fixed in https://github.com/tinygo-org/bluetooth/pull/208.
It's not fixed by #208
for test i'm using GOOS=windows GOARCH=amd64 tinygo.org/x/bluetooth v0.8.1-0.20240221113924-0087e0549b0b (dev branch today) github.com/saltosystems/winrt-go v0.0.0-20240110120258-ad49e9790c38
if i set GOGC="off" (turning of garbage collector) then it stops crashing
if i set GOGC="off" (turning of garbage collector) then it stops crashing
That's very useful information! Sounds like it might be a finalizer that incorrectly frees some memory. @jagobagascon any idea what might be wrong here?
@aykevl I think we are mixing different problems here. Setting GOGC="off" does not help with the error we are seeing in 32 bit windows (at least for me). I still get the exit status 0xc0000005.
This issue was originally opened for an issue we fixed about a year ago:
- https://github.com/saltosystems/winrt-go/issues/63
- https://github.com/saltosystems/winrt-go/pull/64
I our case the exception seems to be happening on a Windows DLL 😕 => https://github.com/saltosystems/winrt-go/issues/83
@aykevl I think we are mixing different problems here. Setting
GOGC="off"does not help with the error we are seeing in 32 bit windows (at least for me). I still get theexit status 0xc0000005.This issue was originally opened for an issue we fixed about a year ago:
- fatal error: unexpected signal during runtime execution saltosystems/winrt-go#63
- codegen: remove go pointers from structs allocated in the heap saltosystems/winrt-go#64
I our case the exception seems to be happening on a Windows DLL 😕 => saltosystems/winrt-go#83
I have separate issues, the 32bit issue i am talking to you in https://github.com/saltosystems/winrt-go/issues/83 about is a separate thing. It's still crashing no matter GC or not when i build it 32bit
What i described in here I am hitting when compiling with GOARCH=amd64
if i build with 64bit and run with GOGC=off then the 64 bit program runs fine and i can talk to the device back and fourth without problems. but as soon as i turn on GC again it crashes after receiving data for a a few second