[Tarantool-patches] [PATCH v3 1/2] b-tree: return NULL on matras_alloc fail
Nikita Pettik
korablev at tarantool.org
Tue Feb 4 21:08:53 MSK 2020
On 04 Feb 20:25, Konstantin Osipov wrote:
> * Nikita Pettik <korablev at tarantool.org> [20/02/04 20:21]:
> > > > On 20 Jan 21:13, Ilya Kosarev wrote:
> > > > > In bps_tree_create_leaf we use matras_alloc in case
> > > > > bps_tree_garbage_pop didn't work out. However it also might not
> > > > > succeed. Then we need to return NULL instead of dereferencing NULL
> > > > > pointer.
> > >
> > > I don't understand the attempt to fix it.
> > >
> > > The reason the allocations are not checked - most likely -because
> > > BPS should refuse to even begin an operation if there is not
> > > enough memory in matras.
> >
> > According to the code it doesn't look so. Matras allocation checked
> > on fails, except two ones in bps_tree_create_inner() and
> > bps_tree_create_leaf().
>
> Because reserve_blocks() should reserve enough blocks or fail, and
> it is called before create_inner/create_leaf in all execution paths?
Consider following path:
memtx_tree_index_replace
|
->memtx_tree_insert (bps_tree_insert)
|
->bps_tree_insert_first_elem
|
->bps_tree_create_leaf
|
-> matras_alloc
In this case reserve_blocks() is not called. AFAIU path is likely to
be reachable. Am I missing smth?
> --
> Konstantin Osipov, Moscow, Russia
More information about the Tarantool-patches
mailing list