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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -