[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#796246: RES: FATAL: ThreadSanitizer: ... (confirmed with g++-6.2 but doesn't show up with g++-5.4)



I've can confirm the bug with g++-6 on Debian (unstable as of
2016/11/14). 

libtsan0: 6.2.0-13
g++-6: 6.2.0-13

When I compile the same software with g++-5 (5.4.1-3) in Debian or on
Gentoo using g++-5.4.0 the error does not occur.

In all cases the tsan library is libtsan.so.0.0.0. 

I've attached a test case that triggers the bug and also does double
un-locking of a mutex to trigger the thread sanitizer. 

The test program was compiled with 

 g++-5 -std=c++11 -fsanitize=thread -g double-unlock.cc -o \
   double-unlock-ts-5 

 g++-6 -std=c++11 -fsanitize=thread -g double-unlock.cc -o \
   double-
unlock-ts-6 

When running double-unlock-ts-5  the thread sanitizer reports the double mutex unlock (as expected). 

When running double-unlock-ts-6 the unexpected memory mapping error shows up as reported in this bug. 

Best, 
Gert 
#include <thread>
#include <mutex>
#include <vector>
#include <iostream>

using namespace std;

mutex g_mutex; 


void thread_function ()
{
        g_mutex.lock();
        cout << "One thread\n";

        g_mutex.unlock();
        g_mutex.unlock();
}


int main(int argc, const char ** args)
{
        auto n_threads = thread::hardware_concurrency();

        vector<thread> threads;

        for (int i = 0; i < n_threads; ++i) 
                threads.push_back(thread(thread_function));

        for (int i = 0; i < n_threads; ++i) 
                threads[i].join(); 
        
        return 0; 
        
}
                

Reply to: