Click here to Skip to main content
15,886,199 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 3:08
professional Randor 16-Sep-09 3:08 
AnswerRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 4:07
Roger Stoltz16-Sep-09 4:07 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 4:40
professional Randor 16-Sep-09 4:40 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 5:34
Roger Stoltz16-Sep-09 5:34 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 7:04
professional Randor 16-Sep-09 7:04 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Chesnokov Yuriy16-Sep-09 7:22
professionalChesnokov Yuriy16-Sep-09 7:22 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 7:47
professional Randor 16-Sep-09 7:47 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 7:59
Roger Stoltz16-Sep-09 7:59 
Randor wrote:
As I have previously mentioned both of our excellent recommendations will avoid the deadlock.


Smile | :) David, no offence taken!
I find it interesting and there's a possibility that someone might learn something and it could be me. Poke tongue | ;-P

However, I think you have misread my previous post (or possibly posts).
I figure this as I am still under the impression that the OP waits on the thread handle before spawning a new thread, as I've stated previously.

- or -

Do you really mean that you have experienced a scenario where you have a handle that:
  • you provide as argument to e.g. ::WaitForSingleObject()
  • is valid so the waiting function doesn't return WAIT_FAILED immediately
  • has not assumed a signalled state (which would make the waiting function return immediately)
  • becomes signalled, closed and recycled behind scenes
in a way that makes the waiting function hang?
(This is how I interpret your statement.)

I must say I seriously doubt that as it would mean a catastrophic design flaw of the synchronization mechanism of the operating system in my opinion.


Randor wrote:
If you like I can create a sample application which continuously spawns/terminates a self deleting thread and then force a context switch before calling WaitForSingleObject. The alertable wait state will return 99% of the time and eventually deadlock.


If you are able to do that and wait on the thread handle before creating a new thread, I'd be delighted to see it.
I will even try and create such an abomination myself.
But if this is the case I don't see how any of our proposed solutions may prevent this deadlock.


Randor wrote:
The cause of the deadlock will be a valid handle which is invalid in the context of the process calling WaitForSingleObject. I guess it would be better to use a different terminology as invalid seems to be confusing you.


Well, I wasn't confused until I read the underlined part above. But the confusion is more about what you mean rather than whether a handle is valid or invalid.


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown


GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 8:51
professional Randor 16-Sep-09 8:51 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 11:58
Roger Stoltz16-Sep-09 11:58 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Randor 16-Sep-09 12:25
professional Randor 16-Sep-09 12:25 
GeneralRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Roger Stoltz16-Sep-09 12:51
Roger Stoltz16-Sep-09 12:51 
AnswerRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Stuart Dootson16-Sep-09 1:58
professionalStuart Dootson16-Sep-09 1:58 
AnswerRe: WaitForSingleObject(m_SomeThread->m_hThread, INFINITE); Pin
Jeff Archer16-Sep-09 2:47
Jeff Archer16-Sep-09 2:47 
QuestionExiting an MFC ActiveX Pin
Opa Knack15-Sep-09 22:41
Opa Knack15-Sep-09 22:41 
AnswerRe: Exiting an MFC ActiveX Pin
Stuart Dootson16-Sep-09 0:28
professionalStuart Dootson16-Sep-09 0:28 
AnswerRe: Exiting an MFC ActiveX Pin
Roger Stoltz16-Sep-09 0:38
Roger Stoltz16-Sep-09 0:38 
AnswerRe: Exiting an MFC ActiveX Pin
Randor 16-Sep-09 1:13
professional Randor 16-Sep-09 1:13 
QuestionAuto login a user in XP, after logoff Pin
SummerBulb15-Sep-09 21:59
SummerBulb15-Sep-09 21:59 
AnswerRe: Auto login a user in XP, after logoff Pin
«_Superman_»15-Sep-09 22:27
professional«_Superman_»15-Sep-09 22:27 
GeneralRe: Auto login a user in XP, after logoff Pin
SummerBulb15-Sep-09 22:32
SummerBulb15-Sep-09 22:32 
GeneralRe: Auto login a user in XP, after logoff Pin
SummerBulb15-Sep-09 22:45
SummerBulb15-Sep-09 22:45 
QuestionDifference between C++ and VC++ Pin
hrishiS15-Sep-09 21:09
hrishiS15-Sep-09 21:09 
AnswerRe: Difference between C++ and VC++ Pin
CPallini15-Sep-09 21:19
mveCPallini15-Sep-09 21:19 
AnswerRe: Difference between C++ and VC++ Pin
QuickDeveloper15-Sep-09 21:32
QuickDeveloper15-Sep-09 21:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.