bareos: master 1d8529a3

Author Committer Branch Timestamp Parent
Sebastian Sura Sebastian Sura master 2024-11-07 08:21 master 758e1646 Pending
Changeset msgchan: make crash less likely

Behind the curtains pthread_cleanup_pop is a destructor and
pthread_cancel causes an exception (via a signal).

This means that if you try to cancel a job while that job is in the
process of ending, then you risk an unfixable crash. We want to make
this less likely and move the CleanupCall outside the destructor.

Note that this is just bandaid and not a real fix. There are still
multiple other destructors and pthread_cleanup_calls inside the call
stack, so this can always cause a crash.

The only way to prevent these crashes (even if they are very unlikely)
is to rewrite everything to not rely on pthread_cancel and instead use
some other mechanism for cancelation. This is very hard as we also
have to be able to cancel stuff like write/read/sleep/etc.

We would have to rewrite them with non blocking alternatives to have a
chance of achieving this (or by using the TIMEOUT signal, but that has
other issues ~> signal (un)safety).
mod - core/src/dird/msgchan.cc Diff File