<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: MQX 4.1 _mem_get_size() in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-mem-get-size/m-p/800932#M17904</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp; Matt:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems your issue is very similar to the mem driver bug fix in MQX 5.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/63212i395A4F777A4F32B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check the below release note for more details&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.nxp.com/docs/en/release-note/MQX_Release_Notes.pdf" title="https://www.nxp.com/docs/en/release-note/MQX_Release_Notes.pdf"&gt;https://www.nxp.com/docs/en/release-note/MQX_Release_Notes.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Aug 2018 07:58:50 GMT</pubDate>
    <dc:creator>danielchen</dc:creator>
    <dc:date>2018-08-20T07:58:50Z</dc:date>
    <item>
      <title>MQX 4.1 _mem_get_size()</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-mem-get-size/m-p/800931#M17903</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;hoping that&amp;nbsp;someone can confirm that _mem_get_size() can incorrectly&amp;nbsp;generate an MQX_INVALID_CHECKSUM error when preempted by a higher priority task which frees the&amp;nbsp;previous block and has to coalesce the newly freed block with an already free block immediately before it. From _mem_get_size():&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;#if&lt;/SPAN&gt; MQX_CHECK_VALIDITY&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; &amp;nbsp; if&lt;/SPAN&gt; ((!VALID_CHECKSUM(block_ptr))) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; kernel_data-&amp;gt;KD_POOL.POOL_BLOCK_IN_ERROR = block_ptr;&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _task_set_error(MQX_INVALID_CHECKSUM);&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return&lt;/SPAN&gt; (0);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; } &lt;SPAN style="color: #008000;"&gt;/* Endif */&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff;"&gt;#endif&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the following memory block state:&lt;/P&gt;&lt;P&gt;Address 1 - Block A - Free&lt;/P&gt;&lt;P&gt;Address 2 - Block B - Allocated&lt;/P&gt;&lt;P&gt;Address 3 - Block C - Allocated&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sequence of operations:&lt;/P&gt;&lt;P&gt;1. Task L is active and calls _mem_get_size(Address 3)&lt;/P&gt;&lt;P&gt;2. While executing VALID_CHECKSUM calculation (after loading the PREVBLOCK address but before performing the CHECKSUM comparison), Task L is preempted by a higher priority Task H.&lt;/P&gt;&lt;P&gt;3. Task H calls _mem_free(Address 2), which needs to coalesce; _mem_check_coalesce_internal() changes Block C PREVBLOCK from Block B to Block A, and calculates and sets a new Block C CHECKSUM.&lt;/P&gt;&lt;P&gt;4. Task H finishes and Task L becomes active.&lt;/P&gt;&lt;P&gt;5. Task L finishes the VALID_CHECKSUM calculation on Block C but the calculated value was generated when PREVBLOCK pointed to Block B, and the CHECKSUM value was generated when PREVBLOCK pointed to Block A, resulting in an MQX_INVALID_CHECKSUM error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it looks to me like _mem_get_size() (_mem_transfer() too) should be wrapping the VALID_CHECKSUM calculation in INT_DISABLE/INT_ENABLE calls.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Aug 2018 17:52:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-mem-get-size/m-p/800931#M17903</guid>
      <dc:creator>mjosborne1</dc:creator>
      <dc:date>2018-08-17T17:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: MQX 4.1 _mem_get_size()</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-mem-get-size/m-p/800932#M17904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp; Matt:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems your issue is very similar to the mem driver bug fix in MQX 5.0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/63212i395A4F777A4F32B7/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please check the below release note for more details&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.nxp.com/docs/en/release-note/MQX_Release_Notes.pdf" title="https://www.nxp.com/docs/en/release-note/MQX_Release_Notes.pdf"&gt;https://www.nxp.com/docs/en/release-note/MQX_Release_Notes.pdf&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Aug 2018 07:58:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-mem-get-size/m-p/800932#M17904</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2018-08-20T07:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: MQX 4.1 _mem_get_size()</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-mem-get-size/m-p/800933#M17905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I'll take that as a yes. i.e. This is a bug in MQX 4.2.&lt;/P&gt;&lt;P&gt;To squash this in MQX 4.2 we'll wrap it (VALID_CHECKSUM calculation) with INT_DISABLE/INT_ENABLE calls, unless there is a different recommended solution...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Aug 2018 15:24:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/MQX-4-1-mem-get-size/m-p/800933#M17905</guid>
      <dc:creator>mjosborne1</dc:creator>
      <dc:date>2018-08-20T15:24:23Z</dc:date>
    </item>
  </channel>
</rss>

