lib: Fix a shutdown crash with "clustering = yes"

This is a bit confusing now, sorry for that:

register_msg_pool_usage() in the ctdb case uses
messaging_ctdb_register_tevent_context(), which talloc_reference()s
the central struct messaging_ctdb_fde_ev of the
messaging_ctdb_context. In messaging_reinit(), we talloc_free only one
of those references and allocate a new messaging_ctdb_fde_ev. The
remaining messaging_ctdb_fde_ev should have been deleted as well, but
due to the second reference this does not happen. When doing the
shutdown messaging_ctdb_fde_ev_destructor() is called twice, once on
the properly reinitialized fde_ev, and once much later on the leftover
one which references invalid data structures.

By the way, this is not a problem with talloc_reference(), this would
have happened with explicit refcounting too.


Signed-off-by: Volker Lendecke <>
Reviewed-by: Martin Schwenke <>
Reviewed-by: Stefan Metzmacher <>

Autobuild-User(master): Björn Baumbach <>
Autobuild-Date(master): Tue Feb 18 13:05:53 UTC 2020 on sn-devel-184

(cherry picked from commit f1577c2b)
40 jobs for vl/1d996bb57b3 in 68 minutes and 50 seconds (queued for 3 seconds)