possible thread deadlock on printf?

J

Jun

hi,

deadlock on printf?
server testing.exe!printf(const char * format=0x000007b4, ...) Line 65 +
0x1d C

but i only have 2 running threads at console app... i have no idea printf()
does deadlock.
it always shows after few min of testing...

any ideas? suggestions? or is there something i missed? (or rewrite in win
app? :-S)

thanks in advance.

-jun
 
J

Jun

Jun said:
hi,

deadlock on printf?


but i only have 2 running threads at console app... i have no idea
printf() does deadlock.
it always shows after few min of testing...

any ideas? suggestions? or is there something i missed? (or rewrite in win
app? :-S)

thanks in advance.

-jun

hi,

just found out that it deadlocks on creating mutex

code...
....
printf(" ProcessReply() mutex created\n");
MutexLock _lock(g_chLock);
printf(" ProcessReply() lock started\n");
....
printf(" ProcessReply() mutex destroy\n");



and this is how i found out
....
ThreadDatabase() mutex created
ThreadDatabase() lock started
....
ThreadDatabase() mutex destroy

ProcessReply() mutex created
STUCKED HERE!

i even tried criticalsection at first, still same :(

any idea?

thanks
-jun
 
C

Carl Daniel [VC++ MVP]

Jun said:
hi,

just found out that it deadlocks on creating mutex

code...
...
printf(" ProcessReply() mutex created\n");
MutexLock _lock(g_chLock);
printf(" ProcessReply() lock started\n");
...
printf(" ProcessReply() mutex destroy\n");



and this is how i found out
...
ThreadDatabase() mutex created
ThreadDatabase() lock started
...
ThreadDatabase() mutex destroy

ProcessReply() mutex created
STUCKED HERE!

i even tried criticalsection at first, still same :(

any idea?

Show more code. What is the complete definition of MutexLock?

-cd
 
J

Jun

Carl Daniel said:
Jun said:
"Carl Daniel [VC++ MVP]"
Show more code. What is the complete definition of MutexLock?

i'm using the http://www.bbdsoft.com/win32.html

OK, fine. Those classes look straightforward and correct. How 'bout
showing a bit more of your code now?

-cd

oh ok, the code kinda bit bloated, here is the basic...

if (true)
{
CriticalLock _lock(g_chLock);
std::map<int, tPlayerInfo>::iterator _iterPlayerInfo =
m_mPlayerInfo.begin();
while(_iterPlayerInfo != m_mPlayerInfo.end())
{
...
++_iterPlayerInfo;
}
}

program runs only 2 threads... main() doesn't do anything just to input a
string.
i'm just protecting the m_mPlayerInfo from sharing...

hope this helps, probably any good tool to detect deadlock?

thanks
-jun
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top