gobot icon indicating copy to clipboard operation
gobot copied to clipboard

Gobot Bebop: Fatal Error Concurrent Map Writes

Open mccurdyc opened this issue 8 years ago • 6 comments

When trying to use the API and Bebop libraries, I get the following issue. Before trying this, I was just using http handler functions and received the same issue. I have also posted a minimal example. The commands DO work. I am able to takeoff and land, then the program crashes.

2017/03/29 14:50:17 Initializing API on :3000...
2017/03/29 14:50:17 Initializing connections...
2017/03/29 14:50:17 Initializing connection Bebop-361A1C107A69ECB7 ...
2017/03/29 14:50:17 Initializing devices...
2017/03/29 14:50:17 Initializing device Bebop-32188FCF05C4CB81 ...
2017/03/29 14:50:17 Robot drone initialized.
2017/03/29 14:50:17 Starting Robot drone ...
2017/03/29 14:50:17 Starting connections...
2017/03/29 14:50:17 Starting connection Bebop-361A1C107A69ECB7...
2017/03/29 14:50:17 WARNING: API using insecure connection. We recommend using an SSL certificate with Gobot.
2017/03/29 14:50:17 Starting devices...
2017/03/29 14:50:17 Starting device Bebop-32188FCF05C4CB81...
2017/03/29 14:50:17 Starting work...
fatal error: concurrent map writes

goroutine 11 [running]:
runtime.throw(0x7030e4, 0x15)
	/usr/lib/go/src/runtime/panic.go:596 +0x95 fp=0xc42003abf0 sp=0xc42003abd0
runtime.mapassign(0x6a99a0, 0xc420015590, 0xc42003acd9, 0xc4200b8af3)
	/usr/lib/go/src/runtime/hashmap.go:499 +0x667 fp=0xc42003ac90 sp=0xc42003abf0
gobot.io/x/gobot/platforms/parrot/bebop/client.networkFrameGenerator.func1(0xc42015a770, 0xc420150d02, 0x8)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/platforms/parrot/bebop/client/client.go:127 +0xd9 fp=0xc42003ad20 sp=0xc42003ac90
gobot.io/x/gobot/platforms/parrot/bebop/client.(*Bebop).createARStreamACK(0xc4200d6000, 0x1c7, 0x0, 0x0, 0x1, 0xc42014a00c, 0x1971, 0x9ff4, 0x1971)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/platforms/parrot/bebop/client/client.go:795 +0x703 fp=0xc42003ae18 sp=0xc42003ad20
gobot.io/x/gobot/platforms/parrot/bebop/client.(*Bebop).packetReceiver(0xc4200d6000, 0xc42014a000, 0x197d, 0xa000)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/platforms/parrot/bebop/client/client.go:546 +0x227 fp=0xc42003af30 sp=0xc42003ae18
gobot.io/x/gobot/platforms/parrot/bebop/client.(*Bebop).Connect.func2(0xc4200d6000)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/platforms/parrot/bebop/client/client.go:290 +0x19f fp=0xc42003afd8 sp=0xc42003af30
runtime.goexit()
	/usr/lib/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc42003afe0 sp=0xc42003afd8
created by gobot.io/x/gobot/platforms/parrot/bebop/client.(*Bebop).Connect
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/platforms/parrot/bebop/client/client.go:292 +0x322

goroutine 1 [chan receive]:
gobot.io/x/gobot.(*Master).Start(0xc420016380, 0x6fe265, 0x4)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/master.go:70 +0x118
main.main()
	/home/mccurdyc/allegheny/cs383s2017/cs383s2017-team1-lab6/main.go:47 +0x428

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
	/usr/lib/go/src/runtime/asm_amd64.s:2197 +0x1

goroutine 5 [syscall]:
os/signal.signal_recv(0x0)
	/usr/lib/go/src/runtime/sigqueue.go:116 +0x104
os/signal.loop()
	/usr/lib/go/src/os/signal/signal_unix.go:22 +0x22
created by os/signal.init.1
	/usr/lib/go/src/os/signal/signal_unix.go:28 +0x41

goroutine 6 [chan receive]:
gobot.io/x/gobot.NewEventer.func1(0xc4200b86a0)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/eventer.go:65 +0x6c
created by gobot.io/x/gobot.NewEventer
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/eventer.go:73 +0x154

goroutine 7 [chan receive]:
gobot.io/x/gobot.NewEventer.func1(0xc4200b86c0)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/eventer.go:65 +0x6c
created by gobot.io/x/gobot.NewEventer
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/eventer.go:73 +0x154

goroutine 8 [IO wait]:
net.runtime_pollWait(0x7fbda2695f00, 0x72, 0x0)
	/usr/lib/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc420110068, 0x72, 0x0, 0xc420232000)
	/usr/lib/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc420110068, 0xffffffffffffffff, 0x0)
	/usr/lib/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).accept(0xc420110000, 0x0, 0x831800, 0xc420232000)
	/usr/lib/go/src/net/fd_unix.go:430 +0x1e5
net.(*TCPListener).accept(0xc420112000, 0xc420228120, 0x6a32c0, 0xffffffffffffffff)
	/usr/lib/go/src/net/tcpsock_posix.go:136 +0x2e
net.(*TCPListener).AcceptTCP(0xc420112000, 0xc420034e38, 0xc420034e40, 0xc420034e30)
	/usr/lib/go/src/net/tcpsock.go:215 +0x49
net/http.tcpKeepAliveListener.Accept(0xc420112000, 0x70fc70, 0xc4202280a0, 0x8358c0, 0xc42010e120)
	/usr/lib/go/src/net/http/server.go:3044 +0x2f
net/http.(*Server).Serve(0xc42010a000, 0x835440, 0xc420112000, 0x0, 0x0)
	/usr/lib/go/src/net/http/server.go:2643 +0x228
net/http.(*Server).ListenAndServe(0xc42010a000, 0xc42010a000, 0xc420102010)
	/usr/lib/go/src/net/http/server.go:2585 +0xb0
net/http.ListenAndServe(0xc420102010, 0x5, 0x0, 0x0, 0x1, 0x6fe11d)
	/usr/lib/go/src/net/http/server.go:2787 +0x7f
gobot.io/x/gobot/api.NewAPI.func1.1(0xc420054070)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/api/api.go:45 +0x12c
created by gobot.io/x/gobot/api.NewAPI.func1
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/api/api.go:47 +0x178

goroutine 9 [chan receive]:
gobot.io/x/gobot.NewEventer.func1(0xc4200b8880)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/eventer.go:65 +0x6c
created by gobot.io/x/gobot.NewEventer
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/eventer.go:73 +0x154

goroutine 10 [runnable]:
syscall.Syscall(0x1, 0x3, 0xc420110480, 0x14, 0x14, 0x14, 0x0)
	/usr/lib/go/src/syscall/asm_linux_amd64.s:18 +0x5
syscall.write(0x3, 0xc420110480, 0x14, 0x40, 0x77, 0x0, 0x0)
	/usr/lib/go/src/syscall/zsyscall_linux_amd64.go:1064 +0x55
syscall.Write(0x3, 0xc420110480, 0x14, 0x40, 0x17, 0x3, 0x0)
	/usr/lib/go/src/syscall/syscall_unix.go:181 +0x49
net.(*netFD).Write(0xc420054230, 0xc420110480, 0x14, 0x40, 0x0, 0x0, 0x0)
	/usr/lib/go/src/net/fd_unix.go:332 +0x15e
net.(*conn).Write(0xc42000e090, 0xc420110480, 0x14, 0x40, 0x14, 0x0, 0x0)
	/usr/lib/go/src/net/net.go:193 +0x70
gobot.io/x/gobot/platforms/parrot/bebop/client.(*Bebop).Connect.func1(0xc4200d6000)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/platforms/parrot/bebop/client/client.go:274 +0x9c
created by gobot.io/x/gobot/platforms/parrot/bebop/client.(*Bebop).Connect
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/platforms/parrot/bebop/client/client.go:280 +0x2fd

goroutine 12 [sleep]:
time.Sleep(0x17d7840)
	/usr/lib/go/src/runtime/time.go:59 +0xf9
gobot.io/x/gobot/platforms/parrot/bebop/client.(*Bebop).Connect.func3(0xc4200d6000)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/platforms/parrot/bebop/client/client.go:303 +0xb4
created by gobot.io/x/gobot/platforms/parrot/bebop/client.(*Bebop).Connect
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/platforms/parrot/bebop/client/client.go:305 +0x347

goroutine 18 [chan receive]:
gobot.io/x/gobot.(*Robot).Start.func2(0xc420060480)
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/robot.go:166 +0x52
created by gobot.io/x/gobot.(*Robot).Start
	/home/mccurdyc/dev/gocode/src/gobot.io/x/gobot/robot.go:167 +0x291

goroutine 19 [select, locked to thread]:
runtime.gopark(0x7101c8, 0x0, 0x6fe84f, 0x6, 0x18, 0x2)
	/usr/lib/go/src/runtime/proc.go:271 +0x13a
runtime.selectgoImpl(0xc420039f50, 0x0, 0x18)
	/usr/lib/go/src/runtime/select.go:423 +0x1364
runtime.selectgo(0xc420039f50)
	/usr/lib/go/src/runtime/select.go:238 +0x1c
