tud-zih-energy / lo2s

Linux OTF2 Sampling - A Lightweight Node-Level Performance Monitoring Tool
https://tu-dresden.de/zih/forschung/projekte/lo2s?set_language=en
GNU General Public License v3.0
45 stars 13 forks source link

Unknown functions in threads #240

Closed tilsche closed 1 year ago

tilsche commented 1 year ago

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.

tilsche commented 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();
}