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

Cross compiled for riscv64 crashes on Debian #2514

Closed
phpeterson-usf opened this issue Jul 27, 2022 · 2 comments
Closed

Cross compiled for riscv64 crashes on Debian #2514

phpeterson-usf opened this issue Jul 27, 2022 · 2 comments

Comments

@phpeterson-usf
Copy link

phpeterson-usf commented Jul 27, 2022

Description of the problem or steps to reproduce

  1. I'm trying to use micro for a riscv64 project. I cross-compiled using go version go1.18.4 darwin/arm64 using the environment variables GOOS=linux GOARCH=riscv64 CGO_ENABLED=0
  2. The resulting micro binary crashes on Debian with the output pasted below
  3. I was successful using an earlier micro binary on Ubuntu/riscv64 but the Debian build is easier to work with for other reasons

Specifications

Commit hash: 225927b
OS:
Host: Darwin Phils-MacBook-Pro.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000 arm64
Guest: Linux debian 5.18.0-2-riscv64 #1 SMP Debian 5.18.5-1 (2022-06-16) riscv64 GNU/Linux
Terminal: iTerm2

Output

runtime: lfstack.push invalid packing: node=0xffffff8cc2b980 cnt=0x1 packed=0xffff8cc2b9800001 -> node=0xffff8cc2b980
fatal error: lfstack.push

runtime stack:
runtime.throw({0x5966ba, 0xc})
	runtime/panic.go:992 +0x58
runtime.(*lfstack).push(0xaf62e8, 0xffffff8cc2b980)
	runtime/lfstack.go:30 +0x144
runtime.(*spanSetBlockAlloc).free(...)
	runtime/mspanset.go:292
runtime.(*spanSet).reset(0xaef898)
	runtime/mspanset.go:265 +0xac
runtime.finishsweep_m()
	runtime/mgcsweep.go:260 +0xc8
runtime.gcStart.func1()
	runtime/mgc.go:664 +0x1c
runtime.systemstack()
	runtime/asm_riscv64.s:133 +0x50

goroutine 1 [running]:
runtime.systemstack_switch()
	runtime/asm_riscv64.s:96 +0x8 fp=0xc0004b3720 sp=0xc0004b3718 pc=0x74098
runtime.gcStart({0x0, 0x0, 0x0})
	runtime/mgc.go:663 +0x500 fp=0xc0004b3798 sp=0xc0004b3720 pc=0x29188
runtime.mallocgc(0x30, 0x5576e0, 0x1)
	runtime/malloc.go:1205 +0x71c fp=0xc0004b3810 sp=0xc0004b3798 pc=0x1bdb4
runtime.growslice(0x5576e0, {0x0, 0x0, 0x0}, 0x1)
	runtime/slice.go:278 +0x4e0 fp=0xc0004b3860 sp=0xc0004b3810 pc=0x5e4b8
regexp/syntax.(*compiler).inst(...)
	regexp/syntax/compile.go:164
regexp/syntax.(*compiler).init(...)
	regexp/syntax/compile.go:83
regexp/syntax.Compile(0xc000131810)
	regexp/syntax/compile.go:73 +0x9c fp=0xc0004b3920 sp=0xc0004b3860 pc=0x151214
regexp.compile({0x59c8fd, 0x14}, 0xd4, 0x0)
	regexp/regexp.go:180 +0xa4 fp=0xc0004b39b8 sp=0xc0004b3920 pc=0x167c94
regexp.Compile(...)
	regexp/regexp.go:135
regexp.MustCompile({0x59c8fd, 0x14})
	regexp/regexp.go:315 +0x3c fp=0xc0004b3a38 sp=0xc0004b39b8 pc=0x1688ac
main.LoadInput({0xc00001c310, 0x0, 0x0})
	github.com/zyedidia/micro/v2/cmd/micro/micro.go:166 +0x14c fp=0xc0004b3bb8 sp=0xc0004b3a38 pc=0x4af5d4
