Skip to content
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

fatal error: concurrent map read and map write when working with the daemon #414

Closed
kittaakos opened this issue Sep 18, 2019 · 2 comments · Fixed by #438
Closed

fatal error: concurrent map read and map write when working with the daemon #414

kittaakos opened this issue Sep 18, 2019 · 2 comments · Fixed by #438

Comments

@kittaakos
Copy link
Contributor

Bug Report

I do not know how this has happened.

arduino-cli daemon -v --log-level info --format json --log-format json
fatal error: concurrent map read and map write

goroutine 29 [running]:
runtime.throw(0x48440d1, 0x21)
        /usr/local/go/src/runtime/panic.go:617 +0x72 fp=0xc00014dca0 sp=0xc00014dc70 pc=0x402dba2
runtime.mapaccess1_faststr(0x47ee540, 0xc0000b5020, 0x4830cbf, 0xa, 0xc00014dd70)
        /usr/local/go/src/runtime/map_faststr.go:21 +0x469 fp=0xc00014dd10 sp=0xc00014dca0 pc=0x4014129
net/http.http2isConnectionCloseRequest(...)
        /usr/local/go/src/net/http/h2_bundle.go:8937
net/http.(*http2clientConnReadLoop).endStreamError(0xc00014dfb8, 0xc000d13b80, 0x492cc40, 0xc000080030)
        /usr/local/go/src/net/http/h2_bundle.go:8571 +0x11a fp=0xc00014dd80 sp=0xc00014dd10 pc=0x431f06a
net/http.(*http2clientConnReadLoop).endStream(...)
        /usr/local/go/src/net/http/h2_bundle.go:8562
net/http.(*http2clientConnReadLoop).processData(0xc00014dfb8, 0xc001d56360, 0xc001d56360, 0x0)
        /usr/local/go/src/net/http/h2_bundle.go:8552 +0x2b2 fp=0xc00014de38 sp=0xc00014dd80 pc=0x431ead2
net/http.(*http2clientConnReadLoop).run(0xc00014dfb8, 0x4863740, 0xc0002647b8)
        /usr/local/go/src/net/http/h2_bundle.go:8137 +0x5eb fp=0xc00014df70 sp=0xc00014de38 pc=0x431c72b
net/http.(*http2ClientConn).readLoop(0xc00009ec00)
        /usr/local/go/src/net/http/h2_bundle.go:8030 +0x76 fp=0xc00014dfd8 sp=0xc00014df70 pc=0x431ba86
runtime.goexit()
        /usr/local/go/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc00014dfe0 sp=0xc00014dfd8 pc=0x405a661
created by net/http.(*http2Transport).newClientConn
        /usr/local/go/src/net/http/h2_bundle.go:7093 +0x637

goroutine 1 [IO wait, 8 minutes]:
internal/poll.runtime_pollWait(0x50b3ea8, 0x72, 0x0)
        /usr/local/go/src/runtime/netpoll.go:182 +0x56
