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

"go install" segfault: memorymalloc.c:587:666 assertion failed: g_machine #86

Open
kdrag0n opened this issue Mar 15, 2023 · 0 comments
Open

Comments

@kdrag0n
Copy link

kdrag0n commented Mar 15, 2023

On an arm64 Linux host with 4K pages, attempts to install Go command-line tools fail with a false-positive "does not contain package" error and end with Blink segfaulting.

Expected output (with Rosetta 2 for Linux):

go: downloading golang.org/x/tools v0.3.1-0.20221213193459-ca17b2c27ca8
go: downloading github.com/sergi/go-diff v1.1.0
go: downloading honnef.co/go/tools v0.3.3
go: downloading mvdan.cc/gofumpt v0.4.0
go: downloading mvdan.cc/xurls/v2 v2.4.0
go: downloading golang.org/x/mod v0.7.0
go: downloading golang.org/x/sys v0.2.0
go: downloading golang.org/x/sync v0.1.0
go: downloading golang.org/x/vuln v0.0.0-20221109205719-3af8368ee4fe
go: downloading golang.org/x/text v0.4.0
go: downloading golang.org/x/exp/typeparams v0.0.0-20221031165847-c99f073a8326
go: downloading github.com/google/go-cmp v0.5.9
go: downloading github.com/BurntSushi/toml v1.2.1
go: downloading golang.org/x/exp v0.0.0-20221031165847-c99f073a8326

Actual output:

go: downloading golang.org/x/tools v0.7.0
go: downloading golang.org/x/tools/gopls v0.11.0
go: golang.org/x/tools/gopls@latest: module golang.org/x/tools/gopls@latest found (v0.11.0), but does not contain package golang.org/x/tools/gopls
assertion failed
blink/memorymalloc.c:587:666 assertion failed: g_machine (0)
	<machine state unavailable>
	<blink backtrace unavailable>
/usr/bin/arch-chroot: line 457:  9403 Segmentation fault      SHELL=/bin/bash $pid_unshare chroot "${chroot_args[@]}" -- "$chrootdir" "${args[@]}"

blink.log:

I2023-03-15T04:33:40.841614:blink/syscall.c:5720:1 missing syscall 0x144
I2023-03-15T04:33:41.289925:blink/memorymalloc.c:292:262151 kill9'd thread after 10 tries

To reproduce:

  • Download and extract an x86_64 Alpine rootfs: https://dl-cdn.alpinelinux.org/alpine/v3.17/releases/x86_64/alpine-minirootfs-3.17.2-x86_64.tar.gz
  • Mount /proc, /sys, and /dev at the respective rootfs paths
  • Set up a resolv.conf: nameserver 1.1.1.1
  • With qemu-user-x86_64 as binfmt handler, install Go: apk add go
  • Compile a static build of Blink
  • Register it as a binfmt handler by writing :blink:M:0:\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\x00\x00\x00\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/PATH/TO/blink/o/blink/blink:OCF to /proc/sys/binfmt_misc/register (I used cat to avoid shell escapes)
  • chroot rootfs /usr/bin/go install golang.org/x/tools/gopls@latest

Blink version:

Blink Virtual Machine 0.9.2 (Wed Mar 15 04:18:12 UTC 2023)
Copyright (c) 2023 Justine Alexandra Roberts Tunney
Blink comes with absolutely NO WARRANTY of any kind.
You may redistribute copies of Blink under the ISC License.
For more information, see the file named LICENSE.
Toolchain: cc (GCC) 12.1.0
Revision: #511 7bb0a1cde18019c7921fafafcf70538e46f7838d
Config: ./configure MODE= --static
@kdrag0n kdrag0n changed the title "go install" fails and segfaults "go install" segfault: memorymalloc.c:587:666 assertion failed: g_machine Mar 31, 2023
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

No branches or pull requests

1 participant