all: avoid a goroutine deadlock on disassembler error

testExtDis currently has a goroutine deadlock - errc is an unbuffered
channel, which is written to from a goroutine that calls extdis. The
goroutine running testExtDis calls generate, which calls back into the
anonymous function which then reads from ext.Dis. If extdis returns an
error, it will not write to ext.Dis which leaves a deadlock between the
two goroutines - one writing on errc and one reading from ext.Dis.

Prevent this by closing the ext.Dis channel if we encounter an error
that would be written to errc. This results in all current and future
calls to the anonymous function returning, generate will then return
and errc will then be read. This is a minimal fix - this really needs
a redesign to improve the synchronisation and error handling (and
ideally it would be not duplicated for each architecture).

Change-Id: I9354b43608d25a55152d3ec989869c2afc076ee5
Reviewed-on: https://go-review.googlesource.com/c/arch/+/805180
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Joel Sing <joel@sing.id.au>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
6 files changed
tree: 264faf5d8b2f417320ed62a50a3c08af7bc45d69
  1. arm/
  2. arm64/
  3. loong64/
  4. ppc64/
  5. riscv64/
  6. s390x/
  7. x86/
  8. .gitattributes
  9. codereview.cfg
  10. CONTRIBUTING.md
  11. go.mod
  12. go.sum
  13. LICENSE
  14. PATENTS
  15. README.md
README.md

arch

Go Reference

This repository holds machine architecture information used by the Go toolchain. The parts needed in the main Go repository are copied in.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.

The git repository is https://go.googlesource.com/arch.

The main issue tracker for the arch repository is located at https://go.dev/issues. Prefix your issue with “x/arch:” in the subject line, so it is easy to find.