(mutex) lock for callback function C++ -


in multi-threaded application, mutex::lock used prevent 2 threads accessing same memory location @ same time. in application, not use multiple threads have callback function writes vector , loop in main function, reads it. sometimes, error:

vector iterator + offset out of range

after checking vector in debugging, seems fine: number of elements right , none of elements in invalid. there similar possibility callback functions?

no, there isn't. mutexes irrelevant case. out-of-range exception has nothing concurrent access; it's logical error in code. find , fix error, using debugger.


Comments