Description
Related dev. issue(s): tarantool/tarantool#7562
Product: Tarantool
Since: 3.0
Root document: https://www.tarantool.io/en/doc/latest/dev_guide/reference_capi/fiber/
SME: @ mkostoevr
Note: looks like a bug fix that doesn't require significant documentation changes.
Details
fiber_join
, fiber_join_timeout
, and fiber_set_joinable
behave differently now.
fiber_join
and fiber_join_timeout
now panic in case if double
join of the given fiber is detected.
fiber_set_joinable
now panics if the given fiber is dead or is
joined already. This prevents some amount of error conditions that
could happen when using the API in an unexpected way, including:
- Making a dead joinable fiber non-joinable could lead to a memory
leak: one can't join the fiber anymore. - Making a dead joinable fiber joinable again is a sign of attempt
to join the fiber later. That means the fiber struct may be joined
later, when it's been recycled and reused. This could lead to a
very hard to debug double join. - Making an alive joined fiber non-joinable would lead to the double
free: once on the fiber function finish, and secondly in the active
fiber join finish. Risks of making it joinable are described above. - Making a dead and recycled fiber joinable allowed to join the fiber
once again leading to a double free.
Any given by the API struct fiber
should only be joined once. If a
fiber is joined after the first join on it has finished the behavior
is undefined: it can either be a panic or an incidental join to a
totally foreign fiber.
Requested by @ mkostoevr in tarantool/tarantool@4440152.