then while still holding that lock calls dns_validator_destroy->destroy->dns_view_weakdetach
which does:
LOCK(&view->lock);
leaving thread A and thread B in a deadlock, with thread A waiting for the bucket.lock that thread B holds, and thread B waiting for the view->lock that thread A holds.
This is a deadlock in bind9 code; thread A runs ns_client_ endrequest- >dns_view_ detach- >view_flushandd etach, which includes:
LOCK( &view-> lock); view)) resolver_ shutdown( view->resolver) ;
if (!RESSHUTDOWN(
dns_
inside dns_resolver_ shutdown, for each resolver bucket, it does:
for (i = 0; i < res->nbuckets; i++) { &res->buckets[ i].lock) ;
LOCK(
at this point, one of the bucket locks is held, and thread A is blocked holding view->lock, but waiting for the view->resolver- >bucket[ i].lock.
meanwhile, thread B runs dispatch- >validated, and does:
bucketnum = fctx->bucketnum; &res->buckets[ bucketnum] .lock);
LOCK(
then while still holding that lock calls dns_validator_ destroy- >destroy- >dns_view_ weakdetach
which does:
LOCK( &view-> lock);
leaving thread A and thread B in a deadlock, with thread A waiting for the bucket.lock that thread B holds, and thread B waiting for the view->lock that thread A holds.