Skip to content

Conversation

@ihsandemir
Copy link
Collaborator

@ihsandemir ihsandemir commented Jul 12, 2017

HazelcastClient destruction should guarantee that the lifecycle service shutdown is completed so that no one accesses ConnectionManager object which is destructed before LifecycleService object. The construction order is LifecycleService first and then the ConnectionManager, and the destruction is in the opposite order (see https://stackoverflow.com/questions/2254263/order-of-member-constructor-and-destructor-calls and http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3690.pdf page 255 item 8). Hence, we need to wait for LifecycleService finish its shutdown before leaving the HazelcastClient destructor to avoid illegal memory access. It is not only the ConnectionManager but the ClusterService and other objects created after LifecycleService.

Windows environment IssueTest::testIssue221 failures at windows may be due to this reason.

Solution: Let the client provide the shutdownLatch (remove the one in LifecycleService) on LifecycleService construction and client waits on this latch before destructor exit.

@ihsandemir ihsandemir added this to the 3.8.2 milestone Jul 12, 2017
@ihsandemir ihsandemir self-assigned this Jul 12, 2017
@ihsandemir ihsandemir requested a review from sancar July 12, 2017 18:36
@devOpsHazelcast
Copy link
Contributor

Test PASSed.

@ihsandemir ihsandemir changed the title ClientContext object destructed before LifecycleService may cause illegal memory access ConnectionManager object destructed before LifecycleService may cause illegal memory access Jul 13, 2017
@ihsandemir ihsandemir merged commit 976e056 into hazelcast:master Jul 13, 2017
@ihsandemir ihsandemir deleted the clientShutdownWait branch July 13, 2017 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants