-
Notifications
You must be signed in to change notification settings - Fork 15
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
Panic when trying to build 32-bit binary #83
Comments
The `NewCallback` function expects the received argument to be a function with one uintptr-sized result. That uintptr type may be a 32 or 64 bit pointer depending on the system, but some functions were always returning a uint64 value. That was causing errors in 32 bit systems. fixes #83
It looks like the syscall callbacks need to return a uintptr-sized result, but we are returning a uint64 which messes with 32 bit systems. Thanks for the report! I was able to reproduce the problem, and I think this branch ( |
Thank you for the fast response! It compiles now but my very simple test program using tinygo.org/x/bluetooth crashes after first scan result. Not sure if it's now a issue for this repo or tinygo.org/x/bluetooth Im on Windows 11 23H2 22631.3155, Go 1.22 and using tdm-gcc as C compiler if that helps goarch=386
goarch=amd64
package main
import (
"log"
"time"
"tinygo.org/x/bluetooth"
)
var adapter = bluetooth.DefaultAdapter
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
func main() {
must("enable BLE stack", adapter.Enable())
ch := make(chan bluetooth.ScanResult, 1)
start := time.Now()
println("scanning...")
err := adapter.Scan(func(adapter *bluetooth.Adapter, device bluetooth.ScanResult) {
log.Printf("found device: %s, %d, %s", device.Address.String(), device.RSSI, device.LocalName())
if time.Since(start) > 10*time.Second {
adapter.StopScan()
}
if device.LocalName() == "OBDX Pro GT" {
adapter.StopScan()
ch <- device
}
})
must("start scan", err)
var device bluetooth.Device
select {
case d := <-ch:
device, err = adapter.Connect(d.Address, bluetooth.ConnectionParams{})
if err != nil {
log.Fatal("failed to connect:", err)
}
log.Printf("connected to %s", d.Address.String())
case <-time.After(10 * time.Second):
log.Fatal("Did not find any OBDX Pro GT device")
}
device.Disconnect()
}
func must(action string, err error) {
if err != nil {
log.Fatal("failed to " + action + ": " + err.Error())
}
} |
I get the same result so we may be missing something. After the first scanned device the program closes with |
I tried debugging the generated binary using WinDbg and I think this is the stack when the error happens:
Which is crazy because I'm just scanning devices, I'm not connecting nor reading any characteristic. But the errors happens in a At this point I think someone should try this on a 32 bit machine. There's too many layers of abstraction that could cause issues (a 32 bit binary running on a Windows ARM virtual machine running in parallels on a ARM MacOS). |
According to the syscall.NewCallback docs all the callbacks should return an uintptr sized result. But we were previously using uint64 which only works for 64 bit systems. This change should allow using winrt-go on 32 bit windows devices. fixes #83
Panic when trying to build 32-bit binary
go version go1.22.0 windows/amd64
The text was updated successfully, but these errors were encountered: