{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/osquery/issues/4286","repository_url":"https://api.github.com/repos/facebook/osquery","labels_url":"https://api.github.com/repos/facebook/osquery/issues/4286/labels{/name}","comments_url":"https://api.github.com/repos/facebook/osquery/issues/4286/comments","events_url":"https://api.github.com/repos/facebook/osquery/issues/4286/events","html_url":"https://github.com/facebook/osquery/pull/4286","id":314300581,"number":4286,"title":"bug: handle windows service shutdowns gracefully","user":{"login":"muffins","id":1328916,"avatar_url":"https://avatars1.githubusercontent.com/u/1328916?v=4","gravatar_id":"","url":"https://api.github.com/users/muffins","html_url":"https://github.com/muffins","followers_url":"https://api.github.com/users/muffins/followers","following_url":"https://api.github.com/users/muffins/following{/other_user}","gists_url":"https://api.github.com/users/muffins/gists{/gist_id}","starred_url":"https://api.github.com/users/muffins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffins/subscriptions","organizations_url":"https://api.github.com/users/muffins/orgs","repos_url":"https://api.github.com/users/muffins/repos","events_url":"https://api.github.com/users/muffins/events{/privacy}","received_events_url":"https://api.github.com/users/muffins/received_events","type":"User","site_admin":false},"labels":[{"id":337332432,"url":"https://api.github.com/repos/facebook/osquery/labels/Windows","name":"Windows","color":"d4c5f9","default":false},{"id":117911471,"url":"https://api.github.com/repos/facebook/osquery/labels/bug","name":"bug","color":"fc2929","default":true},{"id":196858822,"url":"https://api.github.com/repos/facebook/osquery/labels/cla%20signed","name":"cla signed","color":"ededed","default":false},{"id":471633534,"url":"https://api.github.com/repos/facebook/osquery/labels/daemon","name":"daemon","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/facebook/osquery/milestones/34","html_url":"https://github.com/facebook/osquery/milestone/34","labels_url":"https://api.github.com/repos/facebook/osquery/milestones/34/labels","id":3262840,"number":34,"title":"3.2.3","description":"3.2.3 will be the next release for osquery to be marked as Stable. We expect this to land _no later_ than Tuesday April 17th. This release brings about numerous new features, bug features, and architecture changes to osquery.\r\n\r\nPlease read the release notes for the tag to see a detailed enumeration of changes.","creator":{"login":"muffins","id":1328916,"avatar_url":"https://avatars1.githubusercontent.com/u/1328916?v=4","gravatar_id":"","url":"https://api.github.com/users/muffins","html_url":"https://github.com/muffins","followers_url":"https://api.github.com/users/muffins/followers","following_url":"https://api.github.com/users/muffins/following{/other_user}","gists_url":"https://api.github.com/users/muffins/gists{/gist_id}","starred_url":"https://api.github.com/users/muffins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muffins/subscriptions","organizations_url":"https://api.github.com/users/muffins/orgs","repos_url":"https://api.github.com/users/muffins/repos","events_url":"https://api.github.com/users/muffins/events{/privacy}","received_events_url":"https://api.github.com/users/muffins/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":3,"state":"open","created_at":"2018-04-12T17:44:02Z","updated_at":"2018-04-15T14:46:51Z","due_on":"2018-04-17T07:00:00Z","closed_at":null},"comments":13,"created_at":"2018-04-14T05:18:01Z","updated_at":"2018-04-15T14:55:37Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/facebook/osquery/pulls/4286","html_url":"https://github.com/facebook/osquery/pull/4286","diff_url":"https://github.com/facebook/osquery/pull/4286.diff","patch_url":"https://github.com/facebook/osquery/pull/4286.patch"},"body":"This pull request fixes a couple of bugs in the osquery Windows service handling routines\r\n\r\n* A regression exists introduced in 3.2.0 causing the worker service to deadlock. This is due to  boost::asio::detail::win_threads not being shutdown correctly. @ExceptionalHandler identified this, thanks for the triage :) The fix here was to call boost::asio::detail::win_thread::set_terminate_threads(true), to ensure that the APC scheduler in boost terminates threads when the http::Client destructor is called on Windows.\r\n* The watcher shutdown handler is run twice due to us not updating the value after execution. This shouldn't cause any issues as it simply stops the dispatcher services twice, however we're executing code that we don't need to be\r\n* The watcher does not wait for the main thread of execution to complete before updating the Windows SCM with the STOPPED status for our service. This was causing the process to be exited before the Dispatcher had cleared out all references to worker threads, which was causing a sigabort to be thrown and the daemon to crash\r\n\r\nThis PR additionally introduces a new windows integration test to spawn the system service and test configurations. Folks should feel free to use this test for Windows system integration tests to ensure no regressions on the behavior of the system service.\r\n\r\nThis PR addresses #4235\r\n\r\nNote, this PR has a follow-up issue, #4285, we need more tests around the thrashing of windows services. I have an integration test for this, but it needs more ironing out, and I don't want it to prevent this PR from being reviewed. I'll follow up this PR with a commit for the integration tests shortly!"},"comment":{"url":"https://api.github.com/repos/facebook/osquery/issues/comments/381412638","html_url":"https://github.com/facebook/osquery/pull/4286#issuecomment-381412638","issue_url":"https://api.github.com/repos/facebook/osquery/issues/4286","id":381412638,"user":{"login":"osqueryer","id":9722826,"avatar_url":"https://avatars0.githubusercontent.com/u/9722826?v=4","gravatar_id":"","url":"https://api.github.com/users/osqueryer","html_url":"https://github.com/osqueryer","followers_url":"https://api.github.com/users/osqueryer/followers","following_url":"https://api.github.com/users/osqueryer/following{/other_user}","gists_url":"https://api.github.com/users/osqueryer/gists{/gist_id}","starred_url":"https://api.github.com/users/osqueryer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/osqueryer/subscriptions","organizations_url":"https://api.github.com/users/osqueryer/orgs","repos_url":"https://api.github.com/users/osqueryer/repos","events_url":"https://api.github.com/users/osqueryer/events{/privacy}","received_events_url":"https://api.github.com/users/osqueryer/received_events","type":"User","site_admin":false},"created_at":"2018-04-15T14:55:37Z","updated_at":"2018-04-15T14:55:37Z","author_association":"COLLABORATOR","body":":-1: The commit 42a48fa19e39f6f208f7965c42d816f7d7e01f35 (Job results: [6862](https://jenkins.osquery.io/job/osqueryPullRequestLinux/6862/)) failed one or more tests (**Linux**).\n"}}
{"actor":{"display_login":"osqueryer"}}