internal/poll.(*pollDesc).wait(0xc0001e4998, 0x72, 0x0, 0x0, 0x482d2fa)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x9b
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Accept(0xc0001e4980, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /usr/local/go/src/internal/poll/fd_unix.go:384 +0x1ba
net.(*netFD).accept(0xc0001e4980, 0xc000539401, 0x0, 0x0)
        /usr/local/go/src/net/fd_unix.go:238 +0x42
net.(*TCPListener).accept(0xc0000c25c0, 0xc0000dbb70, 0xc0000dbb78, 0x18)
        /usr/local/go/src/net/tcpsock_posix.go:139 +0x32
net.(*TCPListener).Accept(0xc0000c25c0, 0x4863118, 0xc0000c6180, 0x4945fe0, 0xc0005394c0)
        /usr/local/go/src/net/tcpsock.go:260 +0x48
google.golang.org/grpc.(*Server).Serve(0xc0000c6180, 0x493c0a0, 0xc0000c25c0, 0x0, 0x0)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:587 +0x1e9
github.com/arduino/arduino-cli/cli/daemon.runDaemonCommand(0xc00020b400, 0xc0001f4d20, 0x0, 0x7)
        /__w/arduino-cli/arduino-cli/cli/daemon/daemon.go:74 +0x44e
github.com/spf13/cobra.(*Command).execute(0xc00020b400, 0xc0001f4cb0, 0x7, 0x7, 0xc00020b400, 0xc0001f4cb0)
        /github/home/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:830 +0x2ae
github.com/spf13/cobra.(*Command).ExecuteC(0x4ea4300, 0x46973b1, 0xc0001fdf88, 0xc00003c0b8)
        /github/home/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:914 +0x2fc
github.com/spf13/cobra.(*Command).Execute(...)
        /github/home/go/pkg/mod/github.com/spf13/cobra@v0.0.5/command.go:864
main.main()
        /__w/arduino-cli/arduino-cli/main.go:28 +0x2e

goroutine 4 [syscall, 8 minutes]:
os/signal.signal_recv(0x0)
        /usr/local/go/src/runtime/sigqueue.go:139 +0x9f
os/signal.loop()
        /usr/local/go/src/os/signal/signal_unix.go:23 +0x22
created by os/signal.init.0
        /usr/local/go/src/os/signal/signal_unix.go:29 +0x41

goroutine 6 [select, 8 minutes]:
google.golang.org/grpc/internal/transport.(*controlBuffer).get(0xc0000c9bc0, 0x1, 0x0, 0x0, 0x0, 0x0)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/controlbuf.go:317 +0x104
google.golang.org/grpc/internal/transport.(*loopyWriter).run(0xc0000c4ba0, 0x0, 0x0)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/controlbuf.go:435 +0x1b6
google.golang.org/grpc/internal/transport.newHTTP2Server.func2(0xc0000c6780)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:276 +0xcb
created by google.golang.org/grpc/internal/transport.newHTTP2Server
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:273 +0xfba

goroutine 7 [select, 8 minutes]:
google.golang.org/grpc/internal/transport.(*http2Server).keepalive(0xc0000c6780)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:935 +0x1ed
created by google.golang.org/grpc/internal/transport.newHTTP2Server
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:282 +0xfdf

goroutine 8 [IO wait, 8 minutes]:
internal/poll.runtime_pollWait(0x50b3dd8, 0x72, 0xffffffffffffffff)
        /usr/local/go/src/runtime/netpoll.go:182 +0x56
internal/poll.(*pollDesc).wait(0xc0000ee698, 0x72, 0x8000, 0x8000, 0xffffffffffffffff)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x9b
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc0000ee680, 0xc00023a000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
        /usr/local/go/src/internal/poll/fd_unix.go:169 +0x1f2
net.(*netFD).Read(0xc0000ee680, 0xc00023a000, 0x8000, 0x8000, 0x0, 0x800010601, 0x0)
        /usr/local/go/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc000010118, 0xc00023a000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
        /usr/local/go/src/net/net.go:177 +0x69
bufio.(*Reader).Read(0xc0000c4b40, 0xc0001e21f8, 0x9, 0x9, 0xc09ba4f0e6, 0xc0004ce000, 0xc000078d88)
        /usr/local/go/src/bufio/bufio.go:223 +0x23e
io.ReadAtLeast(0x492c940, 0xc0000c4b40, 0xc0001e21f8, 0x9, 0x9, 0x9, 0xbf58aaa0dd81d540, 0x14c5588197, 0x4eb07c0)
        /usr/local/go/src/io/io.go:310 +0x88
io.ReadFull(...)
        /usr/local/go/src/io/io.go:329
golang.org/x/net/http2.readFrameHeader(0xc0001e21f8, 0x9, 0x9, 0x492c940, 0xc0000c4b40, 0x0, 0x0, 0xc0001d6640, 0x7070e0910100402)
        /github/home/go/pkg/mod/golang.org/x/net@v0.0.0-20190311183353-d8887717615a/http2/frame.go:237 +0x88
golang.org/x/net/http2.(*Framer).ReadFrame(0xc0001e21c0, 0xc000364d20, 0xc000364d20, 0x0, 0x0)
        /github/home/go/pkg/mod/golang.org/x/net@v0.0.0-20190311183353-d8887717615a/http2/frame.go:492 +0xa1
google.golang.org/grpc/internal/transport.(*http2Server).HandleStreams(0xc0000c6780, 0xc00017f410, 0x4863170)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:431 +0x7c
google.golang.org/grpc.(*Server).serveStreams(0xc0000c6180, 0x4946b20, 0xc0000c6780)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:713 +0xdd
google.golang.org/grpc.(*Server).handleRawConn.func1(0xc0000c6180, 0x4946b20, 0xc0000c6780)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:675 +0x43
created by google.golang.org/grpc.(*Server).handleRawConn
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:674 +0x580

goroutine 591 [IO wait]:
internal/poll.runtime_pollWait(0x50b3b68, 0x72, 0xffffffffffffffff)
        /usr/local/go/src/runtime/netpoll.go:182 +0x56
internal/poll.(*pollDesc).wait(0xc001232518, 0x72, 0x8000, 0x8000, 0xffffffffffffffff)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:87 +0x9b
internal/poll.(*pollDesc).waitRead(...)
        /usr/local/go/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc001232500, 0xc001c7c000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
        /usr/local/go/src/internal/poll/fd_unix.go:169 +0x1f2
net.(*netFD).Read(0xc001232500, 0xc001c7c000, 0x8000, 0x8000, 0x0, 0x800010601, 0x0)
        /usr/local/go/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc0005394c0, 0xc001c7c000, 0x8000, 0x8000, 0x0, 0x0, 0x0)
        /usr/local/go/src/net/net.go:177 +0x69
