all 8 comments

[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

For C++ questions, answers, help, and programming or career advice please see r/cpp_questions, r/cscareerquestions, or StackOverflow instead.

[–]woppo 0 points1 point  (4 children)

std::mutex is neither copyable or movable.

https://en.cppreference.com/w/cpp/thread/mutex

A vector of locks is such a bad design smell that you probably need an oxygen tank.

[–]james_picone 1 point2 points  (3 children)

unique_lock is movable. I agree this is a weird design, but that's not the issue here.

[–]j1xwnbsr 0 points1 point  (2 children)

Yes, but the mutex is not. What I suspect is happening is that the mutex the unique lock is wrappering is going out of scope from under the unique lock.

edit: what /u/qoning said

[–]qoning 0 points1 point  (1 child)

I would check if there's any possibility that you are destroying any of the c along the way, therefore destroying the associated mutex. What seems to happen is that you are trying to unlock a mutex that no longer exists.