Using assert-checks for double locks is also useful
Posted Jul 29, 2002 23:48 UTC (Mon) by
cdurst (guest, #2953)
Parent article:
Documenting and enforcing locking requirements
Having just been debugging some (application) thread locking code, I wanted to mention that I found it extremely useful to also also add asserts to make sure that I wasn't setting the same lock twice, or releasing it more than once.
That change immediately pointed out a few places where a function that required a prior lock was inadvertently calling another function that did not assume that it was locked and tried to lock it again.
Some programs may consider that OK and would just nest the locks, but in my particular case this was VERY BAD and lead to the locks being released too early.
(
Log in to post comments)