{"action":"created","issue":{"url":"https://api.github.com/repos/rsta2/circle/issues/39","repository_url":"https://api.github.com/repos/rsta2/circle","labels_url":"https://api.github.com/repos/rsta2/circle/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/rsta2/circle/issues/39/comments","events_url":"https://api.github.com/repos/rsta2/circle/issues/39/events","html_url":"https://github.com/rsta2/circle/issues/39","id":231090762,"number":39,"title":"webserver memory leak","user":{"login":"thepyper","id":7761971,"avatar_url":"https://avatars1.githubusercontent.com/u/7761971?v=3","gravatar_id":"","url":"https://api.github.com/users/thepyper","html_url":"https://github.com/thepyper","followers_url":"https://api.github.com/users/thepyper/followers","following_url":"https://api.github.com/users/thepyper/following{/other_user}","gists_url":"https://api.github.com/users/thepyper/gists{/gist_id}","starred_url":"https://api.github.com/users/thepyper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thepyper/subscriptions","organizations_url":"https://api.github.com/users/thepyper/orgs","repos_url":"https://api.github.com/users/thepyper/repos","events_url":"https://api.github.com/users/thepyper/events{/privacy}","received_events_url":"https://api.github.com/users/thepyper/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-24T16:01:22Z","updated_at":"2017-05-25T09:47:53Z","closed_at":null,"body":"Hi!\r\n\r\nI've come across some memory leak problem in web server implementation.\r\nI can reproduce problem on example 21-webserver, on raspberry pi2.\r\nI first tried with ARM_ALLOW_MULTI_CORE + REALTIME settings in sysconfig.h,\r\nthen with ARM_ALLOW_MULTI_CORE only setting, then with default settings, problem remain the same.\r\nWhat I do is flooding webserver with following command from my pc:\r\ncurl -s \"http://192.168.1.118?[1-10000]\"\r\nWhat happens is that always after 457 successful replies raspberry hangs.\r\n\r\nI did some rough debugging, found that:\r\n\r\n- with mem_info() I see that things get allocated but never freed, it looks like any connection is taking about 1 block of 262144, 2 blocks of 4096, 1 block of 1024;\r\n\r\n- with TCP_DEBUG I've seen that connections stay stuck in FIN-WAIT-1 state, as if TCPTimerTimeWait never get called, so state never goes further to CLOSING and tcpconnection never get deleted;\r\n\r\n- what is strange is that this happens only if I continuously do \"fast\" writing on screen (without scrolling): I continuously call \"\\b[H\" sequence to go home with screen cursor, then call mem_info(); this results in seeing very fast update of memory consumption; in this conditions, example 21 hangs with even 1 connection, and connection last seen state is FIN-WAIT-1;\r\n\r\n- if I remove the mem_info() thing, but keep the TCP_DEBUG thing, I see from the tcp log that 1 connection correctly terminates (goes to CLOSED state, and then I see \"Deleted TCB\" message); a connection flood anyway terminates with some not-well defined hang;\r\n\r\nThat's what I've seen so far, hope it is useful :)\r\nI may try some further debugging next days...\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/rsta2/circle/issues/comments/303970132","html_url":"https://github.com/rsta2/circle/issues/39#issuecomment-303970132","issue_url":"https://api.github.com/repos/rsta2/circle/issues/39","id":303970132,"user":{"login":"thepyper","id":7761971,"avatar_url":"https://avatars1.githubusercontent.com/u/7761971?v=3","gravatar_id":"","url":"https://api.github.com/users/thepyper","html_url":"https://github.com/thepyper","followers_url":"https://api.github.com/users/thepyper/followers","following_url":"https://api.github.com/users/thepyper/following{/other_user}","gists_url":"https://api.github.com/users/thepyper/gists{/gist_id}","starred_url":"https://api.github.com/users/thepyper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thepyper/subscriptions","organizations_url":"https://api.github.com/users/thepyper/orgs","repos_url":"https://api.github.com/users/thepyper/repos","events_url":"https://api.github.com/users/thepyper/events{/privacy}","received_events_url":"https://api.github.com/users/thepyper/received_events","type":"User","site_admin":false},"created_at":"2017-05-25T09:47:53Z","updated_at":"2017-05-25T09:47:53Z","body":"I've done some further test, I'm not sure why I'm seeing so many different behaviours, maybe there is more than one thing I'm not understanding :)\r\n\r\nI got the \"memory leak\" solved this way: I added the following line in tcpconnection.cpp at line 1119:\r\nStartTimer (TCPTimerTimeWait, HZ_TIMEWAIT);\r\n\r\nSo, when connection stays stuck in FIN-WAIT-2 state (don't know why yesterday was seeing FIN-WAIT-1) it get closed by timeout. Don't know why my pc is not correctly terminating the connection, but now this command works:\r\n\r\ncurl \"http://192.168.1.250?[1-10000]\"\r\n\r\nRaspberry does not hang, memory consumption stays constant.\r\nI'm no TCP/IP expert, but a timeout on FIN-WAIT-2 state looks reasonable to me, and looking there:\r\n\r\nhttps://benohead.com/tcp-about-fin_wait_2-time_wait-and-close_wait/\r\n\r\nit seems it's usually implemented.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"thepyper"}}