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

http-php template not working with latest spin #1210

Closed
rajatjindal opened this issue Feb 28, 2023 · 17 comments · Fixed by #1449
Closed

http-php template not working with latest spin #1210

rajatjindal opened this issue Feb 28, 2023 · 17 comments · Fixed by #1449
Labels
bug Something isn't working

Comments

@rajatjindal
Copy link
Collaborator

rajatjindal commented Feb 28, 2023

while trying to add tests for http-php, it seems it is not working.

steps followed (Refer below for full logs of commands run and logs)

  • installed latest spin canary spin 0.9.0 (77985cc 2023-02-28) on apple silicon (didn't tried on other one)
  • installed latest templates
  • create new app using template http-php
  • cd to new app folder and run spin up
  • hit the endpoint http://127.0.0.1:3000/, observe following error on spin process side
2023-02-28T07:39:34.061058Z ERROR spin_http: Error processing request: error while executing at wasm backtrace:
    0: 0x34ca86 - <unknown>!<wasm function 6022>
    1: 0x34e793 - <unknown>!<wasm function 6058>
    2: 0x361e09 - <unknown>!<wasm function 6226>
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information

Caused by:
    exit with invalid exit status outside of [0..126) 
Detailed logs

➜  testcases git:(more-tests-2) ✗ /usr/local/bin/spin-canary --version                 
spin 0.9.0 (77985cc 2023-02-28)

➜  testcases git:(more-tests-2) ✗ /usr/local/bin/spin-canary  template install --git https:/fermyon/spin --branch main --upgrade
Copying remote template source
Installing template redis-rust...
Installing template static-fileserver...
Installing template http-grain...
Installing template http-swift...
Installing template http-php...
Installing template http-c...
Installing template redirect...
Installing template http-rust...
Installing template http-go...
Installing template http-zig...
Installing template http-empty...
Installing template redis-go...
Installed 12 template(s)

+------------------------------------------------------------------------+
| Name                Description                                        |
+========================================================================+
| http-c              HTTP request handler using C and the Zig toolchain |
| http-empty          HTTP application with no components                |
| http-go             HTTP request handler using (Tiny)Go                |
| http-grain          HTTP request handler using Grain                   |
| http-php            HTTP request handler using PHP                     |
| http-rust           HTTP request handler using Rust                    |
| http-swift          HTTP request handler using SwiftWasm               |
| http-zig            HTTP request handler using Zig                     |
| redirect            Redirects a HTTP route                             |
| redis-go            Redis message handler using (Tiny)Go               |
| redis-rust          Redis message handler using Rust                   |
| static-fileserver   Serves static files from an asset directory        |
+------------------------------------------------------------------------+

➜  testcases git:(more-tests-2) ✗ /usr/local/bin/spin-canary new http-php http-php-test
Description: 
HTTP base: /
HTTP path: /...

➜  testcases git:(more-tests-2) ✗ cd http-php-test 

➜  http-php-test git:(more-tests-2) ✗ cat spin.toml 
spin_version = "1"
authors = ["Rajat Jindal <[email protected]>"]
description = ""
name = "http-php-test"
trigger = { type = "http", base = "/" }
version = "0.1.0"

[[component]]
id = "http-php-test"
files = [ { source = "./src", destination = "/" } ]
allowed_http_hosts = []
[component.source]
url = "https:/vmware-labs/webassembly-language-runtimes/releases/download/php%2F7.4.32%2B20221124-2159d1c/php-cgi-7.4.32.speed-optimized.wasm"
digest = "sha256:511720698dee56134ed8a08a87131d33c3ea8a64b6726cd6710d624bca4ceb6c"
[component.trigger]
executor = { type = "wagi"}
route = "/..."

➜  http-php-test git:(more-tests-2) ✗ spin up
Serving http://127.0.0.1:3000
Available Routes:
  http-php-test: http://127.0.0.1:3000 (wildcard)
2023-02-28T07:39:34.061058Z ERROR spin_http: Error processing request: error while executing at wasm backtrace:
    0: 0x34ca86 - <unknown>!<wasm function 6022>
    1: 0x34e793 - <unknown>!<wasm function 6058>
    2: 0x361e09 - <unknown>!<wasm function 6226>
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information

Caused by:
    exit with invalid exit status outside of [0..126)    
^C%                                            
@vdice
Copy link
Member

vdice commented Feb 28, 2023

Perhaps a wasm ABI incompatibility with the runtime version being used?

@rajatjindal
Copy link
Collaborator Author

does this fall under our backward compatibility promise?

@vdice
Copy link
Member

vdice commented Mar 1, 2023

If our assumption of the cause is correct, I don't think this scenario (upstream breaking changes) would (or could) fall under a backwards compatibility promise. At this point, I think the best we can do is ensure templates are updated as needed for compatibility with spin for a given release... and it appears this template might not have been updated accordingly (CI/testing gap; soon to be addressed 😉 ?)

Does this template run successfully with an older Spin release?

@itowlson
Copy link
Contributor

itowlson commented Mar 1, 2023

@vdice Upstream breaking change absolutely falls under the backward compatibility promise. If we have updated to a new version of a dependency, and that new version breaks existing apps, then we've not maintained backward compatibility. It doesn't matter that the dependency is what caused it. It matters that an app that used to run, and has not changed, no longer runs.

(Note that if PHP changed in a breaking way, that would be a different matter, because existing apps - that is, existing builds of PHP - would continue to run.)

In this case, we are still at 0.x, and don't have that full stability guarantee in place. But if the ABI change theory is correct we will need to be super careful about this once we hit 1.0.

@itowlson
Copy link
Contributor

itowlson commented Mar 2, 2023

I see the same error with Spin 0.7 and 0.8. And Spin 0.6 didn't support URL components. It's a puzzler.

@technosophos You authored the PHP template and it clearly worked for you at that point. Would you be able to try it again now please? Thanks!

@technosophos
Copy link
Contributor

Yeah, I will give it a test and see if I can figure it out.

@technosophos
Copy link
Contributor

technosophos commented Mar 2, 2023

I started with Spin 0.8 and the version of the PHP template from that.

$ spin new http-php test-php-tpl
Project description: Hello
HTTP base: /
HTTP path: /...
$ cd test-php-tpl/
$ ls
spin.toml src
$ spin up
Serving http://127.0.0.1:3000
Available Routes:
  test-php-tpl: http://127.0.0.1:3000 (wildcard)
$ spin --version
spin 0.8.0 (7086236 2023-01-31)

So that seems to have worked.

Updated to Spin 0.9 and newest templates.

Removed the old test and tried again:

$ spin new http-php test-php-tpl
Description:
HTTP base: /
HTTP path: /...
$ cd test-php-tpl/
$ spin up
Preparing Wasm modules is taking a few seconds...

Serving http://127.0.0.1:3000
Available Routes:
  test-php-tpl: http://127.0.0.1:3000 (wildcard)

Edit: Spin TOML:

spin_version = "1"
authors = ["Matt Butcher <[email protected]>"]
description = ""
name = "test-php-tpl"
trigger = { type = "http", base = "/" }
version = "0.1.0"

[[component]]
id = "test-php-tpl"
files = [ { source = "./src", destination = "/" } ]
allowed_http_hosts = []
[component.source]
url = "https:/vmware-labs/webassembly-language-runtimes/releases/download/php%2F7.4.32%2B20221124-2159d1c/php-cgi-7.4.32.speed-optimized.wasm"
digest = "sha256:511720698dee56134ed8a08a87131d33c3ea8a64b6726cd6710d624bca4ceb6c"
[component.trigger]
executor = { type = "wagi"}
route = "/..."

@itowlson
Copy link
Contributor

itowlson commented Mar 2, 2023

Just to be clear - and I apologise that this is undoubtedly a stupid question - you did hit or curl the pages, not just run up the server, right?

You are on Mac M1, right? I am on WSL... @rajatjindal what OS/arch are you on?

@technosophos
Copy link
Contributor

Err... no... I misread the error as being on spin up. Lemme try that. I am on macOS on an M1.

@rajatjindal
Copy link
Collaborator Author

I was trying on Mac M2. I can give it a shot on my intel based Apple too later today

@technosophos
Copy link
Contributor

Can you try the URL localhost:3000/index.php instead of /. A quirk of PHP is that it is an error to hit the root of the PHP engine.

@technosophos
Copy link
Contributor

This is the workaround for this that I currently have: https:/technosophos/php-hello-spin/blob/main/spin.toml

I can definitely include this in the template. I left it out because it uses a second component to do the redirecting.

@itowlson
Copy link
Contributor

itowlson commented Mar 2, 2023

@technosophos Genius! index.php works for me. Thank you!

I'm not too fussed about the template. It might be nice, though I don't know how it would play if the HTTP base were something other than /. But it would get you onto the Spin 1.0 contributor list... #JustSaying

@radu-matei
Copy link
Member

Can this be closed?

@technosophos
Copy link
Contributor

I think so, unless y'all would like me to add the redirector to the language template to automatically reroute traffic from / to /index.php.

@fibonacci1729 fibonacci1729 added the bug Something isn't working label Mar 15, 2023
@vdice
Copy link
Member

vdice commented Apr 25, 2023

@rajatjindal are you ok with updating the template to use the redirect workaround (to index.php) mentioned in #1210 (comment)?

@rajatjindal
Copy link
Collaborator Author

yes, I think that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants