Author Topic: break error on t.join()  (Read 34679 times)

Kenneth Carter

  • Beta Testers
  • Newbie
  • *
  • Posts: 18
    • View Profile
break error on t.join()
« on: November 19, 2008, 07:35:22 PM »
// this project was created using VS 2008 C++ win32 console application, with pre-compiled header checked.

this was happening with _JUST_THREAD_DEADLOCK_CHECK being defined in the _preprocessor in properties

I was trying to run the test to verify it was installed and working.

the output of this has been the following:

"hello from the main thread"

nothing else. either the thread is being deadlocked or something is happening that I am not aware of.


// Parallel_1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <thread>
#include <mutex>

std::mutex io_mutex;

void greeting(const char* message)
{
    std::lock_guard<std::mutex> lk(io_mutex);
    std::cout << message << std::endl;
}



int _tmain(int argc, _TCHAR* argv[])
{
    std::thread t( greeting, "hello from another thread" );
    greeting("hello from the main thread");
   
    t.join(); //<-- this is where an error is occuring
    return 0;
}


here is the call stack:

>   msvcr90d.dll!_NMSG_WRITE(int rterrnum=10)  Line 198   C
    msvcr90d.dll!abort()  Line 59 + 0x7 bytes   C
    msvcr90d.dll!terminate()  Line 130   C++
    Parallel.exe!__jss::stack_trace::build_trace_from()  + 0x40 bytes   
    Parallel.exe!__jss::stack_trace::stack_trace()  + 0x42 bytes   
    Parallel.exe!__jss::mutex::lock()  + 0x2e bytes   
    Parallel.exe!std::unique_lock<std::mutex>::unique_lock<std::mutex>(std::mutex & m_={...})  Line 261   C++
    Parallel.exe!CLock::CLock(std::mutex & _m={...})  Line 19 + 0xf bytes   C++
    Parallel.exe!greeting(const char * message=0x010daab0)  Line 16 + 0xd bytes   C++
    Parallel.exe!__jss::__invoke1<void,void (__cdecl*)(char const *),char const *>::operator()(void (const char *)* & __func=0x010c177b, const char * & __a1=0x010daab0)  Line 15 + 0xf bytes   C++
    Parallel.exe!__jss::__invoker1<void,void (__cdecl*)(char const *),char const *>::operator()()  Line 79   C++
    Parallel.exe!__jss::thread_data<__jss::__invoker1<void,void (__cdecl*)(char const *),char const *> >::run()  Line 94   C++
    Parallel.exe!std::`anonymous namespace'::thread_start_function()  + 0x50 bytes   
    msvcr90d.dll!_callthreadstartex()  Line 348 + 0xf bytes   C
    msvcr90d.dll!_threadstartex(void * ptd=0x000e53e0)  Line 331   C
    kernel32.dll!7566e3f3()    
    [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]   
    ntdll.dll!7708cfed()    
    ntdll.dll!7708d1ff()    
« Last Edit: November 19, 2008, 08:48:01 PM by Kenneth Carter »

Anthony Williams

  • Administrator
  • Full Member
  • *****
  • Posts: 103
    • View Profile
    • just::thread C++ Thread Library
Re: break error on t.join()
« Reply #1 on: November 19, 2008, 10:00:43 PM »
here is the call stack:

>   msvcr90d.dll!_NMSG_WRITE(int rterrnum=10)  Line 198   C
    msvcr90d.dll!abort()  Line 59 + 0x7 bytes   C
    msvcr90d.dll!terminate()  Line 130   C++

...

   Parallel.exe!std::unique_lock<std::mutex>::unique_lock<std::mutex>(std::mutex & m_={...})  Line 261   C++
    Parallel.exe!CLock::CLock(std::mutex & _m={...})  Line 19 + 0xf bytes   C++
 

The fact that the code is stopped in terminate implies that stack trace function used by the deadlock detection hit an unrecoverable internal error. Why that would happen is currently beyond me. I will have to investigate further. Thank you for reporting this.

What version of Windows are you running? Which edition of MSVC (express, standard, team system ...)?

The later part of the stack trace doesn't seem to match the source code you've pasted. Did you try using something other than lock_guard (e.g. unique_lock as posted?) It doesn't matter; just trying to identify the discrepancy.

Thanks.

Kenneth Carter

  • Beta Testers
  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: break error on t.join()
« Reply #2 on: November 19, 2008, 10:54:36 PM »
between the two cases I had tried unique_lock and lock_guard I may have pasted the stack trace for unique lock. both were expressing the same symptoms.

Vista Ultimate x64
MSVC 2008 standard SP 1
« Last Edit: November 19, 2008, 11:17:25 PM by Kenneth Carter »