Skip to content

[macOS, BLE]: ^C sometimes causes hang #109

@ccollins476ad

Description

@ccollins476ad
  1. In macOS, use one of the BLE transports (ble or oic_ble).
  2. Send a command to a device, e.g.,
newtmgr --conntype ble --connstring peer_name=cc image list
  1. After newtmgr connects to the device, but before it receives the newtmgr response, hit ctrl-C.

Sometimes, the above sequence causes newtmgr to hang. The only way to recover (that I have found) is kill -9.

Here is a Go stack dump which captures the issue:

^C*** goroutine dump
goroutine 18 [running]:
mynewt.apache.org/newtmgr/vendor/mynewt.apache.org/newt/util.PrintStacks()
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/vendor/mynewt.apache.org/newt/util/util.go:666 +0x77
main.main.func1(0xc4200903c0)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/newtmgr.go:106 +0x91
created by main.main
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/newtmgr.go:95 +0x105

goroutine 1 [select (no cases)]:
mynewt.apache.org/newtmgr/newtmgr/cli.NmExit(0x1)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/cli/usage.go:50 +0x66
mynewt.apache.org/newtmgr/newtmgr/cli.nmUsage(0x0, 0x4721600, 0xc42016e240)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/cli/usage.go:78 +0x47
mynewt.apache.org/newtmgr/newtmgr/cli.imageStateListCmd(0xc4201bd200, 0xc4201603c0, 0x0, 0x4)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/cli/image.go:100 +0x214
mynewt.apache.org/newtmgr/vendor/github.com/spf13/cobra.(*Command).execute(0xc4201bd200, 0xc420160300, 0x4, 0x4, 0xc4201bd200, 0xc420160300)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/vendor/github.com/spf13/cobra/command.go:654 +0x2a2
mynewt.apache.org/newtmgr/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc4201bc000, 0xc4201bc480, 0xc4201bc240, 0xc420168050)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/vendor/github.com/spf13/cobra/command.go:729 +0x2d4
mynewt.apache.org/newtmgr/vendor/github.com/spf13/cobra.(*Command).Execute(0xc4201bc000, 0x46de138, 0xc4200903c0)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/vendor/github.com/spf13/cobra/command.go:688 +0x2b
main.main()
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/newtmgr.go:111 +0x10f

goroutine 5 [syscall]:
os/signal.signal_recv(0x47242e0)
        /usr/local/Cellar/go/1.10.3/libexec/src/runtime/sigqueue.go:139 +0xa7
os/signal.loop()
        /usr/local/Cellar/go/1.10.3/libexec/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.0
        /usr/local/Cellar/go/1.10.3/libexec/src/os/signal/signal_unix.go:28 +0x41

goroutine 7 [select, locked to thread]:
runtime.gopark(0x46e0308, 0x0, 0x46b8dde, 0x6, 0x18, 0x1)
        /usr/local/Cellar/go/1.10.3/libexec/src/runtime/proc.go:291 +0x11a
runtime.selectgo(0xc420052750, 0xc4200921e0)
        /usr/local/Cellar/go/1.10.3/libexec/src/runtime/select.go:392 +0xe50
runtime.ensureSigM.func1()
        /usr/local/Cellar/go/1.10.3/libexec/src/runtime/signal_unix.go:549 +0x1c6
runtime.goexit()
        /usr/local/Cellar/go/1.10.3/libexec/src/runtime/asm_amd64.s:2361 +0x1

goroutine 52 [chan receive]:
mynewt.apache.org/newtmgr/vendor/github.com/go-ble/ble/darwin.(*conn).sendReq(0xc420264000, 0x20, 0xc42024c720, 0x13, 0xc42028e2c8, 0x3)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/vendor/github.com/go-ble/ble/darwin/conn.go:137 +0x88
mynewt.apache.org/newtmgr/vendor/github.com/go-ble/ble/darwin.(*Client).CancelConnection(0xc42015a360, 0x472aaa0, 0xc42015a360)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/vendor/github.com/go-ble/ble/darwin/client.go:311 +0xe2
mynewt.apache.org/newtmgr/newtmgr/bll.(*BllSesn).txCancelConnection(0xc4200c20c0, 0xc42017f001, 0xc420167350)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/bll/bll_sesn.go:159 +0x62
mynewt.apache.org/newtmgr/newtmgr/bll.(*BllSesn).Close(0xc4200c20c0, 0xc4200c20c0, 0x0)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/bll/bll_sesn.go:354 +0x46
main.closeSesn()
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/newtmgr.go:60 +0x49
main.cleanup()
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/newtmgr.go:70 +0x39
mynewt.apache.org/newtmgr/newtmgr/cli.NmExit(0x1)
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/cli/usage.go:54 +0x5f
main.main.func1.1()
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/newtmgr.go:102 +0x31
created by main.main.func1
        /Users/ccollins/go/src/mynewt.apache.org/newtmgr/newtmgr/newtmgr.go:100 +0xb2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions