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

Example either crash or hangs on Windows #22

Open
qonn opened this issue May 29, 2021 · 3 comments
Open

Example either crash or hangs on Windows #22

qonn opened this issue May 29, 2021 · 3 comments

Comments

@qonn
Copy link

qonn commented May 29, 2021

When I run the main example on Windows, it's either crash (2%) or just hang after several concurrent requests (98%).

Expected Behavior

Pony should never crash or hang once compiled! At least based on jennet implementation, it doesn't really do that much.

Current Behavior

Everything compiled nicely, but once I run the wrk tool via Ubuntu WSL wrk -c100 -d30s --latency http://127.0.0.1:8080/. It will crash or just hang forever instantly within 2 seconds. No errors, nothing. Just a feeling of emptiness.

Current Workaround

I managed to get this working by always adding a Content-Length header to the BuildableResponse, I pretty much use my own BuildableResponse, instead of using the one provided here:

Original:

jennet/jennet/jennet.pony

Lines 172 to 186 in 6ed62c9

primitive StatusResponse
fun apply(
status: Status,
headers: Array[(String, String)] box = [],
close: Bool = true)
: BuildableResponse iso^
=>
let res = recover BuildableResponse(status) end
for (k, v) in headers.values() do
res.add_header(k, v)
end
if close and (res.header("Connection") is None) then
res.add_header("Connection", "close")
end
res

Mine:
image

Steps to Reproduce

  1. Windows Machine?
  2. Ubuntu WSL installed
  3. wrk installed following
  4. Pretty much everything else was just copy pasted from get started with pony mixed with trying to get jennet to run. But i'm going to write the steps anyway starting from step 3 😄
  5. Install Pony https://github.com/ponylang/ponyc/blob/main/INSTALL.md#windows
  6. Install corral https://github.com/ponylang/corral/blob/main/BUILD.md#from-source-windows
  7. Create a new folder? jennet-test
  8. corral init
  9. Install corral dependencies
  10. jennet doesn't use main as the main branch so corral will fail. Thus we have to manually clone the jennet git into _corral folder in the jennet_test/_corral/github_com_theodus_jennet
  11. follow https://github.com/Theodus/jennet#named-parameters example (I do need to change the listening host to 0.0.0.0)
  12. run with command in cmd corral run -- ponyc --define openssl_0.9.0
  13. run wrk with WSL wrk -c100 -d30s --latency http://127.0.0.1:8080/

Context (Environment)

  • Windows 10
  • Ubuntu WSL
  • ponyc
    0.41.1 [release]
    Compiled with: LLVM 9.0.1 -- MSVC-19.28.29335.0-x64 1928
  • OpenSSL 0.9.0

Notes:

It works fine when building & running in a linux environment, just 100x much more slower somehow (might be due to WSL?):

  • Ubuntu 18.04.2 LTS (WSL)
  • ponyc
    0.41.1-4553e6cf [release]
    Compiled with: LLVM 9.0.1 -- Clang-6.0.0-x86_64
    Defaults: pic=true
  • OpenSSL 1.1.x
@Theodus
Copy link
Owner

Theodus commented May 29, 2021

Hi @qonn! Thanks for bringing up these issues. Apparently the CI has fallen out of sync with Pony releases, which I'm going to fix now. I've just switched the primary branch to "main" instead of "master", and updated the dependencies to support the latest release version of the compiler. You should now be able to run the tests by just cloning the repo and running make test. Let me know if you are still experiencing the same issues on Windows.

@qonn
Copy link
Author

qonn commented May 29, 2021

Hi @Theodus, no problem! Thanks for the fix, it is easier to get things running now. unfortunately, I did another fresh initialization of jennet, the same example (corral add & corral fetch now works fine). Retest using wrk -c512 -d30s --latency http://127.0.0.1:9999/. 1st run -> crash, 2nd run -> hangs again. 3rd run -> crash and so on...

Also, running make test doesn't really work properly on Windows at least for me. I managed to build the test.exe manually but that's about it, I run the test.exe but no output. just the emptiness of the terminal heheh.

@Theodus
Copy link
Owner

Theodus commented May 29, 2021

I don't use Windows, but I suspect a reasonable fix would be to replace Context.respond with the following:

  fun ref respond(res: BuildableResponse iso, res_body: ValBytes = []) =>
    """
    Respond to the given request with the response.
    """
    if res_body.size() > 0 then
      res.add_header("Content-Length", res_body.size().string())
    end
    _responder(consume res, ByteArrays(res_body), this)

Feel free to open a PR if this fix works for you, or if you have an alternative suggestion. Also, if you have had a Pony program crash (like a segfault). it would be good to have some more detail about that because that may be a bug somewhere in the Pony libraries we depend on.

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