Skip to content

sync: panic unlock mutex from sync.Once #16762

@cpuguy83

Description

@cpuguy83

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    1.5.4
  2. What operating system and processor architecture are you using (go env)?
    linux/amd64
  3. What did you do?
    Normal usage of Docker.
    Docker is (was) using a sync.Once in a function that handles DNS requests. Naturally this function can get called often and with a lot of concurrency depending on the user.
  4. What did you expect to see?
    sync.Once should never panic
  5. What did you see instead?
    During operation a user reported this panic:
Aug 17 15:14:26 docker-07 docker[27936]: panic: sync: unlock of unlocked mutex
Aug 17 15:14:26 docker-07 docker[27936]: goroutine 11703956 [running]:
Aug 17 15:14:26 docker-07 docker[27936]: sync.(*Mutex).Unlock(0xc82263da58)
Aug 17 15:14:26 docker-07 docker[27936]: /usr/local/go/src/sync/mutex.go:108 +0x9f
Aug 17 15:14:26 docker-07 docker[27936]: sync.(*Once).Do(0xc82263da58, 0xc8233e1d18)
Aug 17 15:14:26 docker-07 docker[27936]: /usr/local/go/src/sync/once.go:46 +0xe5
Aug 17 15:14:26 docker-07 docker[27936]: github.com/docker/libnetwork.(*resolver).ServeDNS(0xc82263da00, 0x7f65a87be938, 0xc82371afc0, 0xc82230ce10)
Aug 17 15:14:26 docker-07 docker[27936]: /root/rpmbuild/BUILD/docker-engine/vendor/src/github.com/docker/libnetwork/resolver.go:355 +0x812
Aug 17 15:14:26 docker-07 docker[27936]: github.com/miekg/dns.(*Server).serve(0xc820bd7520, 0x7f65b02bb988, 0xc821be9440, 0x7f65b0238948, 0xc82263da00, 0xc822
Aug 17 15:14:26 docker-07 docker[27936]: /root/rpmbuild/BUILD/docker-engine/vendor/src/github.com/miekg/dns/server.go:535 +0x7c1
Aug 17 15:14:26 docker-07 docker[27936]: created by github.com/miekg/dns.(*Server).serveUDP
Aug 17 15:14:26 docker-07 docker[27936]: /root/rpmbuild/BUILD/docker-engine/vendor/src/github.com/miekg/dns/server.go:489 +0x3d5
Aug 17 15:14:26 docker-07 docker[27936]: goroutine 1 [chan receive, 2996 minutes]:
Aug 17 15:14:26 docker-07 docker[27936]: main.(*DaemonCli).CmdDaemon(0xc8204258c0, 0xc82000a0c0, 0x8, 0x8, 0x0, 0x0)
Aug 17 15:14:26 docker-07 docker[27936]: /root/rpmbuild/BUILD/docker-engine/docker/daemon.go:337 +0x23e1
Aug 17 15:14:26 docker-07 docker[27936]: reflect.callMethod(0xc8204177a0, 0xc821703c78)
Aug 17 15:14:26 docker-07 docker[27936]: /usr/local/go/src/reflect/value.go:628 +0x1fc
Aug 17 15:14:26 docker-07 docker[27936]: reflect.methodValueCall(0xc82000a0c0, 0x8, 0x8, 0x1, 0xc8204177a0, 0x0, 0x0, 0xc8204177a0, 0x0, 0x47ccb4, ...)
Aug 17 15:14:26 docker-07 docker[27936]: /usr/local/go/src/reflect/asm_amd64.s:29 +0x36
Aug 17 15:14:26 docker-07 docker[27936]: github.com/docker/docker/cli.(*Cli).Run(0xc820417710, 0xc82000a0b0, 0x9, 0x9, 0x0, 0x0)
Aug 17 15:14:26 docker-07 docker[27936]: /root/rpmbuild/BUILD/docker-engine/.gopath/src/github.com/docker/docker/cli/cli.go:89 +0x383
Aug 17 15:14:26 docker-07 docker[27936]: main.main()
Aug 17 15:14:26 docker-07 docker[27936]: /root/rpmbuild/BUILD/docker-engine/docker/docker.go:63 +0x43c

Note this panic (unlock of unlocked mutex) is happening as a result of a call to once.Do(func() {...}) in the slow path where the once does a defer o.m.Unlock()

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeWaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions