Opened 11 years ago

Closed 11 years ago

#5842 closed Bugs (invalid)

thread.cpp: Win32 thread::thread() calls GetCurrentThread, which returns a pseudo-handle

Reported by: noloader@… Owned by: viboes
Milestone: To Be Determined Component: thread
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

GetCurrentThread() returns a pseudo-handle. All threads which call it are returned a value of (HANDLE)-2 (if I recall correctly). To get a 'real' handle, use DuplicateHandle() [1].

thread::thread() : m_joinable(false)
{
  m_thread = reinterpret_cast<void*>(GetCurrentThread());
  m_id = GetCurrentThreadId();
}

[1] http://msdn.microsoft.com/en-us/library/ms683182(v=vs.85).aspx

Change History (4)

comment:1 by Jeffrey Walton <noloader@…>, 11 years ago

Component: Nonethread
Owner: set to Anthony Williams

comment:2 by viboes, 11 years ago

Are you sure that this pseudo handle is used by another thread?

BTW, thanks for all your reports. This will help a lot to make Boost.Thread more robust :)

comment:3 by viboes, 11 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned
Type: BugsSupport Requests

Moved to support request until resolution clarified.

comment:4 by viboes, 11 years ago

Resolution: invalid
Status: assignedclosed
Type: Support RequestsBugs

It seems that this pseudo-handle is not used by other threads, so no need to duplicate.

Please, reopen it if you don't agree with the resolution.

Note: See TracTickets for help on using tickets.