[Tarantool-patches] [PATCH v7 2/5] box/applier: add missing diag_set on region_alloc failure
Konstantin Osipov
kostja.osipov at gmail.com
Wed Feb 5 12:49:46 MSK 2020
* Cyrill Gorcunov <gorcunov at gmail.com> [20/02/05 10:50]:
> > This code is dead actually. There is no region quota and OOM is
> > impossible here. We haven't had a policy to check these errors
> > before.
> >
> > No harm in pushing it, but no value either.
>
> Wait, region_alloc (as other slab related functions) are using
> malloc call on low level (see slab_get_large) thus there is
> no guarantee that NULL won't be ever returned, moreover malloc
> interface never claimed that NULL will be returned iif there
> no free memory in the system (actually this is not how malloc
> works now but api points explicitly that we should be ready
> for NULL and handle it properly).
>
> IOW I think we should handle NULLs to be stable in long terms.
While I sort of agree with the discipline of checking the malloc
return value, just as a style habit, you won't get NULL
from malloc() in practice. OOM killer will do its job first.
Also if you do, you're just as good crashing next line, when
accessing null pointer.
--
Konstantin Osipov, Moscow, Russia
https://scylladb.com
More information about the Tarantool-patches
mailing list