runtime.ensureSigM.func1()
	/usr/lib/go/src/runtime/signal_unix.go:434 +0x2dd
runtime.goexit()
	/usr/lib/go/src/runtime/asm_amd64.s:2197 +0x1

goroutine 50 [IO wait]:
net.runtime_pollWait(0x7fbda2695cc0, 0x72, 0x7)
	/usr/lib/go/src/runtime/netpoll.go:164 +0x59
net.(*pollDesc).wait(0xc42015ac38, 0x72, 0x8329c0, 0x82f538)
	/usr/lib/go/src/net/fd_poll_runtime.go:75 +0x38
net.(*pollDesc).waitRead(0xc42015ac38, 0xc4201b8000, 0x1000)
	/usr/lib/go/src/net/fd_poll_runtime.go:80 +0x34
net.(*netFD).Read(0xc42015abd0, 0xc4201b8000, 0x1000, 0x1000, 0x0, 0x8329c0, 0x82f538)
	/usr/lib/go/src/net/fd_unix.go:250 +0x1b7
net.(*conn).Read(0xc420112008, 0xc4201b8000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
	/usr/lib/go/src/net/net.go:181 +0x70
net/http.(*connReader).Read(0xc4200169c0, 0xc4201b8000, 0x1000, 0x1000, 0x0, 0xc4201c5bb0, 0x55d538)
	/usr/lib/go/src/net/http/server.go:754 +0x140
bufio.(*Reader).fill(0xc420106060)
	/usr/lib/go/src/bufio/bufio.go:97 +0x117
bufio.(*Reader).Peek(0xc420106060, 0x4, 0x0, 0x0, 0x0, 0x0, 0xc4201c5c10)
	/usr/lib/go/src/bufio/bufio.go:129 +0x67
net/http.(*conn).readRequest(0xc420084640, 0x835800, 0xc420016980, 0x0, 0x0, 0x0)
	/usr/lib/go/src/net/http/server.go:931 +0xe91
net/http.(*conn).serve(0xc420084640, 0x835800, 0xc420016980)
	/usr/lib/go/src/net/http/server.go:1763 +0x49a
created by net/http.(*Server).Serve
	/usr/lib/go/src/net/http/server.go:2668 +0x2ce
exit status 2
package main

import (
	"fmt"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/api"
	"gobot.io/x/gobot/platforms/parrot/bebop"
)

func main() {
	// bebop drone
	bebopAdaptor := bebop.NewAdaptor()
	drone := bebop.NewDriver(bebopAdaptor)

	// Starts the API server on default port 3000
	gbot := gobot.NewMaster()
	api.NewAPI(gbot).Start()

	// Accessible via http://localhost:3000/api/commands/say_hello
	gbot.AddCommand("say_hello", func(params map[string]interface{}) interface{} {
		return "Master says hello!"
	})

	d := gbot.AddRobot(gobot.NewRobot("drone",
		[]gobot.Connection{bebopAdaptor},
		[]gobot.Device{drone},
	))

	// Accessible via http://localhost:3000/robots/Eve/commands/say_hello
	d.AddCommand("say_hello", func(params map[string]interface{}) interface{} {
		return fmt.Sprintf("%v says hello!", d.Name)
	})

	d.AddCommand("takeoff", func(params map[string]interface{}) interface{} {
		drone.TakeOff()
		return 0
	})

	d.AddCommand("land", func(params map[string]interface{}) interface{} {
		drone.Land()
		return 0
	})
	gbot.Start()
}

mccurdyc avatar Mar 29 '17 19:03 mccurdyc

Here is information about my Go version: go version go1.8 linux/amd64 And system information: 4.9.11-1-ARCH x86_64 GNU/Linux Wireless chip: 04:00.0 Network controller: Intel Corporation Wireless 8260 (rev 3a)

Let me know if there is any additional information that would help you! Thank you in advance!

mccurdyc avatar Mar 29 '17 19:03 mccurdyc

It seems to run perfectly for about 10 seconds, then I repeatedly receive this same error.

mccurdyc avatar Mar 29 '17 19:03 mccurdyc

@mccurdyc After GopherCon would you be able to give my branch a try?

losinggeneration avatar Jul 15 '17 20:07 losinggeneration

@losinggeneration I would love to, but I don't have access to the drone anymore. It was a course I was taking in school.

mccurdyc avatar Jul 15 '17 21:07 mccurdyc

I talked with @deadprogram and he said he has some, it's just a matter of digging them out and trying it out.

losinggeneration avatar Jul 16 '17 04:07 losinggeneration

I'm having the same issue, also I'm not able to get the video when using Bebop 2, any idea?

matiasinsaurralde avatar Aug 31 '17 23:08 matiasinsaurralde