I want to make asynchronous writes in stream.
In code below functions streaming and push_stream runs in parallel threads by using CreateThread winapi function. And std::lock_guard<std::mutex> should lock the queue from random access.
But I have some issue with this instance of code. When queue pops items, I get Microsoft Visual C++ Runtime Library error __acrt_first_block == header
std::ofstream somestream;
std::queue<std::string> queue;
std::mutex mutexQueue;
void streaming() {
  while (true) {
    if (!queue.empty()) {
      std::lock_guard<std::mutex> lock(mutexQueue);
      while (!queue.empty()) {
          somestream << queue.front();
          queue.pop();
      }
    }
  }
}
void push_stream(std::string str) {
  std::lock_guard<std::mutex> lock(mutexQueue);
  queue.push(str);
}
How to make this kind of asynchronous writes? I've tried concurrent_queue but it hasn't a thread-safe item removing.
UPD
Problem was in .dll and .exe static linked with RT. Functions implemented in .exe, push_stream called from .dll.
Which cause the Debug Assertion Failed! Expression: _pFirstBlock == pHead
Now issue is fixed.