Ubuntu　Docker buildでSIGABRT: abortというエラーが出たときの対処方法

# docker buildでabortする。

完全に自分用メモです。場当たり的な解決方法を使ったのでオススメできる解決方法ではありません。

以下のように見たことないエラーが起きました。レジスタの内容を表示したり、見たこと無いエラーです。

```
free(): invalid pointer
SIGABRT: abort
PC=0x7efdc7a07fb7 m=0 sigcode=18446744073709551610
signal arrived during cgo execution

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x4afd50, 0xc420047cc0, 0xc420047ce8)
        /usr/lib/go-1.8/src/runtime/cgocall.go:131 +0xe2 fp=0xc420047c90 sp=0xc420047c50
github.com/docker/docker-credential-helpers/secretservice._Cfunc_free(0x8d6da0)
        github.com/docker/docker-credential-helpers/secretservice/_obj/_cgo_gotypes.go:111 +0x41 fp=0xc420047cc0 sp=0xc420047c90
github.com/docker/docker-credential-helpers/secretservice.Secretservice.List.func5(0x8d6da0)
        /build/golang-github-docker-docker-credential-helpers-cMhSy1/golang-github-docker-docker-credential-helpers-0.5.0/obj-x86_64-linux-gnu/src/github.com/docker/docker-credential-helpers/secretservice/secretservice_linux.go:96 +0x60 fp=0xc420047cf8 sp=0xc420047cc0
github.com/docker/docker-credential-helpers/secretservice.Secretservice.List(0x0, 0x756060, 0xc420078000)
        /build/golang-github-docker-docker-credential-helpers-cMhSy1/golang-github-docker-docker-credential-helpers-0.5.0/obj-x86_64-linux-gnu/src/github.com/docker/docker-credential-helpers/secretservice/secretservice_linux.go:97 +0x217 fp=0xc420047da0 sp=0xc420047cf8
github.com/docker/docker-credential-helpers/secretservice.(*Secretservice).List(0x77e548, 0xc420047e88, 0x410022, 0xc4200142e0)
        <autogenerated>:4 +0x46 fp=0xc420047de0 sp=0xc420047da0
github.com/docker/docker-credential-helpers/credentials.List(0x756ba0, 0x77e548, 0x7560e0, 0xc42000e018, 0x0, 0x10)
        /build/golang-github-docker-docker-credential-helpers-cMhSy1/golang-github-docker-docker-credential-helpers-0.5.0/obj-x86_64-linux-gnu/src/github.com/docker/docker-credential-helpers/credentials/credentials.go:145 +0x3e fp=0xc420047e68 sp=0xc420047de0
github.com/docker/docker-credential-helpers/credentials.HandleCommand(0x756ba0, 0x77e548, 0x7ffc7fd4e79f, 0x4, 0x7560a0, 0xc42000e010, 0x7560e0, 0xc42000e018, 0x40e398, 0x4d35c0)
        /build/golang-github-docker-docker-credential-helpers-cMhSy1/golang-github-docker-docker-credential-helpers-0.5.0/obj-x86_64-linux-gnu/src/github.com/docker/docker-credential-helpers/credentials/credentials.go:60 +0x16d fp=0xc420047ed8 sp=0xc420047e68
github.com/docker/docker-credential-helpers/credentials.Serve(0x756ba0, 0x77e548)
        /build/golang-github-docker-docker-credential-helpers-cMhSy1/golang-github-docker-docker-credential-helpers-0.5.0/obj-x86_64-linux-gnu/src/github.com/docker/docker-credential-helpers/credentials/credentials.go:41 +0x1cb fp=0xc420047f58 sp=0xc420047ed8
main.main()
        /build/golang-github-docker-docker-credential-helpers-cMhSy1/golang-github-docker-docker-credential-helpers-0.5.0/secretservice/cmd/main_linux.go:9 +0x4f fp=0xc420047f88 sp=0xc420047f58
runtime.main()
        /usr/lib/go-1.8/src/runtime/proc.go:185 +0x20a fp=0xc420047fe0 sp=0xc420047f88
runtime.goexit()
        /usr/lib/go-1.8/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc420047fe8 sp=0xc420047fe0

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

rax    0x0
rbx    0x7ffc7fd4e000
rcx    0x7efdc7a07fb7
rdx    0x0
rdi    0x2
rsi    0x7ffc7fd4dd90
rbp    0x7ffc7fd4e100
rsp    0x7ffc7fd4dd90
r8     0x0
r9     0x7ffc7fd4dd90
r10    0x8
r11    0x246
r12    0x7ffc7fd4e000
r13    0x1000
r14    0x0
r15    0x30
rip    0x7efdc7a07fb7
rflags 0x246
cs     0x33
fs     0x0
gs     0x0
Sending build context to Docker daemon  8.704kB
```

## 原因

以下に書いてありました。

[strange errors on docker build · Issue #103 · docker/docker-credential-helpers](https://github.com/docker/docker-credential-helpers/issues/103)

> I don't think there is a link to `docker-compose` other than on Ubuntu where installing compose pulls in the g`olang-docker-credential-helpers` dependency, triggering the issue to start appearing. Removing the credentials helper package with `dpkg -r --force-depends` removes this issue and leaves `docker-compose` working fine. For a more practical workaround install with pip or script on Docker's docs site.

バグとしては以下のパッケージによるもののようです。

[Bug #1792824 “golang-docker-credential-helpers is unneeded dep” : Bugs : docker-compose package : Ubuntu](https://bugs.launchpad.net/ubuntu/+source/docker-compose/+bug/1792824)

## 解決方法

dpkgコマンドが自分の環境では動かなかったので、pip3を使いました。
練習用の仮想環境だったので、雑に解決しています。おすすめできる方法ではありません。

```
sudo apt-get purge docker-compose
sudo apt-get autoremove
sudo apt-get install python3-pip

## ここからが雑な解決法

# pip自身をアップデート
sudo pip3 install -U pip

# パッケージを一括アップデート
pip list --outdated | tail -n +3 | awk '{print $1}' | xargs sudo pip install -U 

# docker-composeをインストール
sudo pip3 install docker-compose
```

## 参考

[Pythonのモジュールをpipで一括アップデートする方法](https://kaworu.jpn.org/kaworu/2018-05-22-1.php)