Discussion:
[ast-developers] RFE: Assertions by default...
Roland Mainz
2013-08-07 00:24:22 UTC
Permalink
Hi!

----

More or less short RFE: Are there any objections of adding assertion
code by default in libast&&co., e.g. an |AST_ASSERT(expr)| macro which
immediatly and mercilessly calls |abort()| when the expression |expr|
is not |true| ? It should be allowed to turn the macro into a "nop" of
course... but the default build (debug+optimised) should have it
enabled by default (like Solaris does during development cycles).

The reason I'm coming up with this idea (again) is that this helped a
_lot_ to improve the quality of the Solaris kernel+userland by making
mistakes a la the recent "|fcleft()| returns large negative numbers"
immediately fatal instead of letting the error condition "bleed
through" to other subsystems. It seems libast&&ksh93 have more
problems in this area... I'm experimenting with
http://clang.llvm.org/docs/AddressSanitizer.html right now and the
results look suspicious... either this "clang" feature doesn't work or
we have a lot more problems to fix.

Comments/rants/etc. welcome (and if the idea is OK in general I start
crafting patches) ...

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Glenn Fowler
2013-08-07 02:56:23 UTC
Permalink
Post by Roland Mainz
Hi!
----
More or less short RFE: Are there any objections of adding assertion
code by default in libast&&co., e.g. an |AST_ASSERT(expr)| macro which
immediatly and mercilessly calls |abort()| when the expression |expr|
is not |true| ? It should be allowed to turn the macro into a "nop" of
course... but the default build (debug+optimised) should have it
enabled by default (like Solaris does during development cycles).
The reason I'm coming up with this idea (again) is that this helped a
_lot_ to improve the quality of the Solaris kernel+userland by making
mistakes a la the recent "|fcleft()| returns large negative numbers"
immediately fatal instead of letting the error condition "bleed
through" to other subsystems. It seems libast&&ksh93 have more
problems in this area... I'm experimenting with
http://clang.llvm.org/docs/AddressSanitizer.html right now and the
results look suspicious... either this "clang" feature doesn't work or
we have a lot more problems to fix.
Comments/rants/etc. welcome (and if the idea is OK in general I start
crafting patches) ...
we have <debug.h> with DEBUG_ASSERT() and friends already used in kpv code
Loading...