<html><body><div style="color:#000; background-color:#fff; font-family:bookman old style, new york, times, serif;font-size:12pt"><div><span>Hi,</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'bookman old style', 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'bookman old style', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>Thank you very much for the response, indeed we are using rtems_message_queue_send in an interrupt routine (and also some finite timeouts for receive as well).</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'bookman old style', 'new york', times, serif; background-color: transparent; font-style: normal;">Yes, we also have nested interrupts, T2 can be interrupted by T1.</div><div style="color: rgb(0, 0, 0); font-size: 16px;
 font-family: 'bookman old style', 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'bookman old style', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>We will test with your template to see if we can reproduce the problem.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'bookman old style', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>I will let you know how it develops.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'bookman old style', 'new york', times, serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'bookman old style', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>Thank you
 very much,</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: 'bookman old style', 'new york', times, serif; background-color: transparent; font-style: normal;"><span>Cezar Antohe</span></div><div><br></div>  <div style="font-family: 'bookman old style', 'new york', times, serif; font-size: 12pt;"> <div style="font-family: 'times new roman', 'new york', times, serif; font-size: 12pt;"> <div dir="ltr"> <hr size="1">  <font size="2" face="Arial"> <b><span style="font-weight:bold;">From:</span></b> Sebastian Huber <sebastian.huber@embedded-brains.de><br> <b><span style="font-weight: bold;">To:</span></b> rtems-users@rtems.org <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, August 22, 2013 3:56 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: Synchronization problem in message queue mechanism<br> </font> </div> <div class="y_msg_container"><br>
Hello,<br><br>there was a PR related to message queues:<br><br><a href="https://www.rtems.org/bugzilla/show_bug.cgi?id=1961" target="_blank">https://www.rtems.org/bugzilla/show_bug.cgi?id=1961</a><br><br>It was fixed in 4.10.2, but not in 4.10.1.  So this may explain why it needs <br>longer in 4.10.2 to get into trouble.<br><br>I remember that there was a similar problem with a NULL pointer access in the <br>RTEMS events.<br><br>If I compare the functions _Event_Timeout() and _Thread_queue_Process_timeout() <br>I am a bit surprised that _Thread_queue_Process_timeout() doesn't use <br>_ISR_Disable/Enable() to protect the access to the_thread_queue->sync_state. <br>On a first glance this looks like a major bug.<br><br>I added a test case for the RTEMS event problem:<br><br>http://git.rtems.org/rtems/commit/?id=57f125d02595661b72d66f27b6f71c9b9579f516<br><br>It should be possible to use this as a template to reproduce your message queue
 <br>problem.<br><br>On 2013-08-22 14:14, Cezar Antohe wrote:<br>><br>> Hello guys,<br>><br>> We have been using RTEMS 4.10.1 version in a clinical care med unit, and we<br>> believe there may be a synchronization problem in the message queue mechanisms.<br>> We've observed that sometimes, the values from the currently running thread TCB<br>> table are not valid anymore.<br>> Let me give you 2 examples:<br>><br>> 1. In function "rtems_message_queue_receive" there is a call to<br>> "_Message_queue_Translate_core_message_queue_return_code" with input<br>> parameter "_Thread_Executing->Wait.return_code".<br>> This parameters gets corrupted after some hours of unit functioning, looking<br>> into the code for "_Message_queue_Translate_core_message_queue_return_code",<br>> the input should be less that 6 value, however, the return_code returns 13, out<br>> of bound array and invalid.<br>><br>> 2. Another
 bad situation happens in "_Thread_queue_Timeout" function, when<br>> calling "_Thread_queue_Process_timeout" - the input parameter<br>> "Thread_Control*the_thread" has its Wait.queue NULL. No check on that queue<br>> pointer is made in "_Thread_queue_Process_timeout" function, which tries to<br>> access a NULL pointer.<br>><br>> We are no experts in RTEMS functionality and we haven't modified anything in<br>> the current RTEMS code, however, we've noticed that the problem seems to appear<br>> when a thread consumes the messages from the queue, sets the queue to NULL,<br>> another thread calls queue insertion, wakes the first thread, however, its<br>> queue remains NULL.<br>><br>> We are making tests with patches for RTEMS version 4.10.2, the problem still<br>> exists, however it's diminished, meaning is appears after more functioning time<br>> for the infusing unit.<br>><br>> Any help / idea / fast debug
 RTEMS method would be very much appreciated.<br>><br>> Thank you very much,<br>><br>> Cezar Antohe<br>><br>><br>><br>> _______________________________________________<br>> rtems-users mailing list<br>> <a ymailto="mailto:rtems-users@rtems.org" href="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a><br>> http://www.rtems.org/mailman/listinfo/rtems-users<br>><br><br><br>-- <br>Sebastian Huber, embedded brains GmbH<br><br>Address : Dornierstr. 4, D-82178 Puchheim, Germany<br>Phone   : +49 89 189 47 41-16<br>Fax     : +49 89 189 47 41-09<br>E-Mail  : <a ymailto="mailto:sebastian.huber@embedded-brains.de" href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a><br>PGP     : Public key available on request.<br><br>Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>_______________________________________________<br>rtems-users mailing
 list<br><a ymailto="mailto:rtems-users@rtems.org" href="mailto:rtems-users@rtems.org">rtems-users@rtems.org</a><br><a href="http://www.rtems.org/mailman/listinfo/rtems-users" target="_blank">http://www.rtems.org/mailman/listinfo/rtems-users</a><br><br><br></div> </div> </div>  </div></body></html>