bufio.(*Reader).Read(0xc0015acf60, 0xc0003ac118, 0x9, 0x9, 0xc024639697, 0xc0004be000, 0xc00007bd88)
        /usr/local/go/src/bufio/bufio.go:223 +0x23e
io.ReadAtLeast(0x492c940, 0xc0015acf60, 0xc0003ac118, 0x9, 0x9, 0x9, 0xbf58ab054d587930, 0x724e281d98, 0x4eb07c0)
        /usr/local/go/src/io/io.go:310 +0x88
io.ReadFull(...)
        /usr/local/go/src/io/io.go:329
golang.org/x/net/http2.readFrameHeader(0xc0003ac118, 0x9, 0x9, 0x492c940, 0xc0015acf60, 0x0, 0x0, 0xc001c382d0, 0x7070e0910100402)
        /github/home/go/pkg/mod/golang.org/x/net@v0.0.0-20190311183353-d8887717615a/http2/frame.go:237 +0x88
golang.org/x/net/http2.(*Framer).ReadFrame(0xc0003ac0e0, 0xc003f45380, 0xc003f45380, 0x0, 0x0)
        /github/home/go/pkg/mod/golang.org/x/net@v0.0.0-20190311183353-d8887717615a/http2/frame.go:492 +0xa1
google.golang.org/grpc/internal/transport.(*http2Server).HandleStreams(0xc0004af980, 0xc001211890, 0x4863170)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:431 +0x7c
google.golang.org/grpc.(*Server).serveStreams(0xc0000c6180, 0x4946b20, 0xc0004af980)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:713 +0xdd
google.golang.org/grpc.(*Server).handleRawConn.func1(0xc0000c6180, 0x4946b20, 0xc0004af980)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:675 +0x43
created by google.golang.org/grpc.(*Server).handleRawConn
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:674 +0x580

goroutine 589 [select]:
google.golang.org/grpc/internal/transport.(*controlBuffer).get(0xc00115a800, 0x1, 0x0, 0x0, 0x0, 0x0)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/controlbuf.go:317 +0x104
google.golang.org/grpc/internal/transport.(*loopyWriter).run(0xc0015acfc0, 0x0, 0x0)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/controlbuf.go:435 +0x1b6
google.golang.org/grpc/internal/transport.newHTTP2Server.func2(0xc0004af980)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:276 +0xcb
created by google.golang.org/grpc/internal/transport.newHTTP2Server
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:273 +0xfba

goroutine 590 [select, 8 minutes]:
google.golang.org/grpc/internal/transport.(*http2Server).keepalive(0xc0004af980)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:935 +0x1ed
created by google.golang.org/grpc/internal/transport.newHTTP2Server
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/internal/transport/http2_server.go:282 +0xfdf

goroutine 2911 [select]:
net/http.(*http2ClientConn).roundTrip(0xc00009ec00, 0xc0001cda00, 0x0, 0x0, 0x0, 0x0)
        /usr/local/go/src/net/http/h2_bundle.go:7504 +0x8cc
net/http.(*http2Transport).RoundTripOpt(0xc0004dc240, 0xc0001cda00, 0xc0003eb100, 0x4327286, 0x0, 0xc0001ce7e0)
        /usr/local/go/src/net/http/h2_bundle.go:6867 +0x159
