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

cmd/link: on wasm, number of functions limited to 2^16 #64856

Open
HarikrishnanBalagopal opened this issue Dec 24, 2023 · 36 comments
Open

cmd/link: on wasm, number of functions limited to 2^16 #64856

HarikrishnanBalagopal opened this issue Dec 24, 2023 · 36 comments
Labels
arch-wasm WebAssembly issues compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@HarikrishnanBalagopal
Copy link

HarikrishnanBalagopal commented Dec 24, 2023

Overview

It seems to me that the size of a WASM function is limited to 2^16 = 65536 bytes?

ldr.SetSymValue(s, int64(funcValueOffset+va/ld.MINFUNC)<<16) // va starts at zero

This leads to a bunch of errors whenever using more than a few libraries in our WASM app
The code for our app is available in this branch https://github.com/konveyor/move2kube/blob/wasm/go.mod
The code is able to build using the official Go compiler WASIP1 support
https://github.com/konveyor/move2kube/blob/dec9d8da6e5f8882aacb46a8e5f784b96b42a3c6/Makefile#L45C2-L45C100

Issue

When we try to add the https://pkg.go.dev/go.starlark.net/starlark library then we get a bunch of compile errors

type:*github.com/mholt/archiver/v3.FileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*FileInfo).ModTime is too big: 0x100c40000
type:*github.com/mholt/archiver/v3.FileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*FileInfo).ModTime is too big: 0x100c40000
type:*github.com/mholt/archiver/v3.FileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*FileInfo).Mode is too big: 0x100c60000
type:*github.com/mholt/archiver/v3.FileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*FileInfo).Mode is too big: 0x100c60000
type:*github.com/mholt/archiver/v3.FileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*FileInfo).Name is too big: 0x100c70000
type:*github.com/mholt/archiver/v3.FileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*FileInfo).Name is too big: 0x100c70000
type:*github.com/mholt/archiver/v3.FileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*FileInfo).Size is too big: 0x100c90000
/usr/local/go/pkg/tool/linux_amd64/link: too many errors
make: *** [Makefile:45: build] Error 1

Fix

Please remove this arbitrary limit on function size or at least provide a way to work around it. This is a severe limit on any real world app that will use many different libraries to implement various features.

The WASM page size is 65536 bytes https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/Memory/Memory which is 2^16 and can be addressed with 16 bits. That might explain where this particular limit came from but it doesn't explain why a single function has to fit all inside of one WASM page. Especially since WASM functions live is a completely separate address space than the WASM linear memory.

Also see these comments:

Related

https://stackoverflow.com/questions/67294859/why-golang-limit-the-symbol-number-to-65535-while-compile-wasm-target
#7769
#7980
WebAssembly/design#1138

@HarikrishnanBalagopal HarikrishnanBalagopal changed the title wasm: function size limited to 16KB bug: wasm function size limited to 16KB Dec 24, 2023
@HarikrishnanBalagopal HarikrishnanBalagopal changed the title bug: wasm function size limited to 16KB bug: wasm function size limited to 2^16 bytes Dec 24, 2023
@seankhliao seankhliao changed the title bug: wasm function size limited to 2^16 bytes cmd/link: wasm function size limited to 2^16 bytes Dec 24, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Dec 24, 2023
@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. arch-wasm WebAssembly issues labels Dec 24, 2023
@mauri870
Copy link
Member

/cc @golang/wasm

@mauri870
Copy link
Member

Looking at the limits for other implementations I see no issue bumping the function size in Go, unless that has to do with some internal implementation detail on our side that I'm not aware of. For instance, Webkit and V8 use 7654321, we might as well just ride the same train.

@mauri870
Copy link
Member

mauri870 commented Dec 25, 2023

After some investigation this appears to be a bug with 1.22. I'm able to compile this without any errors with go 1.21.

It happens for both js and wasip1 here. Since there are unrelated failures I was only able to bisect to a certain range 4346ba3...8be8bfe (113 commits).

This error prevents the compilation of large wasm programs with Go 1.22 without a workaround.

/cc @golang/release

@dmitshur dmitshur added this to the Go1.22 milestone Dec 25, 2023
@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Dec 26, 2023

After some investigation this appears to be a bug with 1.22. I'm able to compile this without any errors with go 1.21.

It happens for both js and wasip1 here. Since there are unrelated failures I was only able to bisect to a certain range 4346ba3...8be8bfe (113 commits).

This error prevents the compilation of large wasm programs with Go 1.22 without a workaround.

/cc @golang/release

@mauri870 I don't think the bug is only in v1.22 because we have not tried v1.22 yet. The errors we saw are all with Go v1.21

The line I linked in the first post is still there in the master branch

ldr.SetSymValue(s, int64(funcValueOffset+va/ld.MINFUNC)<<16) // va starts at zero

The git blame shows that line has been there from the beginning when WASM got added f41dc71#diff-b189a5a4d6f377939c502fb248c71ab0f1febe60a54f283eaca1dad73c196604R85

Working

Building the wasm branch https://github.com/konveyor/move2kube/tree/wasm works correctly:

$ go version
go version go1.21.0 darwin/arm64
$ make build
mkdir -p "./bin"
CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm go build -ldflags ' -X github.com/konveyor/move2kube-wasm/types/info.buildmetadata=unreleased -X github.com/konveyor/move2kube-wasm/types/info.gitCommit=dec9d8da6e5f8882aacb46a8e5f784b96b42a3c6 -X github.com/konveyor/move2kube-wasm/types/info.gitTreeState=clean' -o "./bin/move2kube.wasm" .
gzip -f "./bin/move2kube.wasm"
# We have to put require github.com/sirupsen/logrus v1.9.4-0.20230606125235-dd1b4c2e81af
# in order for logrus to work. See https://github.com/HarikrishnanBalagopal/test-wasi-fs-browser/tree/main
# CGO_ENABLED=0 tinygo build -o "./bin/move2kube.wasm" -target=wasi .
$ echo $?
0

Non-working

After adding the go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 library, building this branch https://github.com/HarikrishnanBalagopal/move2kube/tree/feat/starlark with Golang v1.21.0 gives errors:

$ go version
go version go1.21.0 darwin/arm64
$ make build
mkdir -p "./bin"
CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm go build -ldflags ' -X github.com/konveyor/move2kube-wasm/types/info.buildmetadata=unreleased -X github.com/konveyor/move2kube-wasm/types/info.gitCommit=6d72f91783749e697f9fa38c17f8b4d892c9d102 -X github.com/konveyor/move2kube-wasm/types/info.gitTreeState=clean' -o "./bin/move2kube.wasm" .
# github.com/konveyor/move2kube-wasm
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).IsDir is too big: 0x100240000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).IsDir is too big: 0x100240000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).ModTime is too big: 0x100250000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).ModTime is too big: 0x100250000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).Mode is too big: 0x100260000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).Mode is too big: 0x100260000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).Name is too big: 0x100270000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).Name is too big: 0x100270000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).Size is too big: 0x100280000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).Size is too big: 0x100280000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).Sys is too big: 0x100290000
type:*github.com/mholt/archiver/v3.rarFileInfo: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*rarFileInfo).Sys is too big: 0x100290000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Match is too big: 0x100010000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Match is too big: 0x100010000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Read is too big: 0x100030000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Read is too big: 0x100030000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Write is too big: 0x100050000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Write is too big: 0x100050000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).CheckPath is too big: 0x100070000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).CheckPath is too big: 0x100070000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).Close is too big: 0x100090000
/opt/homebrew/Cellar/go/1.21.0/libexec/pkg/tool/darwin_arm64/link: too many errors
make: *** [build] Error 1

Difference

The difference is that we added the starlark-go library and a file that uses it https://github.com/HarikrishnanBalagopal/move2kube/blob/feat/starlark/transformer/external/starlarktransformer.go

$ git checkout feat/starlark 
Switched to branch 'feat/starlark'
Your branch is up to date with 'origin/feat/starlark'.
$ git status
On branch feat/starlark
Your branch is up to date with 'origin/feat/starlark'.

nothing to commit, working tree clean
$ git diff wasm --name-status 
M       go.mod
M       go.sum
A       transformer/external/starlarktransformer.go
$ git diff wasm go.mod
diff --git a/go.mod b/go.mod
index 8fdc019..e8de3ed 100644
--- a/go.mod
+++ b/go.mod
@@ -28,6 +28,7 @@ require (
        github.com/spf13/cobra v1.7.0
        github.com/spf13/viper v1.16.0
        github.com/whilp/git-urls v1.0.0
+       go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5
        golang.org/x/crypto v0.12.0
        golang.org/x/mod v0.10.0
        golang.org/x/text v0.12.0
$ git diff wasm go.sum
diff --git a/go.sum b/go.sum
index 6fe3536..0caf20c 100644
--- a/go.sum
+++ b/go.sum
@@ -1702,6 +1702,7 @@ go.opentelemetry.io/otel/trace v0.20.0/go.mod h1:6GjCW8zgDjwGHGa6GkyeB8+/5vjT16g
 go.opentelemetry.io/otel/trace v1.0.0-RC1/go.mod h1:86UHmyHWFEtWjfWPSbu0+d0Pf9Q6e1U+3ViBOc+NXAg=
 go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
 go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg=
+go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=
 go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
 go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
 go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=

@mauri870
Copy link
Member

Thanks, but I still can't reproduce on 1.21 for some reason

$ CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm go1.21.5 build
$ CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm gotip build
# github.com/konveyor/move2kube-wasm
type:*github.com/mholt/archiver/v3.TarGz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarGz).Match is too big: 0x100010000
type:*github.com/mholt/archiver/v3.TarGz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarGz).Match is too big: 0x100010000
type:*github.com/mholt/archiver/v3.TarGz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarGz).Read is too big: 0x100030000 
# ...

@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Dec 26, 2023

type:*github.com/mholt/archiver/v3.TarGz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarGz).Match is too big: 0x100010000

I might be confused but the output you have shown includes the compile error. Are you trying to reproduce something else?

@mauri870
Copy link
Member

Sorry, I think I was not clear enough. With 1.21.5 it built just fine, the error you see is for gotip(1.22).

@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Dec 26, 2023

Sorry, I think I was not clear enough. With 1.21.5 it built just fine, the error you see is for gotip(1.22).

hmm, that's weird the line I linked hasn't changed very much

ldr.SetSymValue(s, int64(funcValueOffset+va/ld.MINFUNC)<<16) // va starts at zero
since it was added. The error due to function size limit should be in all the versions.

Update

@mauri870 I just updated to v1.21.5 and I am still getting the error.
I am using the go formula provided by brew https://formulae.brew.sh/formula/go
The WASM app commit hash is 95c7fb33c04bb31d3d5e25a8553930693de86194

$ go version
go version go1.21.5 darwin/arm64
$ git log
commit 95c7fb33c04bb31d3d5e25a8553930693de86194 (HEAD -> feat/starlark, origin/feat/starlark)
Author: Harikrishnan Balagopal <harikrishmenon@gmail.com>
Date:   Tue Dec 26 15:04:57 2023 +0530

    feat: add the starlark transformer
    
    chore: update dependencies
    fix: issue with string not implementing a starlark interface
    
    Signed-off-by: Harikrishnan Balagopal <harikrishmenon@gmail.com>
$ git status
On branch feat/starlark
Your branch is up to date with 'origin/feat/starlark'.

nothing to commit, working tree clean
$ make build
mkdir -p "./bin"
CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm go build -ldflags ' -X github.com/konveyor/move2kube-wasm/types/info.buildmetadata=unreleased -X github.com/konveyor/move2kube-wasm/types/info.gitCommit=95c7fb33c04bb31d3d5e25a8553930693de86194 -X github.com/konveyor/move2kube-wasm/types/info.gitTreeState=clean' -o "./bin/move2kube.wasm" .
# github.com/konveyor/move2kube-wasm
type:*github.com/mholt/archiver/v3.TarGz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarGz).Write is too big: 0x100010000
type:*github.com/mholt/archiver/v3.TarGz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarGz).Write is too big: 0x100010000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).CheckPath is too big: 0x100030000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).CheckPath is too big: 0x100030000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Close is too big: 0x100050000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Close is too big: 0x100050000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Match is too big: 0x100070000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Match is too big: 0x100070000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Read is too big: 0x100090000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Read is too big: 0x100090000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Write is too big: 0x1000b0000
type:*github.com/mholt/archiver/v3.TarLz4: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarLz4).Write is too big: 0x1000b0000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).CheckPath is too big: 0x1000d0000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).CheckPath is too big: 0x1000d0000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).Close is too big: 0x1000f0000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).Close is too big: 0x1000f0000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).Match is too big: 0x100110000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).Match is too big: 0x100110000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).Read is too big: 0x100130000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).Read is too big: 0x100130000
type:*github.com/mholt/archiver/v3.TarSz: non-pc-relative relocation address for github.com/mholt/archiver/v3.(*TarSz).Write is too big: 0x100150000
/opt/homebrew/Cellar/go/1.21.5/libexec/pkg/tool/darwin_arm64/link: too many errors
make: *** [build] Error 1

@mauri870
Copy link
Member

mauri870 commented Dec 26, 2023

I managed to reproduce it consistently in go 1.21 now, thanks. I would not trust on my initial bisecting results because the repro was not very consistent.

I was able to reproduce the issue with:

git clone https://github.com/HarikrishnanBalagopal/move2kube.git -b feat/starlark
cd move2kube
GOOS=js GOARCH=wasm go1.21.5 build

Since 1.20 does not have the wasip1 port, I tried with GOOS=js and it compiled just fine, so it appears to not be affected.

It is unclear to me where the issue is, but since programs compile just fine in Go 1.20 and we have the same function size in 1.20, 1.21 and tip something changed between 1.20 and 1.21 that caused the error to appear.

@gopherbot please backport to Go 1.21, this is a linker issue when compiling large wasm programs without a workaround.

@gopherbot
Copy link

Backport issue(s) opened: #64867 (for 1.20), #64868 (for 1.21).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@mauri870
Copy link
Member

mauri870 commented Dec 26, 2023

I tried bisecting again and it points to CL 484856. I tried the parent commit and it works fine, but fails on the CL commit.

I have honestly no idea why this change would cause relocations to overflow in large wasm programs.

cc @randall77 @dr2chase (sorry about the double cc, I posted in the backport issue before by mistake)

@cherrymui
Copy link
Member

It seems to me that the size of a WASM function is limited to 2^16 = 65536 bytes?
ldr.SetSymValue(s, int64(funcValueOffset+va/ld.MINFUNC)<<16) // va starts at zero

This line does not limit a WASM function's size to 65536 bytes. In our WASM backend, the "PC" is an index of a basic block, not a byte count or instruction count. To overflow that limit, the function needs to have more than 65536 basic blocks, which is possible but quite rare.

@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Dec 26, 2023

It seems to me that the size of a WASM function is limited to 2^16 = 65536 bytes?
ldr.SetSymValue(s, int64(funcValueOffset+va/ld.MINFUNC)<<16) // va starts at zero

This line does not limit a WASM function's size to 65536 bytes. In our WASM backend, the "PC" is an index of a basic block, not a byte count or instruction count. To overflow that limit, the function needs to have more than 65536 basic blocks, which is possible but quite rare.

	// The following rules describe how wasm handles function indices and addresses:
	//   PC_F = funcValueOffset + WebAssembly function index (not including the imports)
	//   s.Value = PC = PC_F<<16 + PC_B
	//
	// The funcValueOffset is necessary to avoid conflicts with expectations
	// that the Go runtime has about function addresses.
	// The field "s.Value" corresponds to the concept of PC at runtime.
	// However, there is no PC register, only PC_F and PC_B. PC_F denotes the function,
	// PC_B the resume point inside of that function. The entry of the function has PC_B = 0.

hmm, the comment above that line makes it seem like it's a regular PC (but calculated from 2 values PC_F and PC_B).

  • What is the size of a basic block?
  • Why is it triggering the compile error in the above case then? Is it going over the 65536 basic blocks limit?

@cherrymui
Copy link
Member

It is not a regular PC. PC_B only increments per "resume point", which is essentially per basic block. How many instructions in a basic block and how many bytes are used to encode those instructions do not matter.

I'll look into what the cause of the error is. I'm not sure yet, but it is probably not the basic block number limit.

@cherrymui
Copy link
Member

It is not the basic block number limit, but the total number of (reachable) functions. As you saw in the comment above, PC = PC_F<<16 + PC_B, where PC_F is function index. With the current encoding scheme, when there are more than 65536 functions, PC is larger than 32-bit. The method table uses a 32-bit offset for the PC of the method. So it overflows. (The bisection probably just points to a CL that just increases the total number of functions slightly and pushes it over the limit.)

