c++ - Mutex causes access violation when debugging - works fine otherwise -
the following bar()
function has never caused me trouble:
class foo { public: void bar(); private: std::mutex mutex_; }; void foo::bar() { std::unique_lock<std::mutex> lock{ mutex_ }; // ... }
now, have unit test cover bar()
- using gtest. test passes fine, when try debug exception thrown: read access violation
in line unique lock.
the code breaks in mutex.c
:
if (mtx->thread_id != static_cast<long>(getcurrentthreadid())) mtx->_get_cs()->lock();
here _get_cs()
returns uninitialized.
questions:
1) can me understand or point me right direction?
2) need worry this?
what works , doesn't work:
- running application command line application: works (no access violation)
- debugging application visual studio: works (let's me step on line unique lock)
- running application windows service , attaching debugger: works
- running unit test within visual studio (with resharper): works
- running unit test command line: works
- debugging unit test visual studio (with resharper): crashes
Comments
Post a Comment