{"action":"created","issue":{"url":"https://api.github.com/repos/balabit/syslog-ng/issues/2045","repository_url":"https://api.github.com/repos/balabit/syslog-ng","labels_url":"https://api.github.com/repos/balabit/syslog-ng/issues/2045/labels{/name}","comments_url":"https://api.github.com/repos/balabit/syslog-ng/issues/2045/comments","events_url":"https://api.github.com/repos/balabit/syslog-ng/issues/2045/events","html_url":"https://github.com/balabit/syslog-ng/pull/2045","id":324332348,"number":2045,"title":"Fix window leak in log_source_flow_control_suspend()","user":{"login":"MrAnno","id":3130044,"avatar_url":"https://avatars3.githubusercontent.com/u/3130044?v=4","gravatar_id":"","url":"https://api.github.com/users/MrAnno","html_url":"https://github.com/MrAnno","followers_url":"https://api.github.com/users/MrAnno/followers","following_url":"https://api.github.com/users/MrAnno/following{/other_user}","gists_url":"https://api.github.com/users/MrAnno/gists{/gist_id}","starred_url":"https://api.github.com/users/MrAnno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MrAnno/subscriptions","organizations_url":"https://api.github.com/users/MrAnno/orgs","repos_url":"https://api.github.com/users/MrAnno/repos","events_url":"https://api.github.com/users/MrAnno/events{/privacy}","received_events_url":"https://api.github.com/users/MrAnno/received_events","type":"User","site_admin":false},"labels":[{"id":104723147,"url":"https://api.github.com/repos/balabit/syslog-ng/labels/in%20progress","name":"in progress","color":"207de5","default":false}],"state":"open","locked":false,"assignee":{"login":"lbudai","id":5908786,"avatar_url":"https://avatars1.githubusercontent.com/u/5908786?v=4","gravatar_id":"","url":"https://api.github.com/users/lbudai","html_url":"https://github.com/lbudai","followers_url":"https://api.github.com/users/lbudai/followers","following_url":"https://api.github.com/users/lbudai/following{/other_user}","gists_url":"https://api.github.com/users/lbudai/gists{/gist_id}","starred_url":"https://api.github.com/users/lbudai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbudai/subscriptions","organizations_url":"https://api.github.com/users/lbudai/orgs","repos_url":"https://api.github.com/users/lbudai/repos","events_url":"https://api.github.com/users/lbudai/events{/privacy}","received_events_url":"https://api.github.com/users/lbudai/received_events","type":"User","site_admin":false},"assignees":[{"login":"lbudai","id":5908786,"avatar_url":"https://avatars1.githubusercontent.com/u/5908786?v=4","gravatar_id":"","url":"https://api.github.com/users/lbudai","html_url":"https://github.com/lbudai","followers_url":"https://api.github.com/users/lbudai/followers","following_url":"https://api.github.com/users/lbudai/following{/other_user}","gists_url":"https://api.github.com/users/lbudai/gists{/gist_id}","starred_url":"https://api.github.com/users/lbudai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbudai/subscriptions","organizations_url":"https://api.github.com/users/lbudai/orgs","repos_url":"https://api.github.com/users/lbudai/repos","events_url":"https://api.github.com/users/lbudai/events{/privacy}","received_events_url":"https://api.github.com/users/lbudai/received_events","type":"User","site_admin":false}],"milestone":null,"comments":15,"created_at":"2018-05-18T09:17:46Z","updated_at":"2018-05-24T12:19:25Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/balabit/syslog-ng/pulls/2045","html_url":"https://github.com/balabit/syslog-ng/pull/2045","diff_url":"https://github.com/balabit/syslog-ng/pull/2045.diff","patch_url":"https://github.com/balabit/syslog-ng/pull/2045.patch"},"body":"This PR contains 3 fixes that prevents a source getting stuck/leaking the window.\r\n\r\n- `g_atomic_counter_set()` was not atomic. I would have called it `g_atomic_counter_init_racy`.\r\n- `AckTracker` did not increase the window size by 1 in case of an `AT_SUSPENDED` ack type.\r\n- `log_source_flow_control_suspend()` was not \"atomic enough\":\r\n\r\n```C\r\nvoid\r\nlog_source_flow_control_suspend(LogSource *self)\r\n{\r\n  msg_debug(\"Source has been suspended\", log_pipe_location_tag(&self->super));\r\n\r\n  g_atomic_counter_set(&self->suspended_window_size, /* ! */ g_atomic_counter_get(&self->window_size));\r\n  /* !!! A context switch here and an incrementation of window_size from a different thread\r\n   * make it possible to lose acknowledged \"values\" from the window\r\n   */\r\n  g_atomic_counter_set(&self->window_size, 0);\r\n  _flow_control_rate_adjust(self);\r\n}\r\n```\r\n\r\nBetween setting `suspended_window_size` and setting the original window size to 0, it is possible that `window_size` is incremented by another message consumer in a different thread.\r\n\r\nThis window leak is permanent, it can not be reversed without reloading syslog-ng. Since the problem can occur multiple times in a multithreaded environment, the source may also get stuck.\r\n\r\n-------------\r\n\r\nQuestions:\r\n- **In late-ack-tracker, should I adjust the window size by 1 or `ack_range_length`?**"},"comment":{"url":"https://api.github.com/repos/balabit/syslog-ng/issues/comments/391693332","html_url":"https://github.com/balabit/syslog-ng/pull/2045#issuecomment-391693332","issue_url":"https://api.github.com/repos/balabit/syslog-ng/issues/2045","id":391693332,"user":{"login":"lbudai","id":5908786,"avatar_url":"https://avatars1.githubusercontent.com/u/5908786?v=4","gravatar_id":"","url":"https://api.github.com/users/lbudai","html_url":"https://github.com/lbudai","followers_url":"https://api.github.com/users/lbudai/followers","following_url":"https://api.github.com/users/lbudai/following{/other_user}","gists_url":"https://api.github.com/users/lbudai/gists{/gist_id}","starred_url":"https://api.github.com/users/lbudai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbudai/subscriptions","organizations_url":"https://api.github.com/users/lbudai/orgs","repos_url":"https://api.github.com/users/lbudai/repos","events_url":"https://api.github.com/users/lbudai/events{/privacy}","received_events_url":"https://api.github.com/users/lbudai/received_events","type":"User","site_admin":false},"created_at":"2018-05-24T12:19:25Z","updated_at":"2018-05-24T12:19:25Z","author_association":"CONTRIBUTOR","body":"@MrAnno : thanks for the question!! "}}
{"actor":{"display_login":"lbudai"}}