We might be able to change the encoding scheme. E.g. we could change the method table to encode only the PC_F part, as we never call to the middle of a method. But there are places where we call to the middle of a function: e.g. preemption and resumption. That will make things more complicated.

cc @neelance

@gopherbot
Copy link

Change https://go.dev/cl/552835 mentions this issue: cmd/link, runtime: put only function index in method table

@cherrymui
Copy link
Member

CL https://go.dev/cl/552835 changes the method table encoding to allow more than 65536 functions. Now https://github.com/HarikrishnanBalagopal/move2kube/tree/feat/starlark builds. Could you test if the resulting binary is correct? Thanks.

I don't really like the CL, as it adds more special case for Wasm. But maybe it is fine...

@cherrymui cherrymui changed the title cmd/link: wasm function size limited to 2^16 bytes cmd/link: wasm number of functions limited to 2^16 Dec 26, 2023
@cherrymui cherrymui changed the title cmd/link: wasm number of functions limited to 2^16 cmd/link: on wasm, number of functions limited to 2^16 Dec 26, 2023
@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Dec 27, 2023

It is not the basic block number limit, but the total number of (reachable) functions. As you saw in the comment above, PC = PC_F<<16 + PC_B, where PC_F is function index. With the current encoding scheme, when there are more than 65536 functions, PC is larger than 32-bit. The method table uses a 32-bit offset for the PC of the method. So it overflows. (The bisection probably just points to a CL that just increases the total number of functions slightly and pushes it over the limit.)

We might be able to change the encoding scheme. E.g. we could change the method table to encode only the PC_F part, as we never call to the middle of a method. But there are places where we call to the middle of a function: e.g. preemption and resumption. That will make things more complicated.

cc @neelance

Is it necessary to keep the size to 32bit? The line shows an explicit cast to int64

ldr.SetSymValue(s, int64(funcValueOffset+va/ld.MINFUNC)<<16) // va starts at zero

Both the input va and the return value are also uint64
va += uint64(ld.MINFUNC)
return sect, n, va

Since the WASM functions live in a separate address space to the WASM linear memory, it should not be affected by the same constraints when it comes to address bit size.

@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Dec 27, 2023

CL https://go.dev/cl/552835 changes the method table encoding to allow more than 65536 functions. Now https://github.com/HarikrishnanBalagopal/move2kube/tree/feat/starlark builds. Could you test if the resulting binary is correct? Thanks.

I don't really like the CL, as it adds more special case for Wasm. But maybe it is fine...

Do I need to fetch the git fetch https://go.googlesource.com/go refs/changes/35/552835/2 && git checkout -b change-552835 FETCH_HEAD changes and build to get the Go compiler with the changes? If you have the pre-built wasm binary I can test that directly.

Update 1

I was able to build the Go compiler with the changes.

$ ./make.bash 
Building Go cmd/dist using /opt/homebrew/Cellar/go/1.21.5/libexec. (go1.21.5 darwin/arm64)
Building Go toolchain1 using /opt/homebrew/Cellar/go/1.21.5/libexec.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/arm64.
---
Installed Go for darwin/arm64 in /Users/haribala/Documents/code/remote/go.googlesource.com/go
Installed commands in /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin
*** You need to add /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin to your PATH.

I was able to build the WASM app with the new compiler

$ CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin/go build -ldflags ' -X github.com/konveyor/move2kube-wasm/types/info.buildmetadata=unreleased -X github.com/konveyor/move2kube-wasm/types/info.gitCommit=95c7fb33c04bb31d3d5e25a8553930693de86194 -X github.com/konveyor/move2kube-wasm/types/info.gitTreeState=clean' -o "./bin/move2kube.wasm" .
$ echo $?
0

This is the compressed WASM binary
move2kube.wasm.gz

Update 2

@cherrymui Running the new WASM binary gives a very large stack trace and a fatal error at the end.
For comparison, here's a working version https://move2kube.konveyor.io/experimental

This is the partial stack trace that we were able to capture https://gist.github.com/HarikrishnanBalagopal/80ca5e1d359ffdafd1692700b3370168

fatal error: invalid runtime symbol table
runtime: panic before malloc heap initialized

