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

Panic building WASM target when using embed.FS #4511

Open
samuel opened this issue Oct 9, 2024 · 0 comments
Open

Panic building WASM target when using embed.FS #4511

samuel opened this issue Oct 9, 2024 · 0 comments

Comments

@samuel
Copy link
Contributor

samuel commented Oct 9, 2024

I'm getting a panic in interpreter.go when using TinyGo to compile to the WASM target with embed.FS.

A small test case that triggers the issue: https://github.com/samuel/tinygo-embed-panic

When I try to build using TinyGo 0.330 on macOS installed through Homebrew:

$ tinygo version
tinygo version 0.33.0 darwin/arm64 (using go version go1.23.2 and LLVM version 18.1.2)

$ tinygo build -o bug.wasm -target wasm                             
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x38 pc=0x102902fd8]

goroutine 32 [running]:
github.com/tinygo-org/tinygo/interp.(*runner).run(0x140023300a0, 0x14001fa5680, {0x14002181e90, 0x6, 0x14001dcd650?}, 0x140036a0150, {0x140028ff0f0, 0x10})
        /Users/runner/work/tinygo/tinygo/interp/interpreter.go:361 +0x3448
github.com/tinygo-org/tinygo/interp.(*runner).run(0x140023300a0, 0x14001fa55e0, {0x140020f3e10, 0x3, 0x14002984198?}, 0x140040aab70, {0x140028afdf0, 0xc})
        /Users/runner/work/tinygo/tinygo/interp/interpreter.go:552 +0x673c
github.com/tinygo-org/tinygo/interp.(*runner).run(0x140023300a0, 0x14001fa46e0, {0x14004371590, 0x1, 0x1084d0f40?}, 0x14003fced80, {0x14002d211e8, 0x8})
        /Users/runner/work/tinygo/tinygo/interp/interpreter.go:552 +0x673c
github.com/tinygo-org/tinygo/interp.(*runner).run(0x140023300a0, 0x14001fa4690, {0x0, 0x0, 0x0?}, 0x0, {0x106d42c1f, 0x4})
        /Users/runner/work/tinygo/tinygo/interp/interpreter.go:552 +0x673c
github.com/tinygo-org/tinygo/interp.Run({0x14001476df8?}, 0x102943a7c?, 0x30?)
        /Users/runner/work/tinygo/tinygo/interp/interp.go:117 +0x4dc
github.com/tinygo-org/tinygo/builder.optimizeProgram({0x14001476e50?}, 0x140001cac00, 0x140001dec60)
        /Users/runner/work/tinygo/tinygo/builder/build.go:1108 +0x3c
github.com/tinygo-org/tinygo/builder.Build.func5(0x1400146cc00?)
        /Users/runner/work/tinygo/tinygo/builder/build.go:582 +0x4b0
github.com/tinygo-org/tinygo/builder.runJob(0x1400146cc60, 0x140035fe000)
        /Users/runner/work/tinygo/tinygo/builder/jobs.go:222 +0x48
created by github.com/tinygo-org/tinygo/builder.runJobs in goroutine 1
        /Users/runner/work/tinygo/tinygo/builder/jobs.go:123 +0x43c

If I remove the line _, _ = io.ReadAll(f) it succeeds but I'm not sure that's the real issue as in a larger codebase where I experienced this the problem would come and go based on other code changes (even just having another case statement could cause it).

@samuel samuel changed the title Panic when using embed.FS Panic building WASM target when using embed.FS Oct 9, 2024
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