Skip to content

Hello world example does not work on WSL v1 and WSL v2 (Ubuntu 24.04) #5052

@vadimkantorov

Description

@vadimkantorov

On WSLv1 I got a segfault in GC:

$ cat main.go
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

$ go run main.go
Hello, World!

$ tinygo run main.go
Absurd stack bottom value: 0x0
Absurd stack bottom value
failed to run compiled binary /tmp/tinygo1773568974/main: signal: aborted (core dumped)

$ tinygo build -o hello ./main.go

$ gdb -ex run --args ./hello

(gdb) thread apply all bt

Thread 1 (process 18903 "hello"):
#0  __restore_sigs (set=set@entry=0x7ffffffecee8) at /usr/local/lib/tinygo/lib/musl/src/signal/block.c:44
#1  0x0000000000217c3f in raise (sig=<optimized out>) at /usr/local/lib/tinygo/lib/musl/src/signal/raise.c:11
#2  0x00000000002176cc in abort () at /usr/local/lib/tinygo/lib/musl/src/exit/abort.c:11
#3  0x00000000002165a4 in os_main_stackbottom () at /usr/local/lib/tinygo/lib/bdwgc/os_dep.c:1271
#4  GC_get_main_stack_base () at /usr/local/lib/tinygo/lib/bdwgc/os_dep.c:1403
#5  0x0000000000215b6f in GC_init () at /usr/local/lib/tinygo/lib/bdwgc/misc.c:1390
#6  0x000000000021e220 in runtime.initHeap () at /usr/local/lib/tinygo/src/runtime/gc_boehm.go:39
#7  runtime.run () at /usr/local/lib/tinygo/src/runtime/scheduler_threads.go:24
#8  runtime.runMain () at /usr/local/lib/tinygo/src/runtime/runtime_unix.go:136
#9  0x000000000021e209 in main (argc=<optimized out>, argv=<optimized out>) at /usr/local/lib/tinygo/src/runtime/runtime_unix.go:98

On WSLv2 (also Ubuntu 24.04) I got:

$ sudo apt install golang-go

$ go run main.go
Hello, World!

$ tinygo run ./main.go
could not parse Go version: version does not start with 'go' prefix

$ go version
go version go1.13.8 linux/amd64

# even if the go version is too old, it does start with 'go' prefix, the error message should be adjusted

After upgrade to 1.25, it finally worked:

$ go version
go version go1.25.0 linux/amd64

$ tinygo run main.go
Hello world!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions