[Gluster-devel] About GF_ASSERT() macro

Xavi Hernandez jahernan at redhat.com
Fri Nov 3 08:35:48 UTC 2017


Hi all,

I've seen that GF_ASSERT() macro is defined in different ways depending on
if we are building in debug mode or not.

In debug mode, it's an alias of assert(), but in non-debug mode it simply
logs an error message and continues.

I think that an assert should be a critical check that should always be
true, specially in production code. Allowing the program to continue after
a failure on one of these checks is dangerous. Most probably it will crash
later, losing some information about the real cause of the error. But even
if it doesn't crash, some internal data will be invalid, leading to a bad
behavior.

I think we should always terminate the process if an assertion fails, even
in production level code. If some failure is not considered so much
critical by the coder, it should not use GF_ASSERT() and only write a log
message or use another of the condition check macros.

Thoughts ?

Xavi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gluster.org/pipermail/gluster-devel/attachments/20171103/d3915f22/attachment.html>


More information about the Gluster-devel mailing list