LWN.net Logo

Debug assertions are great

Debug assertions are great

Posted Jul 18, 2002 17:23 UTC (Thu) by cpeterso (subscriber, #305)
Parent article: Documenting and enforcing locking requirements

I think this is a great idea! Many projects (including FreeBSD) use debug assertion statements to help find bugs and document/enforce assumptions in code. I've read that Linus doesn't like assertions, thinking that lazy developers just "code around" them instead of understanding the assumptions the assertions are documenting. Now that the Linux kernel is getting so complicated (with many locks and a preemtible kernel) developers need all the help they can get in testing their code.

Microsoft has a tool called Driver Verifier that helps developers stress-test their device drivers. It forces the NT kernel to do extra (and time-consuming) error checking, such as checking for appropriate IRQL interuppt levels in driver functions and simulating memory allocation failures. Since Linux's device driver APIs are constantly shifting (compared to NT's documented APIs), more assertions like MUST_HOLD_SPIN() are important to become "active" documentation.


(Log in to post comments)

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds