<?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>MQX Software SolutionsのトピックRe: Re: Bug Report: Memory pool corruption in _lwmem_alloc_align_internal</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325386#M10376</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you are right. I agree.&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="CS" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;I edited my last reply according your note.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 31 Jul 2014 09:06:12 GMT</pubDate>
    <dc:creator>RadekS</dc:creator>
    <dc:date>2014-07-31T09:06:12Z</dc:date>
    <item>
      <title>Bug Report: Memory pool corruption in _lwmem_alloc_align_internal</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325382#M10372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have just tracked down a tricky bug in lwmem.c.&lt;/P&gt;&lt;P&gt;When an aligned allocation is made, the following process occurs:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Find a free block&lt;/P&gt;&lt;P&gt;2) Figure out how large a shift is required to make the allocation aligned&lt;/P&gt;&lt;P&gt;3) If free block isn't big enough, go back to 1&lt;/P&gt;&lt;P&gt;4) Create a new free block at the beginning of the free block (size is the previously determined shift).&lt;/P&gt;&lt;P&gt;5) Set the allocated block pointer to the location for the new allocated block&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Sets up the free block's 'nextblock' field to point to the new allocated block, &amp;amp; sets the free block's size)&lt;/P&gt;&lt;P&gt;6a) If there is enough extra space in the allocated block, split it, creating another free block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (The next block is set up - size, pool, nextblock, and the allocated block has it's size set)&lt;/P&gt;&lt;P&gt;6b) If there isn't enough extra space in the allocated block, the allocated block *should* use the remaining space in the block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BUT... here is the problem. The size of the newly allocated block is not set, and is undefined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This causes undefined behavior (usually watchdog resets) when a task's resources are freed (for example), as the allocations in the pool cannot be 'walked'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This bug is present in MQX versions 4.0.1 and 4.1.0 (possibly others).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my fix (based on the MQX 4.1.0 code) - starts in lwmem.c at line 475&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14065287375333297" jivemacro_uid="_14065287375333297" modifiedtitle="true"&gt;
&lt;P&gt;prev_block_ptr-&amp;gt;BLOCKSIZE = shift;&lt;/P&gt;
&lt;P&gt;block_ptr-&amp;gt;U.NEXTBLOCK = prev_block_ptr-&amp;gt;U.NEXTBLOCK;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;next_block_size = block_size - requested_size - shift;&lt;/P&gt;
&lt;P&gt;if (next_block_size &amp;gt;= LWMEM_MIN_MEMORY_STORAGE_SIZE)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /*&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * The current block is big enough to split.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * into 2 blocks.... the part to be allocated is one block,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * and the rest remains as a free block on the free list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; next_block_ptr = (LWMEM_BLOCK_STRUCT_PTR) (void *) ((unsigned char *) block_ptr + requested_size);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize the new physical block values */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; next_block_ptr-&amp;gt;BLOCKSIZE = next_block_size;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Link new block into the free list */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; next_block_ptr-&amp;gt;POOL = (void *) mem_pool_ptr;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; next_block_ptr-&amp;gt;U.NEXTBLOCK = block_ptr-&amp;gt;U.NEXTBLOCK;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; block_ptr-&amp;gt;U.NEXTBLOCK = (void *) next_block_ptr;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Take the entire block */&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; requested_size = block_size - shift;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; next_block_ptr = block_ptr-&amp;gt;U.NEXTBLOCK;&lt;/P&gt;
&lt;P&gt;} /* Endif */&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;block_ptr-&amp;gt;BLOCKSIZE = requested_size;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should have a relatively small impact - aligned allocation is used in only a couple of places.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jul 2014 06:33:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325382#M10372</guid>
      <dc:creator>chrissolomon</dc:creator>
      <dc:date>2014-07-28T06:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Bug Report: Memory pool corruption in _lwmem_alloc_align_internal</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325383#M10373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you are right.&lt;/P&gt;&lt;P&gt;This is potential issue with lwmem allocator. It is known issue and we currently working on that. We plan some more complex rework of lwmem which will include also fix of this potential issue. We would like to focus on solution for avoiding this situation instead of specific workaround.&lt;/P&gt;&lt;P&gt;Anyway, thank you for your bug report and offered solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Jul 2014 13:25:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325383#M10373</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2014-07-28T13:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Bug Report: Memory pool corruption in _lwmem_alloc_align_internal</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325384#M10374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to confirm, that (after triple checking) this bug isn’t presented on current developing version and next MQX release will fix it directly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, we can confirm that your fix is correct for lwmem.c in MQX version up to 4.1.0 (include 4.1.0.1 patch).&lt;/P&gt;&lt;P&gt;Line “&lt;SPAN style="font-family: courier new,courier;"&gt;block_ptr-&amp;gt;BLOCKSIZE = requested_size;&lt;/SPAN&gt;” has to be executed in both cases (&lt;SPAN style="font-family: courier new,courier;"&gt;if (next_block_size &amp;gt;= LWMEM_MIN_MEMORY_STORAGE_SIZE)&lt;/SPAN&gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, you can move this line behind &lt;SPAN style="font-family: courier new,courier;"&gt;if&lt;/SPAN&gt; command or copy this line also to &lt;SPAN style="font-family: courier new,courier;"&gt;else&lt;/SPAN&gt; branch:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if (next_block_size &amp;gt;= LWMEM_MIN_MEMORY_STORAGE_SIZE)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;…. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff00ff; font-family: courier new,courier;"&gt;requested_size = block_size - shift;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: courier new,courier;"&gt;next_block_ptr = block_ptr-&amp;gt;U.NEXTBLOCK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;} /* Endif */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff00ff; font-family: courier new,courier;"&gt;block_ptr-&amp;gt;BLOCKSIZE = requested_size;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if (next_block_size &amp;gt;= LWMEM_MIN_MEMORY_STORAGE_SIZE)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;…. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff00ff; font-family: courier new,courier;"&gt;block_ptr-&amp;gt;BLOCKSIZE = requested_size;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;else&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff00ff; font-family: courier new,courier;"&gt;requested_size = block_size - shift;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: courier new,courier;"&gt;next_block_ptr = block_ptr-&amp;gt;U.NEXTBLOCK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff00ff; font-family: courier new,courier;"&gt;block_ptr-&amp;gt;BLOCKSIZE = requested_size;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;} /* Endif */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;RadekS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 14:25:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325384#M10374</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2014-07-30T14:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Bug Report: Memory pool corruption in _lwmem_alloc_align_internal</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325385#M10375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for checking on that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way, the line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14067586804379429 jive_text_macro jive_macro_code" jivemacro_uid="_14067586804379429"&gt;
&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;requested_size = block_size - shift;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;when the whole block is used is needed as well, or the blocksize will still be set incorrectly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f8f8f8;"&gt;Chris&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Jul 2014 22:17:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325385#M10375</guid>
      <dc:creator>chrissolomon</dc:creator>
      <dc:date>2014-07-30T22:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Bug Report: Memory pool corruption in _lwmem_alloc_align_internal</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325386#M10376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, you are right. I agree.&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="CS" style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;I edited my last reply according your note.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 Jul 2014 09:06:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325386#M10376</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2014-07-31T09:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Bug Report: Memory pool corruption in _lwmem_alloc_align_internal</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325387#M10377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm suffering from quite similar problems, so I stumbled upon this bug report.&lt;/P&gt;&lt;P&gt;My system crashes when _task_destroy_internal finds a memory corruption as in&amp;nbsp;MQX_CORRUPT_STORAGE_POOL_FREE_LIST&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using Cortex-M with MQX v4.2.0.2, so after reviewing lwmem.c I think the issue reported above is already fixed in&amp;nbsp;MQX version 4.2.&lt;/P&gt;&lt;P&gt;Anyway, when using MQX_USE_MEM, my problems are gone.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I'm re-reviewing lwsem.c... The Bug mentioned above&amp;nbsp;seems to be alloc_aligned specific, so I started to check who is using aligned memory. There&amp;nbsp;seems to be a certain need for aligned memory when&amp;nbsp;allocating&amp;nbsp;a&amp;nbsp;dynamic task's stack memory, at least when following this code remark in task.c :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="property macro token"&gt;#if 0 &lt;/SPAN&gt;&lt;SPAN class="comment token"&gt;/* we dont need this, because we using _mem_alloc_align function in _task_alloc_td_internal */&lt;/SPAN&gt;
&lt;SPAN class="property macro token"&gt;#if PSP_MEMORY_ALIGNMENT&lt;/SPAN&gt;
 &lt;SPAN class="comment token"&gt;/* But we need to add size to allow for alignment of stack base */&lt;/SPAN&gt;
 stack_size &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; PSP_STACK_ALIGNMENT &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="property macro token"&gt;#endif&lt;/SPAN&gt;
&lt;SPAN class="property macro token"&gt;#endif&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alas,&amp;nbsp;&lt;SPAN&gt;_task_alloc_td_internal is not using&amp;nbsp;&lt;SPAN&gt;_mem_alloc_align for stack memory allocation.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;Right now&amp;nbsp;I'm testing if using&amp;nbsp;&lt;SPAN&gt;_mem_alloc_align in&amp;nbsp;&lt;SPAN&gt;_task_alloc_td_internal can help me out, or if I have to stick to&amp;nbsp;&lt;SPAN&gt;MQX_USE_MEM instead of lwmem.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Maybe I need something like this to work well with lwmem ?&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;// new_td_ptr-&amp;gt;STACK_ALLOC_BLOCK = (TD_STRUCT_PTR)_mem_alloc(stack_size);&lt;/SPAN&gt;
new_td_ptr&lt;SPAN class="operator token"&gt;-&amp;gt;&lt;/SPAN&gt;STACK_ALLOC_BLOCK &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;TD_STRUCT_PTR&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;_mem_alloc_align&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;stack_size&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Oct 2017 14:00:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-Report-Memory-pool-corruption-in-lwmem-alloc-align-internal/m-p/325387#M10377</guid>
      <dc:creator>martinbachem</dc:creator>
      <dc:date>2017-10-23T14:00:59Z</dc:date>
    </item>
  </channel>
</rss>

