Segfault when using EM.enable_proxy

36 views
Skip to first unread message

Harry Garrood

unread,
Aug 22, 2013, 9:30:17 PM8/22/13
to eventm...@googlegroups.com
I'm getting a segfault when I try to use EM.enable_proxy in a little web app I built. (github: hdgarrood/multicopter)

I've attached all stderr output -- to reproduce it, clone the repository, run `bundle install`, and then `bundle exec ruby main.rb`

Here's a link to the tree at the relevant commit: https://github.com/hdgarrood/multicopter/tree/c1052e1deac7e412e6691b403be996080786facc

Background:
There are two parts to my app, a plain HTTP part, and a websocket part (see main.rb). Until now, they've been running on two different ports. Now I'm trying to make it so that all traffic goes over the same port. I tried to make a third server which looks at incoming requests and chooses whether to send them to the plain HTTP server or the WebSocket one (based on whether they have an 'upgrade: websocket' header) using EM.enable_proxy (see app/controllers/proxy_server.rb). I'm not sure if I've done this correctly -- the ProxyConnection module is taken verbatim from the EM.enable_proxy docs. I don't really understand it.

Anyway, since adding this proxy server, the app behaves a bit weirdly:
* Starts ok
* Serves one request ok
* Dies directly afterwards

It dies in the call to release_machine on line 194 of eventmachine.rb. (this is in the attached log)
I'm using EventMachine 1.0.3. I've checked in Gemfile.lock so you can see there what versions of all the other things I'm using.

segfault.log

c.mene...@gmail.com

unread,
Dec 11, 2013, 10:10:05 PM12/11/13
to eventm...@googlegroups.com
I get the same problem. No idea how to solve it, unfortunately.

It seems that :
- it works fine with no keep-alive
- segfault occurs only with keep-alive.

The reason seems to be that the "enable_proxy" command does not produce the expected result, since  "receive_data" continues to receive data on the second "keep-alive" request (the doc says it should not).

So the segfault only occurs at the second request with keep-alive (the first request is always fine).

Hope it helps. I would love to see that working.
Reply all
Reply to author
Forward
0 new messages