[zeromq-dev] czmq: Error Traceability with assert(...) and release code

Olaf Mandel o.mandel at menlosystems.com
Fri Mar 7 16:26:03 CET 2014

Am 07.03.2014 15:13, schrieb Christoph Zach:
> We are currently planing on using czmq (directly and implicitly via zyre) to implement 
> some distributed services. By browsing the demo applications and the source 
> We found out that there are various places where 'assert( ... )' is used. This caused
> one of the demo applications (compiled as release) to crash.
Hello Christoph,

I assume you mean that an assertion is violated and either:
* you did not specify NDEBUG so the assertion is still checked and
  calls abort()
* you did specify NDEBUG so the assertion is a no-op and the crash
  ahppens further down in the code

In either case, an assertion should only be violated for real
codeing-bugs (czmqs or your applications), not for any runtime errors.
If it is the latter, then using an assertion is actually a bug in czmqs.

> To further use zyre/czmq We are planing on replacing all the assert(...) statements 
> with actual error handling routines. Otherwise, if one of our applications
> crashes on a customer's system We have to put in a lot of effort to find out
> what actually happend (which is really complex/expensive when the system is not 
> remotely accessible).

See my claim above. If an assertion is miss-used for run-time checks,
that should definitely be fixed. Either way, try defining NDEBUG for
your release binaries: this will not call abort() but will do the
null-pointer dereference, the beyond-array-bounds access or whatever the
assertion was about. This may (or may not) be easier to debug than an
assertion, depending on your code.

Best regards,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20140307/6ba5f1c9/attachment.sig>

More information about the zeromq-dev mailing list