Closed tilsche closed 1 year ago
Code to reproduce
#include <string>
#include <iostream>
#include <thread>
#include <chrono>
using namespace std::chrono_literals;
using namespace std;
// The function we want to execute on the new thread.
void task1(string msg)
{
for (size_t i = 0; i < 399999999; i++);
cout << "task1 says: " << msg << "\n";
std::this_thread::sleep_for(1s);
for (size_t i = 0; i < 399999999; i++);
cout << "task1 say bye\n";
}
int main()
{
// Constructs the new thread and runs it. Does not block execution.
thread t1(task1, "Hello");
// Do other things...
// Makes the main thread wait for the new thread to finish execution, therefore blocks its own execution.
t1.join();
}
This happens because the mmap entries of the main thread are used by merge_calling_context when monitoring threads are destructed - before the main thread actually dumps the entries properly.