Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock when adding stream to group after packets received #314

Open
bmerry opened this issue Feb 13, 2024 · 0 comments
Open

Deadlock when adding stream to group after packets received #314

bmerry opened this issue Feb 13, 2024 · 0 comments

Comments

@bmerry
Copy link
Contributor

bmerry commented Feb 13, 2024

chunk_stream_group::emplace_back starts like this:

    std::lock_guard<std::mutex> lock(mutex);
    if (chunks.get_tail_chunk() != 0 || last_flush_until != 0)
    {
        throw std::runtime_error("Cannot add a stream after group has started receiving data");
    }

However, when I accidentally added readers to streams before all the streams were added, I didn't get the exception, but instead deadlocked trying to obtain the lock. There needs to be a better way to detect this condition. Possibly when the first data arrives, it can set an atomic flag, which emplace_back checks before taking the lock. This is still racy, but the whole thing is fundamentally racy anyway since it depends on the timing of the data arriving.

bmerry added a commit to ska-sa/katgpucbf that referenced this issue Feb 13, 2024
It was adding new streams to the stream group after allowing data to
flow, which is a no-no. It's not supposed to deadlock, but I've opened
ska-sa/spead2#314 for that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant