{"action":"created","issue":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5306","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5306/labels{/name}","comments_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5306/comments","events_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5306/events","html_url":"https://github.com/hazelcast/hazelcast/pull/5306","id":76470674,"number":5306,"title":"Fix critical section issue in AbstractCompletableFuture","user":{"login":"metanet","id":999867,"avatar_url":"https://avatars.githubusercontent.com/u/999867?v=3","gravatar_id":"","url":"https://api.github.com/users/metanet","html_url":"https://github.com/metanet","followers_url":"https://api.github.com/users/metanet/followers","following_url":"https://api.github.com/users/metanet/following{/other_user}","gists_url":"https://api.github.com/users/metanet/gists{/gist_id}","starred_url":"https://api.github.com/users/metanet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metanet/subscriptions","organizations_url":"https://api.github.com/users/metanet/orgs","repos_url":"https://api.github.com/users/metanet/repos","events_url":"https://api.github.com/users/metanet/events{/privacy}","received_events_url":"https://api.github.com/users/metanet/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Team:%20Core","name":"Team: Core","color":"eb6420"},{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Type:%20Critical","name":"Type: Critical","color":"e11d21"},{"url":"https://api.github.com/repos/hazelcast/hazelcast/labels/Type:%20Test%20Failure","name":"Type: Test Failure","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/hazelcast/hazelcast/milestones/55","html_url":"https://github.com/hazelcast/hazelcast/milestones/3.5","labels_url":"https://api.github.com/repos/hazelcast/hazelcast/milestones/55/labels","id":819785,"number":55,"title":"3.5","description":null,"creator":{"login":"sancar","id":570462,"avatar_url":"https://avatars.githubusercontent.com/u/570462?v=3","gravatar_id":"","url":"https://api.github.com/users/sancar","html_url":"https://github.com/sancar","followers_url":"https://api.github.com/users/sancar/followers","following_url":"https://api.github.com/users/sancar/following{/other_user}","gists_url":"https://api.github.com/users/sancar/gists{/gist_id}","starred_url":"https://api.github.com/users/sancar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sancar/subscriptions","organizations_url":"https://api.github.com/users/sancar/orgs","repos_url":"https://api.github.com/users/sancar/repos","events_url":"https://api.github.com/users/sancar/events{/privacy}","received_events_url":"https://api.github.com/users/sancar/received_events","type":"User","site_admin":false},"open_issues":94,"closed_issues":547,"state":"open","created_at":"2014-10-09T13:04:53Z","updated_at":"2015-05-14T20:02:13Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-05-14T19:50:53Z","updated_at":"2015-05-14T22:06:49Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/hazelcast/hazelcast/pulls/5306","html_url":"https://github.com/hazelcast/hazelcast/pull/5306","diff_url":"https://github.com/hazelcast/hazelcast/pull/5306.diff","patch_url":"https://github.com/hazelcast/hazelcast/pull/5306.patch"},"body":"The issue is as follows:\r\n\r\nInitially, callbackHead is any value X.\r\n\r\nLets consider andThen(Y) is called by Thread 1 and setResult(Z) is called by Thread 2 concurrently, and the execution occurs in the following order.\r\n\r\nThread 1: Line 66 reads result as NULL_VALUE\r\nThread 2: Line 95 successfully executes CAS and assigns Z to result, and calls fireCallbacks()\r\nThread 2: Line 111 loads callbackHead value X to local variable callbackChain.\r\nThread 2: Line 112 successfully executes CAS and assigns NULL to callbackHead\r\nThread 1: Line 71 loads callbackHead value NULL to local variable oldCallbackHead\r\nThread 1: Line 73 successfully executes CAS and assigns Y to callbackHead\r\nThread 2: Line 116-119 executes callback X.\r\n\r\nIn this particular execution order, callback Y is missed!\r\n\r\nCurrent lock-free implementation is broken. A critical section, which already exists in InvocationFuture class, is defined for fixing the issue.\r\n\r\nFixes #5299"},"comment":{"url":"https://api.github.com/repos/hazelcast/hazelcast/issues/comments/102182804","html_url":"https://github.com/hazelcast/hazelcast/pull/5306#issuecomment-102182804","issue_url":"https://api.github.com/repos/hazelcast/hazelcast/issues/5306","id":102182804,"user":{"login":"metanet","id":999867,"avatar_url":"https://avatars.githubusercontent.com/u/999867?v=3","gravatar_id":"","url":"https://api.github.com/users/metanet","html_url":"https://github.com/metanet","followers_url":"https://api.github.com/users/metanet/followers","following_url":"https://api.github.com/users/metanet/following{/other_user}","gists_url":"https://api.github.com/users/metanet/gists{/gist_id}","starred_url":"https://api.github.com/users/metanet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metanet/subscriptions","organizations_url":"https://api.github.com/users/metanet/orgs","repos_url":"https://api.github.com/users/metanet/repos","events_url":"https://api.github.com/users/metanet/events{/privacy}","received_events_url":"https://api.github.com/users/metanet/received_events","type":"User","site_admin":false},"created_at":"2015-05-14T22:06:49Z","updated_at":"2015-05-14T22:06:49Z","body":"verify"}}