main.main()
	github.com/zyedidia/micro/v2/cmd/micro/micro.go:319 +0x748 fp=0xc0004b3f80 sp=0xc0004b3bb8 pc=0x4b0988
runtime.main()
	runtime/proc.go:250 +0x228 fp=0xc0004b3fd8 sp=0xc0004b3f80 pc=0x48480
runtime.goexit()
	runtime/asm_riscv64.s:497 +0x4 fp=0xc0004b3fd8 sp=0xc0004b3fd8 pc=0x75ec4

goroutine 6 [sleep]:
time.Sleep(0x1dcd65000)
	runtime/time.go:194 +0x150
github.com/zyedidia/micro/v2/internal/buffer.backupThread()
	github.com/zyedidia/micro/v2/internal/buffer/backup.go:37 +0x28
created by github.com/zyedidia/micro/v2/internal/buffer.init.0
	github.com/zyedidia/micro/v2/internal/buffer/backup.go:52 +0x68

goroutine 8 [syscall]:
os/signal.signal_recv()
	runtime/sigqueue.go:151 +0x38
os/signal.loop()
	os/signal/signal_unix.go:23 +0x1c
created by os/signal.Notify.func1.1
	os/signal/signal.go:151 +0x2c

goroutine 9 [select]:
github.com/zyedidia/tcell/v2.(*tScreen).mainLoop(0xc000190000)
	github.com/zyedidia/tcell/v2@v2.0.9/tscreen.go:1580 +0xe0
created by github.com/zyedidia/tcell/v2.(*tScreen).Init
	github.com/zyedidia/tcell/v2@v2.0.9/tscreen.go:210 +0x6cc

goroutine 10 [IO wait]:
internal/poll.runtime_pollWait(0xffffff8cc35198, 0x72)
	runtime/netpoll.go:302 +0xe0
internal/poll.(*pollDesc).wait(0xc000058e58, 0x72, 0x1)
	internal/poll/fd_poll_runtime.go:83 +0x34
internal/poll.(*pollDesc).waitRead(...)
	internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Read(0xc000058e40, {0xc0003fb000, 0x1000, 0x1000})
	internal/poll/fd_unix.go:167 +0x1f0
os.(*File).read(...)
	os/file_posix.go:31
os.(*File).Read(0xc00000c780, {0xc0003fb000, 0x1000, 0x1000})
	os/file.go:119 +0x70
github.com/zyedidia/tcell/v2.(*tScreen).inputLoop(0xc000190000)
	github.com/zyedidia/tcell/v2@v2.0.9/tscreen.go:1633 +0x94
created by github.com/zyedidia/tcell/v2.(*tScreen).Init
	github.com/zyedidia/tcell/v2@v2.0.9/tscreen.go:211 +0x724
@zyedidia
Copy link
Owner

Interesting -- this looks like a bug in Go rather than micro. Are you able to reproduce it consistently? It looks like the crash is happening inside the Go garbage collector in the lock-free stack implementation. In particular, I think the fix would involve adding a || GOARCH == "riscv64" check to this if statement: https://github.com/golang/go/blob/462b78fe7027ef0d2e2b40c3cfd1f5a37d307310/src/runtime/lfstack_64bit.go#L49, since it looks like your riscv system is placing the stack at a high memory address. I'm just guessing though. You could see if that fixes it if you make that change locally to your go installation in src/runtime/lfstack_64bit.go.

Ultimately though I think this is an issue that should be opened on the Go repo.

@phpeterson-usf
Copy link
Author

Yes, this crash is on launch and is consistent. I reverified that the same micro binary works fine on Linux ubuntu 5.13.0-1026-generic #29~20.04.1-Ubuntu SMP Fri Jun 3 11:55:52 UTC 2022 riscv64 riscv64 riscv64 GNU/Linux

I filed an issue on the Go repo

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

2 participants