<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word" xmlns:m =
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3243" name=GENERATOR>
<STYLE>@font-face {
        font-family: Cambria Math;
}
@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Tahoma;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.0in 1.0in 1.0in; }
P.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"
}
LI.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"
}
DIV.MsoNormal {
        FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman","serif"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
PRE {
        FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Courier New"; mso-style-priority: 99; mso-style-link: "HTML Preformatted Char"
}
SPAN.EmailStyle18 {
        COLOR: #1f497d; FONT-FAMILY: "Calibri","sans-serif"; mso-style-type: personal-reply
}
SPAN.HTMLPreformattedChar {
        FONT-FAMILY: "Courier New"; mso-style-priority: 99; mso-style-link: "HTML Preformatted"; mso-style-name: "HTML Preformatted Char"
}
.MsoChpDefault {
        FONT-SIZE: 10pt; mso-style-type: export-only
}
DIV.Section1 {
        page: Section1
}
</STYLE>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008>Hi Johnny,</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008>Thanks for your quick response!</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008>I have had a closer look at all related bug messages
and now I see that my <BR>problem is already quite old (sorry for
that).</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008>Correct me if I'm wrong but as far as I can see now
there are two problems <BR>with ace/Message_Queue_T.cpp:</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008>1) Sun May 5 19:14:34 2002 Douglas C.
Schmidt <<A
href="mailto:schm...@macarena.cs.wustl.edu">schm...@macarena.cs.wustl.edu</A>></SPAN></FONT></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008> *
ace/Message_Queue_T.cpp: Modified all the enqueue*() methods so
that<BR> their calls to
notify() occur *outside* of the monitor
lock.<BR> This change
prevents deadlock from occurring when a
reactor's<BR> notification
pipe is full. Thanks to Sasha
Agranov<BR> <<A
href="mailto:sagra...@COMGATES.co.il">sagra...@COMGATES.co.il</A>> for
reporting this.</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008>2) Sat Mar 22 11:58:12 2003 Douglas C.
Schmidt <<A
href="mailto:schm...@tango.doc.wustl.edu">schm...@tango.doc.wustl.edu</A>></SPAN></FONT></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008> *
ace/Message_Queue_T.cpp: Moved the notify() hook calls
within<BR> the protection
of the guard lock critical section to
prevent<BR> race
conditions on cleanup. Thanks to Ron Muck <<A
href="mailto:r...@sdiusa.com">r...@sdiusa.com</A>><BR>
for this suggestion. </SPAN></FONT></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008>Currently, the latter (2) is solved but because of that
(1), which is my <BR>problem, has returned.</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=681022114-27022008>Is it not possible to solve both problems with adding
an extra notify lock? </SPAN></FONT></DIV>
<DIV> </DIV><FONT face=Arial><SPAN class=681022114-27022008>
<DIV dir=ltr align=left><BR><FONT face=Courier color=#0000ff
size=2>
<MessageQueue1,
lock1>
handle_*<BR>
[Producer-1]-enqueue-->[|||||||||||||||||||||||||]--->[EH-1]
<-----+<BR>
|
\<BR>
\ <notifyLock>
<PIPE?>
|<BR>
+-notify----->[|||||||||||||||||||||]--->[Reactor]---+<BR>
/
(consumer)
|<BR>
|
/<BR>
| <MessageQueue-n,
lock-n>
/<BR>
[Producer-n]-enqueue-->[|||||||||||||||||||||||||]--->[EH-n] <----+
<BR>
handle_*</FONT></DIV>
<DIV><FONT face=Courier color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><BR><FONT color=#0000ff size=2>I will point out my idea
about this in the following fix code example.</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2>This fix might be a problem
because I think it needs some interface change in <BR>ACE_Notification_Strategy
too (to get a notification lock somehow) but you have<BR>more insight in the
concequences of that. </FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2>Maybe you first could have a
look at this proposal?</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2>Thanks in advance,<BR>Rudy
Pot</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff
size=2>//==============================================================================<BR>FIX
CODE EXAMPLE (changes applicable for: enqueue_prio, enqueue_head,
<BR>
enqueue_deadline, enqueue_tail )</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><BR><FONT color=#0000ff size=2>template
<ACE_SYNCH_DECL>
int<BR>ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio (ACE_Message_Block
*new_item,<BR>
ACE_Time_Value *timeout)<BR>{<BR> ACE_TRACE
("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio");<BR> int
queue_count = 0;<BR> {<BR> ACE_GUARD_RETURN
(ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2> if
(this->state_ ==
ACE_Message_Queue_Base::DEACTIVATED)<BR>
{<BR> errno =
ESHUTDOWN;<BR> return
-1;<BR> }</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2> if
(this->wait_not_full_cond (ace_mon, timeout) ==
-1)<BR> return -1;</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2>+
{<BR>+ ACE_GUARD_RETURN
(ACE_SYNCH_MUTEX_T<BR>+
,ace_notify_mon<BR>+
// Would be handy if
ACE_Notification_Strategy<BR>+
// has a lock. To be gathered from notify
target<BR>+
//
(reactor?)<BR>+
// Problem: ACE_Reactor_Notification_Strategy has stored
<BR>+
// Reactor reference but ACE_Notification_Strategy
not.<BR>+
,this->notification_strategy->lock()<BR>+
, -1);</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2>+ //
Somehow check if the (reactor?) notification channel is
full.<BR>+ // Probably needs
this->notification_strategy too.<BR>+ if
(this->wait_no_notify_full_cond (ace_notify_mon, timeout) ==
-1)<BR>+ return -1; // We cannot enqueue
without causing a deadlock, so exit.</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2>+ //
Because we hold the notify lock, no new notifications will occur on
our<BR>+ // target and it is safe to enqueue &
notify hereafter...</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff
size=2> queue_count = this->enqueue_i
(new_item);</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff
size=2> if (queue_count ==
-1)<BR> return -1;</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff
size=2> this->notify (); </FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2>+ }; // e.o.
notify guarded area.</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff size=2> }<BR> return
queue_count;<BR>}</FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff><FONT size=2><SPAN
class=681022114-27022008>END </SPAN>FIX CODE
EXAMPLE <BR>//==============================================================================</FONT></FONT></DIV>
<DIV><FONT color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><FONT color=#0000ff
size=2></FONT></SPAN></FONT> </DIV><FONT face="Courier New"><SPAN
class=681022114-27022008><SPAN style="COLOR: blue">
<DIV dir=ltr align=left><FONT><SPAN class=681022114-27022008><FONT
size=2></FONT></SPAN> </DIV></FONT></SPAN></SPAN></FONT>
<DIV dir=ltr align=left> </DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Johnny Willemsen
[mailto:jwillemsen@remedy.nl] <BR><B>Sent:</B> woensdag 27 februari 2008
13:08<BR><B>To:</B> Rudy Pot; ace-bugs@cs.wustl.edu<BR><B>Subject:</B> RE:
[ace-bugs] [ACE_Message_Queue] notify PIPE block causes Select_Reactor
deadlock.<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=Section1>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Hi,<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Thanks
for using the PRF form. I found the change below in svn <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Johnny<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><B><SPAN
style="FONT-SIZE: 10pt; COLOR: rosybrown; FONT-FAMILY: 'Courier New'">Sat Mar 22
11:58:12 2003 </SPAN></B><B><SPAN
style="FONT-SIZE: 10pt; COLOR: cadetblue; FONT-FAMILY: 'Courier New'">Douglas C.
Schmidt </SPAN></B><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><<SPAN
style="COLOR: darkgoldenrod">schmidt@tango.doc.wustl.edu</SPAN>><o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
* <B><SPAN style="COLOR: blue">ace/Message_Queue_T.cpp</SPAN></B>: Moved the
notify() hook calls within<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
the protection of the guard lock critical section to
prevent<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
race conditions on cleanup. Thanks to Ron Muck
<rlm@sdiusa.com> <o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">
for this suggestion.<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"><o:p> </o:p></SPAN></P>
<DIV
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: blue 1.5pt solid; PADDING-TOP: 0in; BORDER-BOTTOM: medium none">
<DIV>
<DIV
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<P class=MsoNormal><B><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">From:</SPAN></B><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">
ace-bugs-bounces@cse.wustl.edu [mailto:ace-bugs-bounces@cse.wustl.edu] <B>On
Behalf Of </B>Rudy Pot<BR><B>Sent:</B> Wednesday, February 27, 2008 11:29
AM<BR><B>To:</B> ace-bugs@cs.wustl.edu<BR><B>Subject:</B> [ace-bugs]
[ACE_Message_Queue] notify PIPE block causes Select_Reactor
deadlock.<o:p></o:p></SPAN></P></DIV></DIV>
<P class=MsoNormal><o:p> </o:p></P>
<DIV>
<P class=MsoNormal><BR><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
ACE VERSION: 5.5.6</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
HOST MACHINE and OPERATING SYSTEM: i386, Linux 2.6.20-1.2933.fc6
</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
same.</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"><BR>
COMPILER NAME AND VERSION (AND PATCHLEVEL): gcc
4.1.1</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
CONTENTS OF $ACE_ROOT/ace/config.h:
config-linux.h</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
CONTENTS OF $ACE_ROOT/include/makeinclude/platform_macros.GNU
(unless<BR> this isn't used in this case, e.g., with Microsoft
Visual C++):<BR>
platform-linux.GNU<BR> <BR>
AREA/CLASS/EXAMPLE AFFECTED: <BR> Message_Queue_T.cpp /
ACE_Message_Queue<ACE_SYNCH_USE> / enqueue_prio<BR> (
But I think also:<BR> ::enqueue_head,
<BR>
::enqueue_deadline,<BR> ::enqueue_tail
)</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
See DESCRIPTION.
</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
DOES THE PROBLEM AFFECT:<BR>
COMPILATION? NO<BR>
LINKING?
NO<BR> EXECUTION?
YES<BR> OTHER (please specify)?
NO</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
SYNOPSIS:<BR> Application sometimes hangs when main Reactor
gets more busy. <BR> (e.g. due to significant increasing
external events)<BR> Coredump shows:<BR> 1)
Main Reactor thread is blocking to get the ACE_Message_Queue
lock.<BR> 2) Multiple threads block on
ACE_Select_Reactor_Notify-> which ends up
in<BR> ->ACE::send() ->
write().<BR> Result is deadlock. We have to kill the
application for shutdown.</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
I've read Sidebar17 of C++ Network Programming Volume 2 but our situation
<BR> is different from what is stated there (no notify called
from handle_* of<BR> event_handler but producer-consumer
deadlock).</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><BR><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
DESCRIPTION:</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
The application in short.<BR>
-------------------------<BR> The part of our program where
this deadlock appears is dealing with <BR> processing messages
from an embedded (CAN) network. <BR> There is a thread per CAN
message center (hardware communication channel)<BR> which puts
the received message into ACE_Message_Queue's, depending on
who<BR> wants to observe the messages. These are the producer
threads.</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
The message queues belongs to observers who all have registered to
get<BR> notified by one Reactor which runs in one main Reactor
thread (consumer).<BR> (they also have registered themselves
by the message center threads as being<BR> interested in
the messages).</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
Problem cause<BR> --------------<BR> What
can happen now is that the main Reactor, which is used for many other
<BR> things in our application, temporarily got other work
todo, and therefore<BR> the message center threads may fill up
the ACE_Select_Reactor notification<BR> PIPE. This causes the
message center threads (producers) to block on the <BR> (FULL)
PIPE write().</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
The main Reactor thread (consumer), when ready with the other work, wants to
<BR> proceed with handling the pending notifications, and so
emptying the PIPE, <BR> but cannot do this because the current
notification code also holds the <BR> message QUEUE lock!
<BR> <BR> See code description
below:</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><BR><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> In
Message_Queue_T.cpp<BR>
======================<BR>
ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio,<BR> (
But also the code reveals:<BR>
::enqueue_head, <BR>
::enqueue_deadline,<BR> ::enqueue_tail
)</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">-------------------------------<BR>DEADLOCK
CODE: (Above rev. 46096 until HEAD code)</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">template
<ACE_SYNCH_DECL>
int<BR>ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio (ACE_Message_Block
*new_item,<BR>
ACE_Time_Value *timeout)<BR>{<BR> ACE_TRACE
("ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio");<BR> int
queue_count = 0;<BR> {<BR> ACE_GUARD_RETURN
(ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1);</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> if
(this->state_ ==
ACE_Message_Queue_Base::DEACTIVATED)<BR>
{<BR> errno =
ESHUTDOWN;<BR> return
-1;<BR> }</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> if
(this->wait_not_full_cond (ace_mon, timeout) ==
-1)<BR> return -1;</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
queue_count = this->enqueue_i (new_item);</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> if
(queue_count == -1)<BR> return
-1;</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
this->notify (); <<<< ERROR DEADLOCK (When blocking on
notify in scope of
<BR>
buffer lock...)<BR> }<BR> return
queue_count;<BR>}</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><BR><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> In
above code snippet: <BR> this->notify (); Causes DEADLOCK
when blocking on full notification pipe.<BR> This happens
because <notify()> is now called within the scope of the
<BR> ACE_GUARD_RETURN.</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> In
older versions of ACE, e.g. 5.3.1, the <notify()> was outside the
scope<BR> of the GUARD and we never had this
deadlock.</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> In
SUBVERSION ACE, I can see this has been changed after
revision<BR> r.46096 of Message_Queue_T.cpp
(ChangeLogTag:Sat Mar 22 11:58:12 2003)<BR> But I don't know
why.</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
See Message_Queue_T.cpp <BR> : enqueue_prio,
enqueue_head, enqueue_deadline, enqueue_tail</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">-------------------------------<BR>NON
DEADLOCK CODE (rev. 46096)<BR>
... <BR>
... <BR>
if (queue_count == -1)<BR> return
-1;</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> } //
e.o. scope ACE_GUARD_RETURN for queue lock.<BR> this->notify ();
// NO deadlock here, notify will unblock as soon PIPE is
<BR>
// emptied.<BR> return queue_count;<BR>}</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><BR><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">-------------------------------<BR>Concerning
Coredump parts:</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">[ consumer
]</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Thread 1 (process
16785):<BR>#0 0x009bc5d9 in __lll_mutex_lock_wait () from
/lib/libpthread.so.0<BR>#1 0x009b8636 in _L_mutex_lock_85 () from
/lib/libpthread.so.0<BR>#2 0x009b817d in pthread_mutex_lock () from
/lib/libpthread.so.0<BR>#3 0x00a9f922 in ACE_OS::mutex_lock () from
/usr/lib/libACE.so.5.5.6<BR>#4 0x00fd83c8 in
ACE_Message_Queue<ACE_MT_SYNCH>::is_empty ()<BR> from
/opt/lib/libgcp_datadump.so<BR>#5 0x0142d881 in
can::CCanSvcDriverObserver::handle_output ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#6 0x00ac03f6 in
ACE_Select_Reactor_Notify::dispatch_notify ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#7 0x00ac057a in
ACE_Select_Reactor_Notify::handle_input ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#8 0x00ac14da in
ACE_Select_Reactor_Notify::dispatch_notifications ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#9 0x00a5ef8e in
ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task$base ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#10 0x00a5f5fd in
ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task$base ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#11 0x00a65b03 in ACE_OS::gettimeofday () from
/usr/lib/libACE.so.5.5.6<BR>#12 0x00abd0d3 in
ACE_Reactor::run_reactor_event_loop ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#13 0x0804ae36 in main
()</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"><o:p> </o:p></SPAN></P>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">[ producer
]<o:p></o:p></SPAN></P></DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Thread 28 (process
17023):<BR>#0 0x009bc8f1 in write () from /lib/libpthread.so.0<BR>#1
0x00a55a3a in ACE::send () from /usr/lib/libACE.so.5.5.6<BR>#2 0x00ac082e
in ACE_Select_Reactor_Notify::notify ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#3 0x00a5edcc in
ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task$base ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#4 0x00abdce6 in ACE_Reactor::notify () from
/usr/lib/libACE.so.5.5.6<BR>#5 0x00abeace in
ACE_Reactor_Notification_Strategy::notify ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#6 0x0804b42a in
ACE_Message_Queue<ACE_MT_SYNCH>::notify ()<BR>#7 0x00fd7fa2 in
ACE_Message_Queue<ACE_MT_SYNCH>::enqueue_prio ()<BR> from
/opt/lib/libgcp_datadump.so<BR>#8 0x0142d6f3 in
can::CCanSvcDriverObserver::update ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#9 0x0143078d in
can::CCanSvcDriver_Base::svc_Read ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#10 0x0143087f in
can::CCanSvcDriverRemoteRequestImpl::svc ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#11 0x00ad3026 in ACE_Task_Base::svc_run
() from /usr/lib/libACE.so.5.5.6<BR>#12 0x00ad39e8 in
ACE_Thread_Adapter::invoke_i ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#13 0x00ad3bb6 in ACE_Thread_Adapter::invoke () from
/usr/lib/libACE.so.5.5.6<BR>#14 0x00a67511 in ace_thread_adapter () from
/usr/lib/libACE.so.5.5.6<BR>#15 0x009b626a in start_thread () from
/lib/libpthread.so.0<BR>#16 0x92fff470 in ?? ()<BR>#17 0x92fff470 in ??
()<BR>#18 0x92fff470 in ?? ()<BR>#19 0x92fff470 in ?? ()<BR>#20 0x00000000 in ??
()</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">[ producer
]<o:p></o:p></SPAN></P></DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Thread 34 (process
17012):<BR>#0 0x009bc8f1 in write () from /lib/libpthread.so.0<BR>#1
0x00a55a3a in ACE::send () from /usr/lib/libACE.so.5.5.6<BR>#2 0x00ac082e
in ACE_Select_Reactor_Notify::notify ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#3 0x00a5edcc in
ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task$base ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#4 0x00abdce6 in ACE_Reactor::notify () from
/usr/lib/libACE.so.5.5.6<BR>#5 0x00abeace in
ACE_Reactor_Notification_Strategy::notify ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#6 0x0804b42a in
ACE_Message_Queue<ACE_MT_SYNCH>::notify ()<BR>#7 0x00fd7fa2 in
ACE_Message_Queue<ACE_MT_SYNCH>::enqueue_prio ()<BR> from
/opt/lib/libgcp_datadump.so<BR>#8 0x0142d6f3 in
can::CCanSvcDriverObserver::update ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#9 0x0143062b in
can::CCanSvcDriver_Base::svc_Read ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#10 0x014308cd in
can::CCanSvcDriverReadImpl::svc ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#11 0x00ad3026 in ACE_Task_Base::svc_run
() from /usr/lib/libACE.so.5.5.6<BR>#12 0x00ad39e8 in
ACE_Thread_Adapter::invoke_i ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#13 0x00ad3bb6 in ACE_Thread_Adapter::invoke () from
/usr/lib/libACE.so.5.5.6<BR>#14 0x00a67511 in ace_thread_adapter () from
/usr/lib/libACE.so.5.5.6<BR>#15 0x009b626a in start_thread () from
/lib/libpthread.so.0<BR>#16 0x96bff470 in ?? ()<BR>#17 0x96bff470 in ??
()<BR>#18 0x96bff470 in ?? ()<BR>#19 0x96bff470 in ?? ()<BR>#20 0x00000000 in ??
()</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">[ producer
]<o:p></o:p></SPAN></P></DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Thread 26 (process
17025):<BR>#0 0x009bc8f1 in write () from /lib/libpthread.so.0<BR>#1
0x00a55a3a in ACE::send () from /usr/lib/libACE.so.5.5.6<BR>#2 0x00ac082e
in ACE_Select_Reactor_Notify::notify ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#3 0x00a5edcc in
ACE_Asynch_Pseudo_Task::ACE_Asynch_Pseudo_Task$base ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#4 0x00abdce6 in ACE_Reactor::notify () from
/usr/lib/libACE.so.5.5.6<BR>#5 0x00abeace in
ACE_Reactor_Notification_Strategy::notify ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#6 0x0804b42a in
ACE_Message_Queue<ACE_MT_SYNCH>::notify ()<BR>#7 0x00fd7fa2 in
ACE_Message_Queue<ACE_MT_SYNCH>::enqueue_prio ()<BR> from
/opt/lib/libgcp_datadump.so<BR>#8 0x0142d6f3 in
can::CCanSvcDriverObserver::update ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#9 0x0143078d in
can::CCanSvcDriver_Base::svc_Read ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#10 0x0143087f in
can::CCanSvcDriverRemoteRequestImpl::svc ()<BR> from
/opt/lib/libcanResourceManager.so.2<BR>#11 0x00ad3026 in ACE_Task_Base::svc_run
() from /usr/lib/libACE.so.5.5.6<BR>#12 0x00ad39e8 in
ACE_Thread_Adapter::invoke_i ()<BR> from
/usr/lib/libACE.so.5.5.6<BR>#13 0x00ad3bb6 in ACE_Thread_Adapter::invoke () from
/usr/lib/libACE.so.5.5.6<BR>#14 0x00a67511 in ace_thread_adapter () from
/usr/lib/libACE.so.5.5.6<BR>#15 0x009b626a in start_thread () from
/lib/libpthread.so.0<BR>#16 0x91bff470 in ?? ()<BR>#17 0x91bff470 in ??
()<BR>#18 0x91bff470 in ?? ()<BR>#19 0x91bff470 in ?? ()<BR>#20 0x00000000 in ??
()</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><BR><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
REPEAT BY:<BR> See description</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">
SAMPLE FIX/WORKAROUND:<BR> Change ACE code so that
<this->notify();> is outside of GUARD scope?<BR>
(like it was before in rev. 46096).</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">[* end of PRF
*]</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Aside from this
deadlock problem:</SPAN><o:p></o:p></P></DIV>
<DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">One thing what also
comes up now is that I have to look at the notification
pipe</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">buffer length too
when I want to increase the ACE_Message_Queue
size?</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">(enqueue will block
if notification pipe is full). </SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Or, I have to
use #define ACE_HAS_REACTOR_NOTIFICATION_QUEUE and</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">recompile
ACE?</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Best
regards,</SPAN><o:p></o:p></P></DIV></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P>
<DIV>
<P class=MsoNormal><STRONG><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Rudy Pot</SPAN></STRONG><o:p></o:p></P></DIV>
<DIV>
<DIV>
<DIV>
<DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Embedded Computer
Systems</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal> <o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><STRONG><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">AWETA G&P
b.v</SPAN></STRONG><o:p></o:p></P></DIV>
<DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">Postbox
17</SPAN><o:p></o:p></P></DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">NL-2630 AA
Nootdorp</SPAN><o:p></o:p></P></DIV></DIV>
<DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">tel +31 (0)15 3109961
</SPAN><o:p></o:p></P>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">fax +31 (0)15
3107321 </SPAN><o:p></o:p></P>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">mail </SPAN><A
href="mailto:rpot@aweta.nl"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">rpot@aweta.nl</SPAN></A><o:p></o:p></P></DIV>
<DIV>
<DIV>
<P class=MsoNormal><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">web <A
href="blocked::http://www.aweta.com">www.aweta.com</A></SPAN><o:p></o:p></P></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></DIV></BODY></HTML>