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

Spin Apps trap at runtime when build with TinyGo 0.35.0 #10

Closed
ThorstenHans opened this issue Jan 14, 2025 · 7 comments
Closed

Spin Apps trap at runtime when build with TinyGo 0.35.0 #10

ThorstenHans opened this issue Jan 14, 2025 · 7 comments

Comments

@ThorstenHans
Copy link

I've installed tinygo using Homebrew on my Apple Silicon Mac.

As the tap is not versioned, I recently updated all my installed formulas (including tinygo) which results in me having 0.35.0 right now.

Although I could compile different Spin apps without any error, every app traps at runtime - when receiving incoming HTTP requests - and I receive the following error:

spin build

Building component hello-spin with `tinygo build -target=wasi -gc=leaking -no-debug -o main.wasm main.go`

Finished building all Spin components

demos/hello-spin via 🐹 1.23.4 💫 Spin 3.1.2 took 8s

spin up

Logging component stdio to ".spin/logs/"

Serving http://127.0.0.1:3000
Available Routes:
  hello-spin: http://127.0.0.1:3000 (wildcard)
2025-01-14T18:11:22.335465Z ERROR spin_trigger_http::server: Error processing request: error while executing at wasm backtrace:
    0: 0x2b7d4 - main!canonical_abi_realloc
    1: 0x38a9b - wit-component:adapter:wasi_snapshot_preview1!allocate_stack
    2: 0x35fb7 - wit-component:adapter:wasi_snapshot_preview1!cabi_export_realloc

Caused by:
    wasm trap: wasm `unreachable` instruction executed

Steps to repro

  • Install tinygo 0.35.0
  • Create a new Spin app (spin new -t http-go -a hello-spin) or take an existing Spin app created using the http-go template (haven't tested other triggers
  • Compile the Spin app down to Wasm (spin b)
  • Run the Spin app (spin up)
  • Send an HTTP request to the Spin app (curl localhost:3000/)
    • curl won't receive anything and the spin process should display an error similar to the one shown above

Workaround

I uninstalled tinygo from my machine and installed tinygo 0.34.0 manually. After recompiling the Spin app with 0.34.0, I was able to successfully invoke the Spin app.

@itowlson
Copy link
Contributor

There is an updated template with an 0.35-friendly build command in the Spin repo. See fermyon/spin#2977 for the changes.

@ThorstenHans
Copy link
Author

ThorstenHans commented Jan 14, 2025

That's strange, I updated all templates earlier today and was still getting this error. I'll check again tomorrow, however I'm pretty confident that I've updated templates from fermyon/spin as well.

Thanks @itowlson

@itowlson
Copy link
Contributor

You might be on a released build of Spin? In that case it picks up the "stable templates known to work with that version" snapshot; pass --branch main to install/update the canary templates.

@ThorstenHans
Copy link
Author

Will try and report back!

@adamreese
Copy link
Member

I hit the same error and upgrading the templates fixed it for me. The build command you want is

tinygo build -target=wasip1 -gc=leaking -scheduler=none -buildmode=c-shared -no-debug -o main.wasm .

@adamreese
Copy link
Member

Also, I just made the changes in CI for a working example #12

@ThorstenHans
Copy link
Author

Updating the build command in templates fixed this for me as well.

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

3 participants