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

Windows PHP CGI Execution Error #68

Open
reeperbahnause opened this issue Sep 30, 2023 · 2 comments
Open

Windows PHP CGI Execution Error #68

reeperbahnause opened this issue Sep 30, 2023 · 2 comments

Comments

@reeperbahnause
Copy link

Describe the bug

First of all, thank you for this awesome project!

I followed the Installation steps for Windows, downloaded the examples and tried my best to get the php examples running but I get the following error message using this location:

<Location /php-hello>
        AddHandler wasm-handler .php
        WasmModule D:/wasmer/php-cgi-8.2.0.wasm
        WasmDir    /tmp
        WasmEnv TMPDIR /tmp
        WasmMapDir / /
        WasmEnableCGI On
</Location>

Message:

[Sat Sep 30 19:05:32.778156 2023] [mpm_winnt:notice] [pid 34536:tid 336] AH00354: Child: Starting 64 worker threads.
ERROR! C-API: Can't run Wasm execution context 'E8A405B1'! "ERROR! Invocation of function '_start' failed! Wasm Trap returned! error while executing at wasm backtrace:\n    0: 0x8f8afe - <unknown>!<wasm function 11722>\n    1: 0xbadd - <unknown>!<wasm function 38>\n\nCaused by:\n    exit with invalid exit status outside of [0..126)"
[Sat Sep 30 19:05:37.331759 2023] [wasm:error] [pid 34536:tid 1020] (-1)Unknown error: [client ::1:54591] content_handler() - ERROR! Couldn't run Wasm execution context 'E8A405B1'!
[Sat Sep 30 19:05:37.331759 2023] [core:error] [pid 34536:tid 1020] [client ::1:54591] End of script output before headers: index.php
[Sat Sep 30 19:05:37.331759 2023] [wasm:error] [pid 34536:tid 1020] (500)Unknown error: [client ::1:54591] ERROR! Invalid script response. On header #0, found character '(null)': 
[Sat Sep 30 19:05:37.331759 2023] [wasm:error] [pid 34536:tid 1020] (500)Unknown error: [client ::1:54591] ERROR! Couldn't find mandatory 'Content-type' HTTP header (i.e.: "Content-type: text/html\n\n")

I manged to see a result using this Location with WasmEnableCGI = Off

<Location /php-hello2>
        AddHandler wasm-handler .php
        WasmModule D:/wasmer/php-cgi-8.2.0.wasm
        WasmArg    /index.php
        WasmMapDir / D:/webassambly/htdocs/php-hello2
        WasmEnableCGI Off
</Location>

Result (truncated):

X-Powered-By: PHP/8.2.0
Content-type: text/html; charset=UTF-8


<html>
    <body>
        <h1>Hello from PHP on Wasm!</h1>
        Today, Saturday, 2023-9-30, at 21:30:39 we greet you with this message!<h1>Output from phpinfo():</h1>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
                <style type="text/css">
                    body {
                        background-color: #fff;
                        color: #222;
                        font-family: sans-serif;
                    }
...

The non php exapmles like http-request-viewer run just fine.

I don't know, if this is a bug or a wrong configuration.

Reproduction steps

  1. Download apache httpd version 2.4.57 for Windows
  2. Download the mod_wasm for Windows from the apachelounge website in version 0.12.1
  3. use the provided httpd.conf from this project
  4. Edit the config to match your local filesystem
  5. Start apache httpd.exe
  6. Browse the php-hello website

Expected behavior

The Hello from PHP on Wasm! message and the phpinfo() html is shown

Additional context

I also tried wasmer using this wasmer.toml:

[package]
name = "wasmer/php-hello"
version = "0.0.1"
description = "A PHP template for WCGI applications"
license = "MIT OR Apache-2.0"
readme = "README.md"
repository = "https://github.com/wasmerio/wcgi-php-template"

[[module]]
name = "php"
source = "php-cgi-8.2.0.wasm"
abi = "wasi"

[[command]]
name = "php"
runner = "wcgi"
module = "php"

[command.annotations.wcgi]
dialect = "rfc-3875"

[command.annotations.wasi]
atom = "php"
env = ["DOCUMENT_ROOT=/app", "SCRIPT_FILENAME=/app/index.php"]

[fs]
"app" = "app"

Running wasmer with this command

wasmer run-unstable .

returns the expected result.
So php-cgi-8.2.0.wasm is fine but I don't have any idea what causes the issue.

@ereslibre
Copy link
Contributor

Thank you for your report @reeperbahnause! We are very glad that you like mod_wasm!

The fact that setting WasmEnableCGI to Off makes it work is interesting.

We have to look more in depth into this, we'll take a look at it as soon as possible, hopefully next week.

@reeperbahnause
Copy link
Author

Any news on this?

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

2 participants