Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Mar 2003 02:26:37 +0100
From:      des@ofug.org (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=)
To:        walt <wa1ter@myrealbox.com>
Cc:        freebsd-current@freebsd.org
Subject:   Re: Why did INVARIANTS hide the geom bug?
Message-ID:  <xzp3clm941e.fsf@flood.ping.uio.no>
In-Reply-To: <3E74BEA3.6070603@myrealbox.com> (walt's message of "Sun, 16 Mar 2003 10:12:51 -0800")
References:  <3E74BEA3.6070603@myrealbox.com>

next in thread | previous in thread | raw e-mail | index | archive | help
walt <wa1ter@myrealbox.com> writes:
> If inclusion of INVARIANTS serves to disguise bugs in
> the kernel, I wonder if kernel committers should be
> using this option routinely?

It doesn't "serve to disguise bugs"; quite to the contrary, it serves
to expose bugs and reveal their causes.  However, INVARIANTS is
slightly invasive; it adds code to the kernel, and in some cases
changes data structures a little, and these changes have subtle side
effects which may cause a bug to go into hiding.  Such bugs are called
"heisenbugs" (because the presence of the observer affects the outcome
of the experiment...) and are generally caused by using a stack
variable before its initialization, or dereferencing a pointer after
freeing the memory it points to, etc.

I recently fixed a bug in pkg_delete which had gone undetected for
years because it depended on whether the stack had been used before
the function the bug was in got called, and even if it had the garbage
on the stack would in most cases be recognized as an incorrect value
and ignored, but once in a while pkg_delete thought it was a valid
file name and ended up doing the weirdest things.  Running pkg_delete
with kernel tracing enabled (which would have shown me exactly what
pkg_delete was trying to do) caused the bug to magically disappear - I
never quite figured out why - so I had a hell of a time tracking it
down.

DES
-- 
Dag-Erling Smorgrav - des@ofug.org

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzp3clm941e.fsf>