Skip to content

Commit

Permalink
dcpdrain: Fix user-after-free bug on shutdown
Browse files Browse the repository at this point in the history
Class MemcachedConnection as stored in vbmap refers to the libevent
object constructed at line 560, so we need to destroy all elements of
vbmap before the libevent eventbase is destroyed.

Change-Id: I012e40e21d85dd1d0f0345c7a9da7124adb08330
Reviewed-on: http://review.couchbase.org/c/kv_engine/+/157349
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Trond Norbye <trond.norbye@couchbase.com>
  • Loading branch information
daverigby authored and trondn committed Jul 13, 2021
1 parent b3edc1d commit f314d75
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions programs/dcpdrain/dcpdrain.cc
Expand Up @@ -729,5 +729,9 @@ int main(int argc, char** argv) {
<< calculateThroughput(total_bytes, duration.count() / 1000)
<< ")" << std::endl;
}

/// Need to destruct MemcachedConnections before the libevent 'base'
/// eventbase as MemcachedConnection refers to the event.
vbmap.clear();
return EXIT_SUCCESS;
}

0 comments on commit f314d75

Please sign in to comment.