On Thu, 2023-05-25 at 03:13 +0300, Eduard Zingerman wrote: [...] > +static void test_delete() > +{ > + struct rb_node *next = rb_first(&test_tree); > + > + while (next) { > + struct test_struct *pos = rb_entry(next, struct test_struct, rb_node); > + next = rb_next(&pos->rb_node); > + rb_erase(&pos->rb_node, &structures__tree); ^^^^^^^ Should be &test_tree I made a mistake in this test code. When correct tree is passed to rb_erase() test passes w/o segfaults. The original issue is caused by the same 'struct structures' instance being added to an rb_tree twice, posted a separate patch with a fix to the mailing list. > + } > +} [...]