[zeromq-dev] czmq and zalloc - handling OOM situations
Pieter Hintjens
ph at imatix.com
Mon Sep 12 16:32:02 CEST 2011
On Mon, Sep 12, 2011 at 9:09 AM, AJ Lewis <AJ.Lewis at quantum.com> wrote:
> I'm just starting to use zmq and czmq. After poking a bit at the APIs
> and the czmq code, I'm a bit confused about the zmalloc macro and
> associated safe_malloc() wrapper. It appears that the assumption in
> czmq is that cmalloc never fails, which is generally true in Linux, but
> not necessarily true on other OSes. Is there a reason czmq doesn't
> propogate a malloc error back up through the call stack, and instead
> just abort()s? I could #define _ZMALLOC_DEBUG, but then functions like
> zframe_new() would just segfault in the OOM case.
We could propagate the error, sure. The current approach is the
simplest one that plausibly works. I've no preference either way,
except that changes to CZMQ be driven by demand.
Do you want to try patching the code to make it propagate malloc
errors? Or would you like me to look at this?
Note that the zmalloc macro also initalizes (zeroes) memory.
-Pieter
More information about the zeromq-dev
mailing list