net/http.(*http2Transport).RoundTrip(...)
        /usr/local/go/src/net/http/h2_bundle.go:6829
net/http.http2noDialH2RoundTripper.RoundTrip(0xc0004dc240, 0xc0001cda00, 0xc001aeb6e0, 0x5, 0xc0001ce868)
        /usr/local/go/src/net/http/h2_bundle.go:8959 +0x3f
net/http.(*Transport).roundTrip(0x4ea37a0, 0xc0001cda00, 0x10, 0xc001f8ee60, 0xc0003eb480)
        /usr/local/go/src/net/http/transport.go:430 +0xe90
net/http.(*Transport).RoundTrip(0x4ea37a0, 0xc0001cda00, 0x4ea37a0, 0x0, 0x0)
        /usr/local/go/src/net/http/roundtrip.go:17 +0x35
net/http.send(0xc0001cda00, 0x492de20, 0x4ea37a0, 0x0, 0x0, 0x0, 0xc0000ca938, 0xc0003eb6a8, 0x1, 0x0)
        /usr/local/go/src/net/http/client.go:250 +0x461
net/http.(*Client).send(0x4eaf480, 0xc0001cda00, 0x0, 0x0, 0x0, 0xc0000ca938, 0x0, 0x1, 0xc00009c400)
        /usr/local/go/src/net/http/client.go:174 +0xfb
net/http.(*Client).do(0x4eaf480, 0xc0001cda00, 0x0, 0x0, 0x0)
        /usr/local/go/src/net/http/client.go:641 +0x279
net/http.(*Client).Do(...)
        /usr/local/go/src/net/http/client.go:509
github.com/arduino/arduino-cli/commands/board.apiByVidPid(0xc001aeb6e0, 0x2f, 0xc0003ebac0, 0x2, 0x2, 0xc001aeb6e0, 0x2f)
        /__w/arduino-cli/arduino-cli/commands/board/list.go:46 +0x1a3
github.com/arduino/arduino-cli/commands/board.List(0x2, 0x0, 0x0, 0x0, 0x0, 0x0)
        /__w/arduino-cli/arduino-cli/commands/board/list.go:116 +0x87f
github.com/arduino/arduino-cli/commands/daemon.(*ArduinoCoreServerImpl).BoardList(0xc0001c6e00, 0x493eaa0, 0xc003860720, 0xc003860750, 0xc0001c6e00, 0xc003860720, 0xc000372ba8)
        /__w/arduino-cli/arduino-cli/commands/daemon/daemon.go:52 +0x47
github.com/arduino/arduino-cli/rpc/commands._ArduinoCore_BoardList_Handler(0x480f300, 0xc0001c6e00, 0x493eaa0, 0xc003860720, 0xc001d5f9a0, 0x0, 0x493eaa0, 0xc003860720, 0xc002c2dfa0, 0x4)
        /__w/arduino-cli/arduino-cli/rpc/commands/commands.pb.go:1551 +0x23e
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000c6180, 0x4946b20, 0xc0004af980, 0xc005b3d700, 0xc000220750, 0x4ea3700, 0x0, 0x0, 0x0)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:998 +0x470
google.golang.org/grpc.(*Server).handleStream(0xc0000c6180, 0x4946b20, 0xc0004af980, 0xc005b3d700, 0x0)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:1278 +0xda6
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc000eea400, 0xc0000c6180, 0x4946b20, 0xc0004af980, 0xc005b3d700)
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:717 +0x9f
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /github/home/go/pkg/mod/google.golang.org/grpc@v1.21.1/server.go:715 +0xa1

    at ChildProcess.exithandler (child_process.js:299:12)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:962:16)
    at Socket.stream.socket.on (internal/child_process.js:381:11)
    at Socket.emit (events.js:182:13)
    at Pipe._handle.close (net.js:606:12)
  • CLI version (output of arduino-cli version):
    arduino-cli Version: 0.3.7-alpha.preview Commit: ac85e06
  • OS and platform:
    macOS 10.14.6 (18G87)

Additional context

@cmaglie
Copy link
Member

cmaglie commented Sep 27, 2019

There is a (more or less) reliable way to reproduce it?
I have some idea, but I'd like to test the fix too.

@kittaakos
Copy link
Contributor Author

reliable way to reproduce it?

I can give you the steps offline, @cmaglie. I do not have a self-contained way to reproduce it with the CLI only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants