- edited description
HTTP server leaks on unclosed connections and segFault
There are no way to protect against it.
1) If client close connection abnormally server eats 1 MB for 1000 connections (very aprox)
2) If I try to protect against it as shown in example http://www.php.net/manual/en/eventhttpconnection.setclosecallback.php also got memory leaks, and segFault on signal/exit
Reproduction script is attached
Comments (7)
-
reporter -
repo owner That's how it goes on my machine:
$ php http_req_leak.php 0 -> 524288 1 -> 524288 2 -> 524288 3 -> 524288 4 -> 524288 5 -> 524288 6 -> 524288 7 -> 524288 8 -> 524288 9 -> 524288 10 -> 524288 ... 8000 -> 524288 ...
I had a quick look at the code. It looks good either.
-
repo owner - changed status to on hold
Waiting for your reply. Thanks for reporting this.
BTW, I'd recommend rather using
EventBufferEvent
andEventBuffer
where possible. -
reporter php -n -dextension=event.so --ri event
event Event support => enabled Sockets support => enabled Debug support => disabled Extra functionality support including HTTP, DNS, and RPC => enabled OpenSSL support => enabled Thread safety support => disabled Extension version => 1.10.1 libevent2 headers version => 2.0.21-stable
php -v
PHP 5.4.4-14+deb7u4 (cli) (built: Aug 23 2013 14:37:41)
uname -a
Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.46-1+deb7u1 x86_64 GNU/Linux
As I see 1.10.2 has no any http related changes wich can differ version I've tested.
May be Os, PHP related issue?
php http_req_leak.php
0 -> 262144 1 -> 262144 2 -> 262144 3 -> 262144 4 -> 262144 5 -> 262144 6 -> 262144 ....... 2920 -> 1572864 2921 -> 1572864 .......... 4760 -> 2359296 4761 -> 2359296 4762 -> 2359296 4763 -> 2359296 ....... 5926 -> 2621440 ^CGot sig 2 PHP Notice: Unknown: bufferevent.c:611: Assertion bufev_private->refcnt > 0 failed in _bufferevent_decref_and_unlock in Unknown on line 0 PHP Fatal error: Unknown: libevent detected a non-recoverable internal error, code: -559030611 in Unknown on line 0
may be this errors will help to determinate point of trouble
-
repo owner I see. I had port 8181 bound to some other thing. Now it is reproduced on a free port.
-
repo owner - changed status to open
found a way to reproduce
-
repo owner - changed status to resolved
Fixed in
master
.The
EventBufferEvent
object returned byEventHttpRequest::getBufferEvent()
should be freed explicitly (withEventBufferEvent::free()
method:function _default_callback($req) { $bev = $req->getBufferEvent(); $bev->enable(Event::READ); $bev->free(); $buffer = new EventBuffer(); $buffer->add(str_repeat('*', 1024)); $req->sendReply(200, null, $buffer); }
- Log in to comment