<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Exercise 2 of Lesson 8 looks have a potential TOCTOU issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119123/exercise-2-of-lesson-8-looks-have-a-potential-toctou-issue</link><description>academy.nordicsemi.com/.../ 
 
 
 The comparison of &amp;quot;increment_count + decrement_count != COMBINED_TOTAL&amp;quot; happens after test_mutex unlock. It is possible that between comparison and test_mutex unlock, &amp;quot;increment_count&amp;quot; or &amp;quot;decrement_count&amp;quot; is incremented</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 21 Feb 2025 09:29:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119123/exercise-2-of-lesson-8-looks-have-a-potential-toctou-issue" /><item><title>RE: Exercise 2 of Lesson 8 looks have a potential TOCTOU issue</title><link>https://devzone.nordicsemi.com/thread/524039?ContentTypeID=1</link><pubDate>Fri, 21 Feb 2025 09:29:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71afde67-8502-423b-a8eb-5eb62f8d542f</guid><dc:creator>Rick Cai</dc:creator><description>&lt;p&gt;I am totally fine as this is a demo to show the usage of mutex and race condition.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Just let learners know how to use these variables correctly.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Exercise 2 of Lesson 8 looks have a potential TOCTOU issue</title><link>https://devzone.nordicsemi.com/thread/524035?ContentTypeID=1</link><pubDate>Fri, 21 Feb 2025 09:24:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64cefbcd-3cf6-4968-b1e8-211e728deeb0</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;I discussed it with the author and it looks to be as you described, yes. Printing the&amp;nbsp;values by fetching values of increment and decrement count outside mutex lock will still have a race condition as you said. Getting those values added into sum inside mutex will avoid that problem, which you also said.&lt;/p&gt;
&lt;p&gt;I will discuss it with the author if it should be updated.&lt;/p&gt;
&lt;p&gt;Again thank you for reporting it&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Exercise 2 of Lesson 8 looks have a potential TOCTOU issue</title><link>https://devzone.nordicsemi.com/thread/523925?ContentTypeID=1</link><pubDate>Thu, 20 Feb 2025 14:31:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:876b04b6-8051-43fe-b448-9e248cb6e119</guid><dc:creator>Rick Cai</dc:creator><description>&lt;p&gt;I observed the race condition even with mutex code enabled.&lt;/p&gt;
&lt;p&gt;Better to add a notice that&amp;nbsp;&lt;span&gt;&amp;quot;increment_count&amp;quot; + &amp;quot;decrement_count&amp;quot; might not be 40 once mutex is unlocked.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Exercise 2 of Lesson 8 looks have a potential TOCTOU issue</title><link>https://devzone.nordicsemi.com/thread/523923?ContentTypeID=1</link><pubDate>Thu, 20 Feb 2025 14:24:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a113d8da-86e6-4ef1-a3fc-b5330297cb13</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;What you&amp;#39;re observing is what is&amp;nbsp; correct. The purpose of the exercise is to show a TOCTOU i.e a race condition.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>