Skip to content

Commit 49dccee

Browse files
committed
MB-42977: Fix use-after-free bug in AuthProviderService dtor
The AuthProviderService dtor calls event_base_loopbreak() to stop the eventloop (which is running in a different thread), but then immediately deletes the 'base' event_base object. Given event_base_loopbreak() is non-blocking, this can result in the event_base getting deleted while still being used by the other thread. This manifests in different ways - sometimes a crash, but frequently the background thread never breaks out of the event loop and the test hangs, eventually timing out. Fix by simply letting the AuthProviderService dtor delete the base (via the unique_ptr which owns it) _after_ the background thread has joined. Change-Id: I92e06c293b866b442aa4386450947cfb55c01267 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/141394 Tested-by: Build Bot <[email protected]> Reviewed-by: James Harrison <[email protected]>
1 parent 8099deb commit 49dccee

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

cluster_framework/auth_provider_service.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ AuthProviderService::AuthProviderService(Cluster& cluster) : cluster(cluster) {
6262
AuthProviderService::~AuthProviderService() {
6363
// Just break out of the loop
6464
event_base_loopbreak(base.get());
65-
base.reset();
6665
thread.join();
6766
}
6867

0 commit comments

Comments
 (0)