Re: [PATCH] debug: Deprecate BUG_ON() use in new code, introduce CRASH_ON()

From: Alexander Holler
Date: Mon Jun 08 2015 - 05:22:33 EST


Am 08.06.2015 um 11:11 schrieb Ingo Molnar:

* Ingo Molnar <mingo@xxxxxxxxxx> wrote:

Firstly, the changelog of the patch that Greg rejected told nothing about all
that thinking, so at minimum it's a deficient changelog.

Secondly and more importantly, instead of doing a BUG_ON() you could have done:

if (WARN_ON_ONCE(port->itty))
return;

This would probably have prevented the tty related memory corruption just as
much, at the cost of a (small and infrequent) memory leak.

I.e. instead of crashing the machine, you need to try to find the least
destructive approach if a bug is detected.

Also note that BUG_ON() will make data corruption _worse_ statistically. Why?
Because most data corruptions are unlikely to be perfectly detected by a BUG_ON(),
and the BUG_ON() delays the finding of the underlying bug, so the bug will hit
more people before it's fixed for good.

So even in the cases where you could argue that the system needs to stop, because
we have evidence of data corruption, it's statistically the better approach to
continue and get kernel log info back to developers.

Risking more, maybe even worse problems like corrupting file systems or similiar in order to have a slightly chance of save log info?

Sorry, that isn't something I would propose.

Anyway, CRASH_ON didn't exist, so I only had the choice between BUG_ON and WARN_ON, and for the latter you need a proper exit path which isn't always easy to find. So I appreciate CRASH_ON, thanks.

Alexander Holler
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/