possible deadlocks?

Ted Unangst tedu at stanford.edu
Wed Aug 6 15:20:04 PDT 2003


My advisor Dawson Engler has written a deadlock detector, and we'd like
some verification. They look like bugs, unless there is some other reason
why two call chains cannot happen at the same time.

deadlock between ktrace_mtx and sema_mtx.  is it possible to call
sema_timewait on ktrace_sema?  call chain below.

thread 1:
_sema_timedwait(sema, ...)
  mtx_lock(&sema->sema_mtx) /* gets this lock */
    cv_timewait()
      ktrcsw()
        ktr_getrequest()
          mtx_lock(&ktrace_mtx) /* waits for thread 2 */

thread 2:
ktr_submitrequest
  mtx_lock(&ktrace_mtx) /* gets this lock */
    _sema_post(&ktrace_sema)
      mtx_lock(&sema->sema_mtx) /* waits for thread 1 */

second one in bpf, between bpfif_lock and bpfd_lock.

thread 1:
bpf_tap() /* or bpf_mtap */
  BPFIF_LOCK(bp); /* gets this lock */
  for (d = bp->bif_dlist; d != 0; d = d->bd_next) {
	BPFD_LOCK(d); /* waits for thread 2 */

thread 2:
bpf_setdlt()
  BPFD_LOCK(d); /* gets lock */
  bpf_detachd(d); /* or bpf_attachd */
    BPFIF_LOCK(bp); /* waits for thread 1 */





-- 
"The brave men who died in Vietnam, more than 100% of which were
black, were the ultimate sacrifice."
      - M. Barry, Mayor of Washington, DC





More information about the freebsd-hackers mailing list