ska-sa / spead2

Library for the Streaming Protocol for Exchange of Astronomical Data (SPEAD)
http://spead2.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
23 stars 14 forks source link

Defer reader destruction until add_packet_state destructor #225

Closed bmerry closed 1 year ago

bmerry commented 1 year ago

The ibv reader was crashing due to use-after-free errors. It needed to call ibv_end_poll after the batch finished, but if a packet in the batch stopped the stream, the reader would immediately get destroyed, taking the completion queue with it.

Fix by delaying the actual stream stop until the add_packet_state object is destroyed, which gives the poller object a chance to unwind first.