runtime stack:
runtime.throw({0x4aae37, 0x1c})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1023 +0x3 fp=0x27e4628 sp=0x27e4600 pc=0x13710003
runtime.moduledataverify1(0x2699700)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:553 +0x8d fp=0x27e4720 sp=0x27e4628 pc=0x148c008d
runtime.moduledataverify(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:518
runtime.schedinit()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:783 +0xb fp=0x27e4770 sp=0x27e4720 pc=0x13a8000b
runtime.rt0_go()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:22 +0x3 fp=0x27e4778 sp=0x27e4770 pc=0x160b0003

Steps:

image

Update 3

@cherrymui So with the new compiler changes, even the wasm branch (without the starlark-go library https://github.com/konveyor/move2kube/tree/wasm) is also failing with fatal error
move2kube.wasm.gz

https://gist.github.com/HarikrishnanBalagopal/d59b6f5a724dc49e207de967f2394e84

fatal error: invalid runtime symbol table
runtime: panic before malloc heap initialized

runtime stack:
runtime.throw({0x4a2792, 0x1c})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1023 +0x3 fp=0x27a0c48 sp=0x27a0c20 pc=0x13700003
runtime.moduledataverify1(0x2656660)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:553 +0x8d fp=0x27a0d40 sp=0x27a0c48 pc=0x148b008d
runtime.moduledataverify(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:518
runtime.schedinit()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:783 +0xb fp=0x27a0d90 sp=0x27a0d40 pc=0x13a7000b
runtime.rt0_go()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:22 +0x3 fp=0x27a0d98 sp=0x27a0d90 pc=0x160a0003

Update 4

Managed to capture the beginning of the stack trace:
https://gist.github.com/HarikrishnanBalagopal/539cb78919807beeceba33049b2b2e4d

function symbol table not sorted by PC offset: 0xffff0000 github.com/mholt/archiver/v3.(*TarGz).Close > 0x0 github.com/mholt/archiver/v3.TarGz.Match , plugin: 
	 0x10000000 
	 0x10010000 internal/abi.(*RegArgs).Dump
	 0x10020000 internal/abi.(*RegArgs).IntRegArgAddr
	 0x10030000 internal/abi.(*IntArgRegBitmap).Set

@HarikrishnanBalagopal
Copy link
Author

@cherrymui The panic seems to be coming from

println("function symbol table not sorted by PC offset:", hex(datap.ftab[i].entryoff), funcname(f1), ">", hex(datap.ftab[i+1].entryoff), f2name, ", plugin:", datap.pluginpath)

and
throw("invalid runtime symbol table")

@cherrymui
Copy link
Member

Thanks for trying the code and posting the error message. It seems the function table will need a similar update. I'll look into that.

Is it necessary to keep the size to 32bit?

Yes. It is not va that needs to be in 32-bit, but the relative addresses are stored in the binary as 32-bit in various places. If that value overflows 32-bit, the stored relative address is truncated and incorrect. (Please refrain from commenting on the code. The failure mode and error message are helpful, but the comments on the code are not. Thanks.)

@HarikrishnanBalagopal
Copy link
Author

Thanks for trying the code and posting the error message. It seems the function table will need a similar update. I'll look into that.

Is it necessary to keep the size to 32bit?

Yes. It is not va that needs to be in 32-bit, but the relative addresses are stored in the binary as 32-bit in various places. If that value overflows 32-bit, the stored relative address is truncated and incorrect. (Please refrain from commenting on the code. The failure mode and error message are helpful, but the comments on the code are not. Thanks.)

Thanks, please let me know when you make the changes to the function table and I will test them out as well.

@HarikrishnanBalagopal
Copy link
Author

Any update on this?

@cherrymui
Copy link
Member

I was OOO last week and I'm just back. I'll work on the function table change. Thanks.

@HarikrishnanBalagopal
Copy link
Author

I was OOO last week and I'm just back. I'll work on the function table change. Thanks.

Np, hope you had a good vacation. Please let me know if there's any update on this.

@gopherbot gopherbot modified the milestones: Go1.22, Go1.23 Feb 6, 2024
@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Feb 13, 2024

Hi! Any update on this? now that v1.22 has been released.

@cherrymui
Copy link
Member

Not yet. Still working on it. I hope to get a new version of the fix by this week.

@cherrymui
Copy link
Member

@HarikrishnanBalagopal could you try the new version of CL https://go.dev/cl/552835 ? Thanks.

@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Feb 18, 2024

@HarikrishnanBalagopal could you try the new version of CL https://go.dev/cl/552835 ? Thanks.

Sorry, I went on vacation myself 😅 I will try it tomorrow and update here.

Update 1

@cherrymui I have tried the change and it failed to build the wasm webapp.

  1. Building the patch set 5 Go commit 06039ae75fa4505de13184f520fe1c6bd0bb7bc9
    https://go.googlesource.com/go/+/06039ae75fa4505de13184f520fe1c6bd0bb7bc9
$ go version
go version go1.22.0 darwin/arm64
$ git remote -v
origin	https://go.googlesource.com/go (fetch)
origin	https://go.googlesource.com/go (push)
$ git log
commit 06039ae75fa4505de13184f520fe1c6bd0bb7bc9 (HEAD -> change-552835, tag: change-patchset-5)
Author: Cherry Mui <cherryyz@google.com>
Date:   Tue Dec 26 15:35:56 2023 -0500

    cmd/link, runtime: put only function index in method table and func table
.................
$ cd src/ && ./make.bash 
Building Go cmd/dist using /opt/homebrew/Cellar/go/1.22.0/libexec. (go1.22.0 darwin/arm64)
Building Go toolchain1 using /opt/homebrew/Cellar/go/1.22.0/libexec.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/arm64.
---
Installed Go for darwin/arm64 in /Users/haribala/Documents/code/remote/go.googlesource.com/go
Installed commands in /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin
*** You need to add /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin to your PATH.
  1. Building the wasm webapp using the same commit 95c7fb33c04bb31d3d5e25a8553930693de86194
    https://github.com/HarikrishnanBalagopal/move2kube/tree/95c7fb33c04bb31d3d5e25a8553930693de86194
$ /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin/go version
go version devel go1.23-06039ae75f Thu Feb 15 13:53:32 2024 -0500 darwin/arm64
$ git log
commit 95c7fb33c04bb31d3d5e25a8553930693de86194 (HEAD -> feat/starlark, origin/feat/starlark)
Author: Harikrishnan Balagopal <harikrishmenon@gmail.com>
Date:   Tue Dec 26 15:04:57 2023 +0530

    feat: add the starlark transformer
.................
$ CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin/go build -ldflags ' -X github.com/konveyor/move2kube-wasm/types/info.buildmetadata=unreleased -X github.com/konveyor/move2kube-wasm/types/info.gitCommit=95c7fb33c04bb31d3d5e25a8553930693de86194 -X github.com/konveyor/move2kube-wasm/types/info.gitTreeState=clean' -o "./bin/move2kube.wasm" .
# github.com/konveyor/move2kube-wasm
github.com/mholt/archiver/v3.(*Rar).Close.wrapinfo: non-pc-relative relocation R_ADDROFF address for github.com/mholt/archiver/v3.(*Rar).Close is too big: 0x1007b0000
github.com/mholt/archiver/v3.(*Tar).Close.wrapinfo: non-pc-relative relocation R_ADDROFF address for github.com/mholt/archiver/v3.(*Tar).Close is too big: 0x100a80000
github.com/mholt/archiver/v3.(*Zip).Close.wrapinfo: non-pc-relative relocation R_ADDROFF address for github.com/mholt/archiver/v3.(*Zip).Close is too big: 0x101420000
$ echo $?
1

The wasm webapp build fails now.


With the previous change we were able to build the wasm webapp at least #64856 (comment)
and it was failing at runtime.

One difference is that I used go version go1.21.5 darwin/arm64 when building the Go compiler before.
Now I am using go version go1.22.0 darwin/arm64 to build the Go compiler.

Update 2

The new changed Go compiler 06039ae75fa4505de13184f520fe1c6bd0bb7bc9 is able to build the parent commit which doesn't have the Starlark library and all the new functions that it brings in
https://github.com/HarikrishnanBalagopal/move2kube/tree/dec9d8da6e5f8882aacb46a8e5f784b96b42a3c6

$ CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin/go build -ldflags ' -X github.com/konveyor/move2kube-wasm/types/info.buildmetadata=unreleased -X github.com/konveyor/move2kube-wasm/types/info.gitCommit=dec9d8da6e5f8882aacb46a8e5f784b96b42a3c6 -X github.com/konveyor/move2kube-wasm/types/info.gitTreeState=clean' -o "./bin/move2kube.wasm" .
$ echo $?
0

Update 3

@cherrymui I think there's a regression with v1.22.0 of Golang #65786

@HarikrishnanBalagopal
Copy link
Author

@cherrymui Please let me know if you need any more details.

@cherrymui
Copy link
Member

@HarikrishnanBalagopal thanks for the update. Could you try the latest version of CL https://go.dev/cl/552835 ? Thanks.

@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Feb 28, 2024

Update 1

Tested patchset 7 commit 21cb3991a2076762670019b4e3c808ca38428281 of Go compiler

$ go version
go version go1.21.7 darwin/arm64
$ git remote -v
origin	https://go.googlesource.com/go (fetch)
origin	https://go.googlesource.com/go (push)
$ git log
commit 21cb3991a2076762670019b4e3c808ca38428281 (HEAD -> patchset-7)
Author: Cherry Mui <cherryyz@google.com>
Date:   Tue Dec 26 15:35:56 2023 -0500

    cmd/link, runtime: on Wasm, put only function index in method table and func table
    
    In the type descriptor's method table, it contains relative PCs of
    the methods (relative to the start of the text section) stored as
    32-bit offsets. On Wasm, a PC is PC_F<<16 + PC_B, where PC_F is
    the function index, and PC_B is the block index. When there are
    more than 65536 functions, the PC will not fit into 32-bit (and
    relative to the section start doesn't help). Since there are no
    more bits for the function index, and the method table always
    targets the entry of a method, we put just the PC_F there, and
    rewrite back to a full PC at run time when we need the PC. This
    way we can have more than 65536 functions.
    
    The func table also contains 32-bit relative PCs, and it also
    always points to function entries. Do the same there, as well
    as other places where we use relative text offsets.
    
    Also add the relocation type in the relocation overflow error
    message.
    
    Also add check for function too big on Wasm. If a function has
    more than 65536 blocks, PC_B will overflow and PC = PC_F<<16 + PC_B
    will points to the wrong function.
    
    Fixes #64856.
    
    Change-Id: If9c307e9fb1641f367a5f19c39f88f455805d0bb
................
$ git status
On branch patchset-7
nothing to commit, working tree clean
$ cd src/ && ./make.bash 
Building Go cmd/dist using /opt/homebrew/Cellar/go@1.21/1.21.7/libexec. (go1.21.7 darwin/arm64)
Building Go toolchain1 using /opt/homebrew/Cellar/go@1.21/1.21.7/libexec.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/arm64.
---
Installed Go for darwin/arm64 in /Users/haribala/Documents/code/remote/go.googlesource.com/go
Installed commands in /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin
*** You need to add /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin to your PATH.
$ echo $?
0

Building the wasm webapp

$ /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin/go version
go version devel go1.23-21cb3991a2 Wed Feb 28 15:05:12 2024 -0500 darwin/arm64
$ git log
commit 95c7fb33c04bb31d3d5e25a8553930693de86194 (HEAD, origin/feat/starlark, feat/starlark)
Author: Harikrishnan Balagopal <harikrishmenon@gmail.com>
Date:   Tue Dec 26 15:04:57 2023 +0530

    feat: add the starlark transformer
    
    chore: update dependencies
    fix: issue with string not implementing a starlark interface
    
    Signed-off-by: Harikrishnan Balagopal <harikrishmenon@gmail.com>
.......................
$ CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin/go build -ldflags ' -X github.com/konveyor/move2kube-wasm/types/info.buildmetadata=unreleased -X github.com/konveyor/move2kube-wasm/types/info.gitCommit=95c7fb33c04bb31d3d5e25a8553930693de86194 -X github.com/konveyor/move2kube-wasm/types/info.gitTreeState=clean' -o "./bin/move2kube.wasm" .
$ echo $?
0

Update 2

At runtime there is an error

worker: the wasm module finished with exit code: RuntimeError: null function or function signature mismatch
    at runtime.doInit1 (17bc6346:0x106356)
    at runtime.main (17bc6346:0xe2173)
    at wasm_pc_f_loop (17bc6346:0x166360)
    at _rt0_wasm_wasip1 (17bc6346:0x1663f8)
    at WASI.start (wasi.js:1:122)
    at processMessage (worker.js:84:1)

Update 3

The runtime error is on the call_indirect wasm instruction.
There's a lot of indentation so you have to scroll to see the code.

                                        end
                                                                                                                                  local.get $var2
                                                                                                                                  global.set $global1
                                                                                                                                  local.get $var2
                                                                                                                                  i32.wrap_i64
                                                                                                                                  i64.load
                                                                                                                                  local.get $var1
                                                                                                                                  i32.const 8
                                                                                                                                  i32.sub
                                                                                                                                  local.tee $var1
                                                                                                                                  global.set $global0
                                                                                                                                  local.get $var1
                                                                                                                                  i64.const 338362393
                                                                                                                                  i64.store
                                                                                                                                  i32.wrap_i64
                                                                                                                                  i32.const 16
                                                                                                                                  i32.shr_u
                                                                                                                                  local.set $var0
                                                                                                                                  i32.const 0
                                                                                                                                  local.get $var0
                                                                                                                                  call_indirect (param i32) (result i32)
                                                                                                                                  global.get $global0
                                                                                                                                  local.set $var1
                                                                                                                                  br_if $label71
                                                                                                                                end $label10

@cherrymui This line call_indirect (param i32) (result i32)

Here is the compiled wasm file (gzipped) btw
move2kube.wasm.gz

Update 4

The exact same runtime error occurs with the wasm branch of my webapp commit 8b309cad0a4657aa570797b91b23260aee4984c1 https://github.com/konveyor/move2kube/tree/8b309cad0a4657aa570797b91b23260aee4984c1
The error is again on the call_indirect (param i32) (result i32) line.

Since the 8b309cad0a4657aa570797b91b23260aee4984c1 commit compiles and runs correctly with the normal Go compiler go version go1.21.7 darwin/arm64 I think this is a regression. You can see it running here https://move2kube.konveyor.io/experimental

@gopherbot
Copy link

Change https://go.dev/cl/567896 mentions this issue: cmd/internal/obj/wasm: use 64-bit instructions for indirect calls

@cherrymui
Copy link
Member

Thanks for the update.

i32.wrap_i64
i32.const 16
i32.shr_u
...
call_indirect (param i32) (result i32)

The problem is this code: we extract the function index from the "PC". But we first truncate it to 32-bit then shift by 16 bits, so we only have 16 bits for the function index, which overflows. The fix is to do the shift first, then truncate. Wrote CL https://go.dev/cl/567896 for this.

Could you try CL https://go.dev/cl/567896 and CL https://go.dev/cl/552835 together? You'll need both CLs. The easiest way is to check out the latter git fetch https://go.googlesource.com/go refs/changes/35/552835/8 && git checkout FETCH_HEAD.

@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Mar 17, 2024

Thanks for the update.

i32.wrap_i64
i32.const 16
i32.shr_u
...
call_indirect (param i32) (result i32)

The problem is this code: we extract the function index from the "PC". But we first truncate it to 32-bit then shift by 16 bits, so we only have 16 bits for the function index, which overflows. The fix is to do the shift first, then truncate. Wrote CL https://go.dev/cl/567896 for this.

Could you try CL https://go.dev/cl/567896 and CL https://go.dev/cl/552835 together? You'll need both CLs. The easiest way is to check out the latter git fetch https://go.googlesource.com/go refs/changes/35/552835/8 && git checkout FETCH_HEAD.

I was OOF past weeks, I will be back next week. Will try the change and post an update in the next few days.

@HarikrishnanBalagopal
Copy link
Author

HarikrishnanBalagopal commented Mar 28, 2024

@cherrymui Sorry for the late reply, been a bit busy with work.

I have tried the commit and it's failing with a panic.

Golang repo

$ git status
On branch feat/test28march
nothing to commit, working tree clean
$ git log
commit 72a51bd9fed870a8e9f10a1aad80c2720dedded6 (HEAD -> feat/test28march)
Author: Cherry Mui <cherryyz@google.com>
Date:   Tue Dec 26 15:35:56 2023 -0500

    cmd/link, runtime: on Wasm, put only function index in method table and func table
    
    In the type descriptor's method table, it contains relative PCs of
    the methods (relative to the start of the text section) stored as
........................................

$ cd src/ && ./make.bash
Building Go cmd/dist using /opt/homebrew/Cellar/go@1.21/1.21.7/libexec. (go1.21.7 darwin/arm64)
Building Go toolchain1 using /opt/homebrew/Cellar/go@1.21/1.21.7/libexec.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for darwin/arm64.
---
Installed Go for darwin/arm64 in /Users/haribala/Documents/code/remote/go.googlesource.com/go
Installed commands in /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin
*** You need to add /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin to your PATH.
$ echo $?
0
$ cd ..
$ ./bin/go version
go version devel go1.23-72a51bd9fe Thu Feb 29 14:39:12 2024 -0500 darwin/arm64

Move2Kube repo

$ git status
On branch feat/starlark
Your branch is up to date with 'origin/feat/starlark'.

nothing to commit, working tree clean
$ git log
commit 95c7fb33c04bb31d3d5e25a8553930693de86194 (HEAD -> feat/starlark, origin/feat/starlark)
Author: Harikrishnan Balagopal <harikrishmenon@gmail.com>
Date:   Tue Dec 26 15:04:57 2023 +0530

    feat: add the starlark transformer
    
    chore: update dependencies
...................................
$ CGO_ENABLED=0 GOOS=wasip1 GOARCH=wasm /Users/haribala/Documents/code/remote/go.googlesource.com/go/bin/go build -ldflags ' -X github.com/konveyor/move2kube-wasm/types/info.buildmetadata=unreleased -X github.com/konveyor/move2kube-wasm/types/info.gitCommit=95c7fb33c04bb31d3d5e25a8553930693de86194 -X github.com/konveyor/move2kube-wasm/types/info.gitTreeState=clean' -o "./bin/move2kube.wasm" .

Move2Kube WASM output

fatal error: index out of range

runtime stack:
runtime.throw({0x49a3eb, 0x12})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1021 +0x3 fp=0x27ec288 sp=0x27ec260 pc=0x13720003
runtime.panicCheck1(0x14940026, {0x49a3eb, 0x12})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:64 +0x6 fp=0x27ec2a0 sp=0x27ec288 pc=0x134f0006
runtime.goPanicIndex(0x167e7, 0xf264)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:113 +0x2 fp=0x27ec2d8 sp=0x27ec2a0 pc=0x13510002
runtime.findfunc(0x102600017)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:806 +0x26 fp=0x27ec2f0 sp=0x27ec2d8 pc=0x14940026
runtime.(*unwinder).next(0x27ec528)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:449 +0x8 fp=0x27ec360 sp=0x27ec2f0 pc=0x15180008
runtime.tracebackPCs(0x27ec528, 0x4, {0x3b42be8, 0x20, 0x20})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:622 +0x3 fp=0x27ec4f8 sp=0x27ec360 pc=0x151c0003
runtime.callers.func1()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:1098 +0x3 fp=0x27ec5b8 sp=0x27ec4f8 pc=0x152b0003
runtime.systemstack(0x27ec5c8)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:172 +0x3 fp=0x27ec5c0 sp=0x27ec5b8 pc=0x16140003
runtime.mstart()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:29 +0x1 fp=0x27ec5c8 sp=0x27ec5c0 pc=0x16100001

goroutine 1 gp=0x38001c0 m=0 mp=0x278fe80 [running]:
runtime.systemstack_switch()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:183 +0x1 fp=0x3b42b48 sp=0x3b42b40 pc=0x16150001
runtime.callers(0x4, {0x3b42be8, 0x20, 0x20})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:1095 +0x2 fp=0x3b42ba8 sp=0x3b42b48 pc=0x152a0002
runtime.mProf_Malloc(0x437c000, 0x8000)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mprof.go:427 +0x2 fp=0x3b42d28 sp=0x3b42ba8 pc=0x12e90002
runtime.profilealloc(0x278fe80, 0x437c000, 0x8000)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/malloc.go:1426 +0x18 fp=0x3b42d48 sp=0x3b42d28 pc=0x11a20018
runtime.mallocgc(0x8000, 0x1b2d60, 0x1)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/malloc.go:1267 +0xce fp=0x3b42dd0 sp=0x3b42d48 pc=0x119d00ce
runtime.makeslice(0x1b2d60, 0x8000, 0x8000)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/slice.go:107 +0x12 fp=0x3b42df8 sp=0x3b42dd0 pc=0x145e0012
io.copyBuffer({0x7993b8, 0x3849b70}, {0x3e29fd8, 0x3a81870}, {0x0, 0x0, 0x0})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/io/io.go:426 +0x17 fp=0x3b42e80 sp=0x3b42df8 pc=0x178b0017
io.Copy(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/io/io.go:388 pc=0x1a220005
os.genericReadFrom(0x3849b68, {0x3e29fd8, 0x3a81870})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/os/file.go:179 +0x3 fp=0x3b42ee0 sp=0x3b42e80 pc=0x1a220003
os.(*File).ReadFrom(0x3849b68, {0x3e29fd8, 0x3a81870})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/os/file.go:155 +0xc fp=0x3b42f18 sp=0x3b42ee0 pc=0x1a20000c
io.copyBuffer({0x7991b8, 0x3849b68}, {0x3e29fd8, 0x3a81870}, {0x0, 0x0, 0x0})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/io/io.go:415 +0x1e fp=0x3b42fa0 sp=0x3b42f18 pc=0x178b001e
io.Copy(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/io/io.go:388 pc=0x4f37002e
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7c40}, {0x39eb590, 0x4d}, {0x40d8c40, 0x70}, 0x3b4ced0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:556 +0x2c fp=0x3b43188 sp=0x3b42fa0 pc=0x4f37002c
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7c40}, {0x39469c0, 0x3c}, {0x40f2ae0, 0x5f}, 0x3b4ced0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:575 +0x8a fp=0x3b43370 sp=0x3b43188 pc=0x4f37008a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7c40}, {0x39468c0, 0x31}, {0x40f27e0, 0x54}, 0x3b4ced0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:575 +0x8a fp=0x3b43558 sp=0x3b43370 pc=0x4f37008a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7c40}, {0x3a8a9c0, 0x29}, {0x39ea7d0, 0x4c}, 0x3b4ced0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:575 +0x8a fp=0x3b43740 sp=0x3b43558 pc=0x4f37008a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7c40}, {0x40805a0, 0x15}, {0x383c340, 0x38}, 0x3b4ced0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:575 +0x8a fp=0x3b43928 sp=0x3b43740 pc=0x4f37008a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7c40}, {0x380cbd0, 0x8}, {0x3a8a7e0, 0x2b}, 0x3b4ced0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:575 +0x8a fp=0x3b43b10 sp=0x3b43928 pc=0x4f37008a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7c40}, {0x7904b8, 0x1}, {0x3a8a720, 0x22}, 0x3b4ced0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:575 +0x8a fp=0x3b43cf8 sp=0x3b43b10 pc=0x4f37008a
github.com/konveyor/move2kube-wasm/common.CreateAssetsData({0x7c7c40}, 0x3b4ced0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:529 +0x44 fp=0x3b43e50 sp=0x3b43cf8 pc=0x4f360044
fatal error: index out of range
panic during panic

runtime stack:
runtime.throw({0x49a3eb, 0x12})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1021 +0x3 fp=0x27ebb40 sp=0x27ebb18 pc=0x13720003
runtime.panicCheck1(0x14940026, {0x49a3eb, 0x12})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:64 +0x6 fp=0x27ebb58 sp=0x27ebb40 pc=0x134f0006
runtime.goPanicIndex(0x167e7, 0xf264)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:113 +0x2 fp=0x27ebb90 sp=0x27ebb58 pc=0x13510002
runtime.findfunc(0x102600017)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:806 +0x26 fp=0x27ebba8 sp=0x27ebb90 pc=0x14940026
runtime.(*unwinder).next(0x27ebf60)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:449 +0x8 fp=0x27ebc18 sp=0x27ebba8 pc=0x15180008
runtime.traceback2(0x27ebf60, 0x0, 0x0, 0x1e)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:963 +0x9 fp=0x27ebe78 sp=0x27ebc18 pc=0x15260009
runtime.traceback1.func1(0x0)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:899 +0x3 fp=0x27ebf38 sp=0x27ebe78 pc=0x15250003
runtime.traceback1(0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x38001c0, 0x0)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:922 +0x31 fp=0x27ec138 sp=0x27ebf38 pc=0x15240031
runtime.traceback(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:799 pc=0x1531000d
runtime.tracebackothers(0x278f420)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:1251 +0xb fp=0x27ec198 sp=0x27ec138 pc=0x1531000b
runtime.dopanic_m(0x278f420, 0x13720003, 0x27ec260)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1343 +0x2d fp=0x27ec1e8 sp=0x27ec198 pc=0x137c002d
runtime.fatalthrow.func1()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1197 +0x3 fp=0x27ec228 sp=0x27ec1e8 pc=0x13780003
runtime.fatalthrow(0x2)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1190 +0x6 fp=0x27ec260 sp=0x27ec228 pc=0x13770006
runtime.throw({0x49a3eb, 0x12})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1021 +0x3 fp=0x27ec288 sp=0x27ec260 pc=0x13720003
runtime.panicCheck1(0x14940026, {0x49a3eb, 0x12})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:64 +0x6 fp=0x27ec2a0 sp=0x27ec288 pc=0x134f0006
runtime.goPanicIndex(0x167e7, 0xf264)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:113 +0x2 fp=0x27ec2d8 sp=0x27ec2a0 pc=0x13510002
runtime.findfunc(0x102600017)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:806 +0x26 fp=0x27ec2f0 sp=0x27ec2d8 pc=0x14940026
runtime.(*unwinder).next(0x27ec528)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:449 +0x8 fp=0x27ec360 sp=0x27ec2f0 pc=0x15180008
runtime.tracebackPCs(0x27ec528, 0x4, {0x3b42be8, 0x20, 0x20})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:622 +0x3 fp=0x27ec4f8 sp=0x27ec360 pc=0x151c0003
runtime.callers.func1()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:1098 +0x3 fp=0x27ec5b8 sp=0x27ec4f8 pc=0x152b0003
runtime.systemstack(0x27ec5c8)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:172 +0x3 fp=0x27ec5c0 sp=0x27ec5b8 pc=0x16140003
runtime.mstart()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:29 +0x1 fp=0x27ec5c8 sp=0x27ec5c0 pc=0x16100001

Move2Kube Code

The panic seems to be on the io.Copy https://github.com/HarikrishnanBalagopal/move2kube/blob/95c7fb33c04bb31d3d5e25a8553930693de86194/common/utils.go#L556

Update

It fails with a panic even with a simple move2kube version -l command. The io.Copy succeeds multiple times before failing

time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf180} f &{f:0x7c7d48 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf300} f &{f:0x7c7d78 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf380} f &{f:0x7c7da8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf400} f &{f:0x7c7dd8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf480} f &{f:0x7c7e08 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf580} f &{f:0x7c7f88 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf600} f &{f:0x7c7fb8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf680} f &{f:0x7c7f58 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf700} f &{f:0x7c8078 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf780} f &{f:0x7c80a8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf800} f &{f:0x7c8138 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf880} f &{f:0x7c8168 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf900} f &{f:0x7c8198 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbf980} f &{f:0x7c81c8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbfa80} f &{f:0x7c8108 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbfb00} f &{f:0x7c8408 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbfb80} f &{f:0x7c8498 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbfc00} f &{f:0x7c8468 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbfc80} f &{f:0x7c8558 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbfd00} f &{f:0x7c8588 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbfd80} f &{f:0x7c8528 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbfe00} f &{f:0x7c87f8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbfe80} f &{f:0x7c8828 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x3bbff00} f &{f:0x7c88b8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e180} f &{f:0x7c8888 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e200} f &{f:0x7c8948 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e280} f &{f:0x7c8918 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e300} f &{f:0x7c89d8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e380} f &{f:0x7c89a8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e400} f &{f:0x7c8a68 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e480} f &{f:0x7c8a38 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e500} f &{f:0x7c8a98 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e580} f &{f:0x7c8b28 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e600} f &{f:0x7c8af8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e680} f &{f:0x7c8bb8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e700} f &{f:0x7c8b88 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e780} f &{f:0x7c8be8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e800} f &{f:0x7c8c18 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e880} f &{f:0x7c8c48 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e900} f &{f:0x7c8c78 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387e980} f &{f:0x7c8d08 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387ea00} f &{f:0x7c8cd8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387ea80} f &{f:0x7c8d98 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387eb00} f &{f:0x7c8d68 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387eb80} f &{f:0x7c8e28 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387ed80} f &{f:0x7c8df8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387ee00} f &{f:0x7c8eb8 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387ee80} f &{f:0x7c8e88 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x387ef00} f &{f:0x7c8f48 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x436a000} f &{f:0x7c8f18 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x436a080} f &{f:0x7c9038 offset:0}"
time="2024-03-29T09:56:18Z" level=info msg="DEBUG! just before io.Copy df: &{file:0x436a100} f &{f:0x7c90c8 offset:0}"
fatal error: index out of range

runtime stack:
runtime.throw({0x49a3eb, 0x12})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1021 +0x3 fp=0x27ec288 sp=0x27ec260 pc=0x13720003
runtime.panicCheck1(0x14940026, {0x49a3eb, 0x12})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:64 +0x6 fp=0x27ec2a0 sp=0x27ec288 pc=0x134f0006
runtime.goPanicIndex(0x9cfa1, 0xf264)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:113 +0x2 fp=0x27ec2d8 sp=0x27ec2a0 pc=0x13510002
runtime.findfunc(0x102600017)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:806 +0x26 fp=0x27ec2f0 sp=0x27ec2d8 pc=0x14940026
runtime.(*unwinder).next(0x27ec528)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:449 +0x8 fp=0x27ec360 sp=0x27ec2f0 pc=0x15180008
runtime.tracebackPCs(0x27ec528, 0x4, {0x3b42900, 0x20, 0x20})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:622 +0x3 fp=0x27ec4f8 sp=0x27ec360 pc=0x151c0003
runtime.callers.func1()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:1098 +0x3 fp=0x27ec5b8 sp=0x27ec4f8 pc=0x152b0003
runtime.systemstack(0x27ec5c8)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:172 +0x3 fp=0x27ec5c0 sp=0x27ec5b8 pc=0x16140003
runtime.mstart()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:29 +0x1 fp=0x27ec5c8 sp=0x27ec5c0 pc=0x16100001

goroutine 1 gp=0x38001c0 m=0 mp=0x278fe80 [running]:
runtime.systemstack_switch()

Update 2

@cherrymui I managed to get an error about an invalid symbol table

runtime: invalid pc-encoded table f=internal/abi.(*PtrType).StructType pc=0x10bc0008 targetpc=0x102600017 tab=[0/0]0x0
        value=0 until pc=0x10bc0008
fatal error: invalid runtime symbol table

Full log

time="2024-03-31T10:49:58Z" level=error msg="CopyEmbedFSToDir source 'built-in/transformers/dockerfilegenerator/rust/templates' dest '/tmp/move2kube2298099505/m2kassets/built-in/transformers/dockerfilegenerator/rust/templates'"
time="2024-03-31T10:49:58Z" level=error msg="CopyEmbedFSToDir source 'built-in/transformers/dockerfilegenerator/rust/templates/Dockerfile' dest '/tmp/move2kube2298099505/m2kassets/built-in/transformers/dockerfilegenerator/rust/templates/Dockerfile'"
time="2024-03-31T10:49:58Z" level=error msg="CopyEmbedFSToDir df &{file:0x3880f00} f &{f:0x7c8fc8 offset:0}"
runtime: invalid pc-encoded table f=internal/abi.(*PtrType).StructType pc=0x10bc0008 targetpc=0x102600017 tab=[0/0]0x0
        value=0 until pc=0x10bc0008
fatal error: invalid runtime symbol table

runtime stack:
runtime.throw({0x4ab944, 0x1c})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/panic.go:1021 +0x3 fp=0x27ec1a0 sp=0x27ec178 pc=0x13720003
runtime.pcvalue({0x21eb7c8, 0x26a1700}, 0x425, 0x102600017, 0x1)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:987 +0x81 fp=0x27ec280 sp=0x27ec1a0 pc=0x14950081
runtime.funcspdelta(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/symtab.go:1047 pc=0x15170029
runtime.(*unwinder).resolveInternal(0x27ec528, 0x0, 0x0)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:325 +0x27 fp=0x27ec2f0 sp=0x27ec280 pc=0x15170027
runtime.(*unwinder).next(0x27ec528)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:512 +0x16 fp=0x27ec360 sp=0x27ec2f0 pc=0x15180016
runtime.tracebackPCs(0x27ec528, 0x4, {0x3b40a28, 0x20, 0x20})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:622 +0x3 fp=0x27ec4f8 sp=0x27ec360 pc=0x151c0003
runtime.callers.func1()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:1098 +0x3 fp=0x27ec5b8 sp=0x27ec4f8 pc=0x152b0003
runtime.systemstack(0x27ec5c8)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:172 +0x3 fp=0x27ec5c0 sp=0x27ec5b8 pc=0x16140003
runtime.mstart()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:29 +0x1 fp=0x27ec5c8 sp=0x27ec5c0 pc=0x16100001

goroutine 1 gp=0x38001c0 m=0 mp=0x278fe80 [running]:
runtime.systemstack_switch()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:183 +0x1 fp=0x3b40988 sp=0x3b40980 pc=0x16150001
runtime.callers(0x4, {0x3b40a28, 0x20, 0x20})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/traceback.go:1095 +0x2 fp=0x3b409e8 sp=0x3b40988 pc=0x152a0002
runtime.mProf_Malloc(0x4370000, 0x8000)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mprof.go:427 +0x2 fp=0x3b40b68 sp=0x3b409e8 pc=0x12e90002
runtime.profilealloc(0x278fe80, 0x4370000, 0x8000)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/malloc.go:1426 +0x18 fp=0x3b40b88 sp=0x3b40b68 pc=0x11a20018
runtime.mallocgc(0x8000, 0x1b2d60, 0x1)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/malloc.go:1267 +0xce fp=0x3b40c10 sp=0x3b40b88 pc=0x119d00ce
runtime.makeslice(0x1b2d60, 0x8000, 0x8000)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/slice.go:107 +0x12 fp=0x3b40c38 sp=0x3b40c10 pc=0x145e0012
io.copyBuffer({0x799488, 0x38499b0}, {0x3e29118, 0x436e0c0}, {0x0, 0x0, 0x0})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/io/io.go:426 +0x17 fp=0x3b40cc0 sp=0x3b40c38 pc=0x178b0017
io.Copy(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/io/io.go:388 pc=0x1a220005
os.genericReadFrom(0x38499a8, {0x3e29118, 0x436e0c0})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/os/file.go:179 +0x3 fp=0x3b40d20 sp=0x3b40cc0 pc=0x1a220003
os.(*File).ReadFrom(0x38499a8, {0x3e29118, 0x436e0c0})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/os/file.go:155 +0xc fp=0x3b40d58 sp=0x3b40d20 pc=0x1a20000c
io.copyBuffer({0x799288, 0x38499a8}, {0x3e29118, 0x436e0c0}, {0x0, 0x0, 0x0})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/io/io.go:415 +0x1e fp=0x3b40de0 sp=0x3b40d58 pc=0x178b001e
io.Copy(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/io/io.go:388 pc=0x4f37003e
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7d20}, {0x39eb5e0, 0x43}, {0x42fca80, 0x66}, 0x3b48ed0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:559 +0x3c fp=0x3b41008 sp=0x3b40de0 pc=0x4f37003c
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7d20}, {0x40f5cc0, 0x38}, {0x42fe7e0, 0x5b}, 0x3b48ed0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:578 +0x9a fp=0x3b41230 sp=0x3b41008 pc=0x4f37009a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7d20}, {0x3a86b40, 0x2e}, {0x42fe6c0, 0x51}, 0x3b48ed0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:578 +0x9a fp=0x3b41458 sp=0x3b41230 pc=0x4f37009a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7d20}, {0x3a869c0, 0x29}, {0x39ea910, 0x4c}, 0x3b48ed0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:578 +0x9a fp=0x3b41680 sp=0x3b41458 pc=0x4f37009a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7d20}, {0x40847c8, 0x15}, {0x383d3c0, 0x38}, 0x3b48ed0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:578 +0x9a fp=0x3b418a8 sp=0x3b41680 pc=0x4f37009a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7d20}, {0x380cb00, 0x8}, {0x3a867e0, 0x2b}, 0x3b48ed0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:578 +0x9a fp=0x3b41ad0 sp=0x3b418a8 pc=0x4f37009a
github.com/konveyor/move2kube-wasm/common.CopyEmbedFSToDir({0x7c7d20}, {0x790580, 0x1}, {0x3a86720, 0x22}, 0x3b48ed0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:578 +0x9a fp=0x3b41cf8 sp=0x3b41ad0 pc=0x4f37009a
github.com/konveyor/move2kube-wasm/common.CreateAssetsData({0x7c7d20}, 0x3b48ed0)
        /Users/haribala/Documents/code/remote/github.com/konveyor/move2kube/common/utils.go:530 +0x44 fp=0x3b41e50 sp=0x3b41cf8 pc=0x4f360044
internal/abi.(*PtrType).StructType(0x3b48ed000)
        ?:0 +0xf1a40017 fp=0x3b41e57 sp=0x3b41e50 pc=0x102600017
knative.dev/serving/pkg/apis/serving/v1.(*Revision).GetObjectKind(0x1a800000)
        ?:0 +0x2000 fp=0x3b41e5e sp=0x3b41e57 pc=0x7c7d2000
runtime: g 1: unexpected return pc for knative.dev/serving/pkg/apis/serving/v1.(*Revision).GetObjectKind called from 0x3b48ed00000
stack: frame={sp:0x3b41e57, fp:0x3b41e5e} stack=[0x3b32000,0x3b42000)
0x0000000003b41d57:  0x00000003b41e8000  0x0000003a34005c00 
0x0000000003b41d67:  0x0000000000002200  0x0000000000001800 
0x0000000003b41d77:  0x0000000000001800  0x000000038493a800 
0x0000000003b41d87:  0x0000000408452800  0x0000000000010100 
0x0000000003b41d97:  0x0000000377010800  0x00000000001a8000 
0x0000000003b41da7:  0x0000000278fe8000  0x000000040e000000 
0x0000000003b41db7:  0x00000003bd48c000  0x000000001947e000 <sort.(*reverse).Less+0x000000000000e000> 
0x0000000003b41dc7:  0x000000038493a800  0x0000000408452800 
0x0000000003b41dd7:  0x0000000000001800  0x0000000048cddc00 <golang.org/x/net/http2.(*ClientConn).Shutdown.func1+0x000000000000dc00> 
0x0000000003b41de7:  0x0000000000000900  0x000000040e000000 
0x0000000003b41df7:  0x000000038fa40000  0x000000040e000000 
0x0000000003b41e07:  0x000000147f000800  0x0000003a35000000 
0x0000000003b41e17:  0x00000003b5e00800  0x0000003a36000000 
0x0000000003b41e27:  0x00000003b41e8000  0x00000003a8672000 
0x0000000003b41e37:  0x0000000408454000  0x0000000408452800 
0x0000000003b41e47:  0x0000010260001700  0x000000007c7d2000 <knative.dev/serving/pkg/apis/serving/v1.(*Revision).GetObjectKind+0x0000000000002000> 
0x0000000003b41e57: <0x00000003b48ed000  0x00000000001a8000 
0x0000000003b41e67:  0x000000001947e000 <sort.(*reverse).Less+0x000000000000e000>  0x000000038493a800 
0x0000000003b41e77:  0x00000000001a0000  0x0000000000000000 
0x0000000003b41e87:  0x0000000000000000  0x0000000000000000 
0x0000000003b41e97:  0x0000000000000000  0x0000000377bc0000 
0x0000000003b41ea7:  0x0000000000000100  0x0100000000000000 
0x0000000003b41eb7:  0x6000000101010001  0x0000000377bc5800 
0x0000000003b41ec7:  0x000000038d5b0800  0x0000000377010800 
0x0000000003b41ed7:  0x0000000000006000  0x0000000278fe8000 
0x0000000003b41ee7:  0x0000000386600000  0x0000000000000000 
0x0000000003b41ef7:  0x000000114f004000  0x0000000386605800 
0x0000000003b41f07:  0x0000000000000000  0x0000000000000000 
0x0000000003b41f17:  0x0000000000000000  0x0000001209010100 
0x0000000003b41f27:  0x0000000386600000  0x0000000386605800 
0x0000000003b41f37:  0x0000000000000000  0x000000001b30e000 <strings.TrimRight+0x000000000000e000> 
0x0000000003b41f47:  0x000000038493a800  0x0000000000000000 
0x0000000003b41f57:  0x0000000000000000 

goroutine 2 gp=0x3800380 m=nil [force gc (idle)]:
runtime.gopark(0x5a5838, 0x2783d60, 0x11, 0xa, 0x1)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:402 +0x22 fp=0x385cfb0 sp=0x385cf88 pc=0x139a0022
runtime.goparkunlock(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:408 pc=0x1397001b
runtime.forcegchelper()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:326 +0x19 fp=0x385cfe0 sp=0x385cfb0 pc=0x13970019
runtime.goexit({})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:434 +0x1 fp=0x385cfe8 sp=0x385cfe0 pc=0x163f0001
created by runtime.init.5 in goroutine 1
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:314 +0x2

goroutine 3 gp=0x3800540 m=nil [runnable]:
runtime.gopark(0x5a5838, 0x2785840, 0xc, 0x9, 0x1)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:402 +0x22 fp=0x385d790 sp=0x385d768 pc=0x139a0022
runtime.goparkunlock(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:408 pc=0x1288000c
runtime.bgsweep(0x3860000)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgcsweep.go:278 +0xa fp=0x385d7d0 sp=0x385d790 pc=0x1288000a
runtime.gcenable.gowrap1()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgc.go:203 +0x2 fp=0x385d7e0 sp=0x385d7d0 pc=0x120b0002
runtime.goexit({})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:434 +0x1 fp=0x385d7e8 sp=0x385d7e0 pc=0x163f0001
created by runtime.gcenable in goroutine 1
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgc.go:203 +0x6

goroutine 4 gp=0x3800700 m=nil [runnable]:
runtime.gopark(0x5a5838, 0x278eb40, 0xd, 0xa, 0x2)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:402 +0x22 fp=0x385df80 sp=0x385df58 pc=0x139a0022
runtime.goparkunlock(...)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:408 pc=0x1265000c
runtime.(*scavengerState).park(0x278eb40)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgcscavenge.go:425 +0xa fp=0x385dfa8 sp=0x385df80 pc=0x1265000a
runtime.bgscavenge(0x3860000)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgcscavenge.go:653 +0x4 fp=0x385dfd0 sp=0x385dfa8 pc=0x126a0004
runtime.gcenable.gowrap2()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgc.go:204 +0x2 fp=0x385dfe0 sp=0x385dfd0 pc=0x120a0002
runtime.goexit({})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:434 +0x1 fp=0x385dfe8 sp=0x385dfe0 pc=0x163f0001
created by runtime.gcenable in goroutine 1
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgc.go:204 +0xa

goroutine 5 gp=0x38008c0 m=nil [finalizer wait]:
runtime.gopark(0x5a5590, 0x27e1bf8, 0x10, 0xa, 0x1)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:402 +0x22 fp=0x385c710 sp=0x385c6e8 pc=0x139a0022
runtime.runfinq()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mfinal.go:194 +0x1c fp=0x385c7e0 sp=0x385c710 pc=0x1201001c
runtime.goexit({})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:434 +0x1 fp=0x385c7e8 sp=0x385c7e0 pc=0x163f0001
created by runtime.createfing in goroutine 1
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mfinal.go:164 +0xc

goroutine 6 gp=0x3b9f340 m=nil [GC worker (idle)]:
runtime.gopark(0x5a55b0, 0x3b317e0, 0x1a, 0xa, 0x0)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/proc.go:402 +0x22 fp=0x385e738 sp=0x385e710 pc=0x139a0022
runtime.gcBgMarkWorker(0x3866fc0)
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgc.go:1333 +0x1f fp=0x385e7d0 sp=0x385e738 pc=0x121f001f
runtime.gcBgMarkStartWorkers.gowrap1()
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgc.go:1249 +0x2 fp=0x385e7e0 sp=0x385e7d0 pc=0x121e0002
runtime.goexit({})
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/asm_wasm.s:434 +0x1 fp=0x385e7e8 sp=0x385e7e0 pc=0x163f0001
created by runtime.gcBgMarkStartWorkers in goroutine 1
        /Users/haribala/Documents/code/remote/go.googlesource.com/go/src/runtime/mgc.go:1249 +0x28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly issues compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Status: In Progress
Development

No branches or pull requests

7 participants