<?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>Problems with k_free()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/65928/problems-with-k_free</link><description>Hi, 
 I can run the following code within main.c successfully, but it produces the error as shown in the attachment upon execution of k_free(mem.ptr) from with aggregator.c. Any ideas why it is not working?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Dec 2020 14:32:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/65928/problems-with-k_free" /><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/286080?ContentTypeID=1</link><pubDate>Mon, 21 Dec 2020 14:32:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e7a1bb1-cd15-42f6-8911-3a87c2bce574</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Your problems seems to be related to other things than k_free(). Could you please create a new thread?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/286074?ContentTypeID=1</link><pubDate>Mon, 21 Dec 2020 14:19:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1eb199db-bd94-444a-8d4e-a5760c400fc1</guid><dc:creator>_dev_</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;was it resolved at all?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m having the same problem once I moved from SDK 1.3.0 to 1.4.1&lt;/p&gt;
&lt;p&gt;App crashes and also UART is not available anymore.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The workaround with&amp;nbsp;&lt;span&gt;CONFIG_MEM_POOL_HEAP_BACKEND doesn&amp;#39;t work either(&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;CONFIG_RESET_ON_FATAL_ERROR=n&amp;nbsp;doesn&amp;#39;t show any additional info.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s what is seen under debug&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1608560547787v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/270565?ContentTypeID=1</link><pubDate>Mon, 21 Sep 2020 11:45:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed9b8d55-b2cc-422e-bc82-d89f954d58a0</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;A private case is preferred if you need to share sensitive data. Since you&amp;#39;re not the original poster in this case, you will lose access to the case if I made it private; so this scenario falls a bit between two stones.&lt;/p&gt;
&lt;p&gt;What you can do in the future is to input a private case, then share it with colleagues (Note: shared users only have read rights, not write)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/270531?ContentTypeID=1</link><pubDate>Mon, 21 Sep 2020 09:57:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e987b63d-b11c-4f0c-8695-b8aacb0e115a</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Please advise how I may send you the project by private message. (Commercially sensitive)&lt;/p&gt;
&lt;p&gt;I have a suspicion that it&amp;#39;s the way that we are forming the project under v1.3 rather than something that is native to zephyr, which is why I&amp;#39;m keen for you to take a look. Because if we have done something stupid it would be great to understand what it was.&lt;/p&gt;
&lt;p&gt;Another issue that has become apparent is that we seem to have lost uart_2 connectivity between nrf52840 and the 9160 which worked fine inside v1.2&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/270521?ContentTypeID=1</link><pubDate>Mon, 21 Sep 2020 09:43:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0172ccd8-d91c-4c94-b36d-a210df1df90c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am glad to hear that you have a workaround, but it is a bit concerning that this happens in the first place.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d be happy to help debug,&amp;nbsp;if you have a simple project that replicates the behavior.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="webfeet"]I don&amp;#39;t think we are using a lot of memory, as we are filling a buffer with a few bytes then clearing the buffer when we have issued MQTT statements.[/quote]
&lt;p&gt;Some&amp;nbsp;heap implementations splits into different chunk-sizes, like having x 32 byte chunks, y 128 byte chunks, and so-forth. If you alloc several smaller chunks, it might take up all the blocks that it normally fits into, and start taking up the next chunk size. However; this shouldn&amp;#39;t explain the fault on free() call. If the pointer mem_ptr was corrupted somehow, it might cause an unaligned access or out-of-bounds access (both scenarios ends in a fault). I cannot say if that is the case here, as the failure looks very deterministic.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/270031?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 10:01:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f1faa09-0750-454b-9d9b-b2e6f84e49d7</guid><dc:creator>John</dc:creator><description>&lt;p&gt;CONFIG_MAIN_STACK_SIZE=8192&lt;/p&gt;
&lt;p&gt;Yes the following was the was the only change:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;CONFIG_MEM_POOL_HEAP_BACKEND=n&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When reading the following in kernel.h it almost seems like there is a more &amp;quot;loose&amp;quot; API on top of the heap.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;* @note When CONFIG_MEM_POOL_HEAP_BACKEND is enabled, the k_mem_pool&lt;br /&gt; * API is implemented on top of a k_heap, which is a more general&lt;br /&gt; * purpose allocator which does not make the same promises about&lt;br /&gt; * splitting or alignment detailed above.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I don&amp;#39;t think we are using a lot of memory, as we are filling a buffer with a few bytes then clearing the buffer when we have issued MQTT statements.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But we are doing this continuously, and in saying that, the problem doesn&amp;#39;t develop like a memory leak would, it happens immediately on the first call to K_free&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I wish I could offer more insight into the problem.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/270022?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 09:22:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d16e832-4f7c-402b-a2c5-6e7a13fb89ce</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is that the only change you did?&lt;/p&gt;
&lt;p&gt;According to the release notes for zephyr v2.3, this falls back to the &amp;quot;old&amp;quot; allocation:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/25882/files#diff-d5ddd504431bec7f3b9e3d5ab926ec34"&gt;https://github.com/zephyrproject-rtos/zephyr/pull/25882/files#diff-d5ddd504431bec7f3b9e3d5ab926ec34&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you using dynamic memory allocation very actively (ie: using a lot of mem)? What happens if you set the heap to 24k for instance?&lt;/p&gt;
&lt;p&gt;What about your CONFIG_MAIN_STACK_SIZE (or the thread where k_free() is called from)? Since the pointer itself is stacked, it could be an issue there. What is your current main stack size?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269996?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 07:49:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c867b27c-8ef3-41c4-9897-6fcb3c2a50b9</guid><dc:creator>John</dc:creator><description>&lt;p&gt;Or perhaps and easier way is&amp;nbsp;CONFIG_MEM_POOL_HEAP_BACKEND=n in prj.conf&lt;/p&gt;
&lt;p&gt;However I&amp;#39;m unsure if this is the right thing to do.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269993?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 07:34:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55b49a54-e32d-4fd1-a111-63d647e72696</guid><dc:creator>John</dc:creator><description>&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/heap.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;If I do this the problem seems to evaporate and k_free doesn&amp;#39;t fail.&lt;/p&gt;
&lt;p&gt;Should this be necessary to do ?&lt;/p&gt;
&lt;p&gt;Also should it be done in SPM as well ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269989?ContentTypeID=1</link><pubDate>Thu, 17 Sep 2020 06:57:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be52e9fa-f938-4668-9078-2bed3491d554</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="webfeet"]Faulting instruction address (r15/pc): 0x0002625e[1B][0m[/quote]
&lt;p&gt;&amp;nbsp;This seems to be the culprit.&lt;/p&gt;
&lt;p&gt;You can use the tool &amp;quot;arm-none-eabi-addr2line -e build-folder/zephyr/zephyr.elf 0xFAULTINGADDR&amp;quot; to resolv an address to a specific line.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="webfeet"]os: r3/a4: 0x0000090c r12/ip: 0x200228b4 r14/lr: 0x00026523[1B][0m[/quote]
&lt;p&gt;Addresses starting from 0 and up to 0x100000 (1M) is flash mapped. 0x200????? is RAM mapped.&lt;/p&gt;
&lt;p&gt;RAM is usually not handled by the addr2line application, so in that case, you can have a look at the zephyr.map file to see what is happening.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="webfeet"]os: Current thread: 0x20022b0c (unknown)[1B][0m[/quote]
&lt;p&gt;&amp;nbsp;If you check the .map file, you should see which thread/stack this memory belongs to.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269807?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 09:39:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:303c44b9-c9df-4c00-9b1a-c0f00ad169a0</guid><dc:creator>John</dc:creator><description>&lt;p&gt;I ran it again.&lt;/p&gt;
&lt;p&gt;Got a more interesting result: after K_free executed&lt;/p&gt;
&lt;p&gt;Memory allocated:[00:09:10.317,321] [1B][1;31m&amp;lt;err&amp;gt; os: ***** HARD FAULT *****[1B][0m&lt;br /&gt;[00:09:10.322,998] [1B][1;31m&amp;lt;err&amp;gt; os: Fault escalation (see below)[1B][0m&lt;br /&gt;[00:09:10.329,406] [1B][1;31m&amp;lt;err&amp;gt; os: ***** BUS FAULT *****[1B][0m&lt;br /&gt;[00:09:10.334,991] [1B][1;31m&amp;lt;err&amp;gt; os: Precise data bus error[1B][0m&lt;br /&gt;[00:09:10.340,881] [1B][1;31m&amp;lt;err&amp;gt; os: BFAR Address: 0x1ffa2db0[1B][0m&lt;br /&gt;[00:09:10.346,923] [1B][1;31m&amp;lt;err&amp;gt; os: r0/a1: 0x20022bc8 r1/a2: 0x1ffa2db0 r2/a3: 0x00000000[1B][0m&lt;br /&gt;[00:09:10.355,834] [1B][1;31m&amp;lt;err&amp;gt; os: r3/a4: 0x0000090c r12/ip: 0x200228b4 r14/lr: 0x00026523[1B][0m&lt;br /&gt;[00:09:10.364,715] [1B][1;31m&amp;lt;err&amp;gt; os: xpsr: 0x81003800[1B][0m&lt;br /&gt;[00:09:10.370,056] [1B][1;31m&amp;lt;err&amp;gt; os: s[ 0]: 0x00000000 s[ 1]: 0x00000003 s[ 2]: 0x00000001 s[ 3]: 0x00000001[1B][0m&lt;br /&gt;[00:09:10.380,767] [1B][1;31m&amp;lt;err&amp;gt; os: s[ 4]: 0x00000001 s[ 5]: 0x00000001 s[ 6]: 0x00000001 s[ 7]: 0x00000001[1B][0m&lt;br /&gt;[00:09:10.391,448] [1B][1;31m&amp;lt;err&amp;gt; os: s[ 8]: 0x00000001 s[ 9]: 0x00000001 s[10]: 0x00000001 s[11]: 0x00000001[1B][0m&lt;br /&gt;[00:09:10.402,160] [1B][1;31m&amp;lt;err&amp;gt; os: s[12]: 0x00000001 s[13]: 0x00000001 s[14]: 0x00000001 s[15]: 0x00000001[1B][0m&lt;br /&gt;[00:09:10.412,841] [1B][1;31m&amp;lt;err&amp;gt; os: fpscr: 0x00000000[1B][0m&lt;br /&gt;[00:09:10.418,182] [1B][1;31m&amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x0002625e[1B][0m&lt;br /&gt;[00:09:10.426,269] [1B][1;31m&amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 0: CPU exception on CPU 0[1B][0m&lt;br /&gt;[00:09:10.434,265] [1B][1;31m&amp;lt;err&amp;gt; os: Current thread: 0x20022b0c (unknown)[1B][0m&lt;br /&gt;[00:09:10.441,223] [1B][1;31m&amp;lt;err&amp;gt; os: Halting system[1B][0m&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269800?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 09:21:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc5e7900-ccba-4f72-b261-81613dbb6902</guid><dc:creator>John</dc:creator><description>&lt;p&gt;With&amp;nbsp;&lt;span&gt;CONFIG_RESET_ON_FATAL_ERROR=n&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Set in SPM and the ns part I have the following before it gets to k_free&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m happy to share the code with you, privately if possible.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;[0[00:04:15.576,477] [1B][1;31m&amp;lt;err&amp;gt; os: ***** USAGE FAULT *****[1B][0m&lt;br /&gt;[00:04:15.582,275] [1B][1;31m&amp;lt;err&amp;gt; os: Illegal load of EXC_RETURN into PC[1B][0m&lt;br /&gt;[00:04:15.589,202] [1B][1;31m&amp;lt;err&amp;gt; os: r0/a1: 0x20027490 r1/a2: 0x2002aa58 r2/a3: 0x00000000[1B][0m&lt;br /&gt;[00:04:15.598,114] [1B][1;31m&amp;lt;err&amp;gt; os: r3/a4: 0x40008000 r12/ip: 0x000003d6 r14/lr: 0x20020090[1B][0m&lt;br /&gt;[00:04:15.607,025] [1B][1;31m&amp;lt;err&amp;gt; os: xpsr: 0x00000000[1B][0m&lt;br /&gt;[00:04:15.612,365] [1B][1;31m&amp;lt;err&amp;gt; os: s[ 0]: 0x00000000 s[ 1]: 0x00000000 s[ 2]: 0x00000000 s[ 3]: 0x00000000[1B][0m&lt;br /&gt;[00:04:15.623,046] [1B][1;31m&amp;lt;err&amp;gt; os: s[ 4]: 0x00000000 s[ 5]: 0x00000000 s[ 6]: 0x00000000 s[ 7]: 0x00000000[1B][0m&lt;br /&gt;[00:04:15.633,758] [1B][1;31m&amp;lt;err&amp;gt; os: s[ 8]: 0x00000000 s[ 9]: 0x00000000 s[10]: 0x00000000 s[11]: 0x00000000[1B][0m&lt;br /&gt;[00:04:15.644,470] [1B][1;31m&amp;lt;err&amp;gt; os: s[12]: 0x00000064 s[13]: 0x00000000 s[14]: 0x00000000 s[15]: 0x000000a3[1B][0m&lt;br /&gt;[00:04:15.655,151] [1B][1;31m&amp;lt;err&amp;gt; os: fpscr: 0x00000010[1B][0m&lt;br /&gt;[00:04:15.660,522] [1B][1;31m&amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x2002009c[1B][0m&lt;br /&gt;[00:04:15.668,609] [1B][1;31m&amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 0: CPU exception on CPU 0[1B][0m&lt;br /&gt;[00:04:15.676,605] [1B][1;31m&amp;lt;err&amp;gt; os: Current thread: 0x20027490 (unknown)[1B][0m&lt;br /&gt;[00:04:15.683,532] [1B][1;31m&amp;lt;err&amp;gt; os: Halting system[1B][0m&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269782?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 08:32:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10f797a1-bc51-473d-ade0-078655de13f5</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes, that is the very beginning of the fault handling. I would like you to go deeper, more specifically here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/master/arch/arm/core/aarch32/cortex_m/fault.c#L949-L962"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/master/arch/arm/core/aarch32/cortex_m/fault.c#L949-L962&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;which again calls this function:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/master/arch/arm/core/aarch32/fatal.c#L41"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/master/arch/arm/core/aarch32/fatal.c#L41&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;which should give you a register dump when the fault occurred.&lt;/p&gt;
&lt;p&gt;Since you are debugging with secure and non-secure regions; it complicates the fault handling, as fault handlers go to the secure side in some scenarios.&lt;/p&gt;
&lt;p&gt;Could you try to set CONFIG_RESET_ON_FATAL_ERROR=n in both your project and in spm when debugging this issue?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269779?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 08:19:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e5c92d4-f713-41aa-b4f0-6b1c3cf079d9</guid><dc:creator>John</dc:creator><description>&lt;p&gt;The code is just for test purposes and runs fine in main.c&lt;/p&gt;
&lt;p&gt;When the same code is run inside aggregator.c&lt;/p&gt;
&lt;p&gt;It begins to execute k_free(mem_ptr);&lt;/p&gt;
&lt;p&gt;When you step inside using debug, it looks almost normal:&lt;/p&gt;
&lt;p&gt;Then ends up here and reboots.&lt;/p&gt;
&lt;p&gt;SECTION_SUBSEC_FUNC(TEXT,__fault,z_arm_hard_fault)&lt;br /&gt;#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE)&lt;br /&gt;/* HardFault is used for all fault conditions on ARMv6-M. */&lt;br /&gt;#elif defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE)&lt;br /&gt;SECTION_SUBSEC_FUNC(TEXT,__fault,z_arm_mpu_fault)&lt;br /&gt;SECTION_SUBSEC_FUNC(TEXT,__fault,z_arm_bus_fault)&lt;br /&gt;SECTION_SUBSEC_FUNC(TEXT,__fault,z_arm_usage_fault)&lt;br /&gt;#if defined(CONFIG_ARM_SECURE_FIRMWARE)&lt;br /&gt;SECTION_SUBSEC_FUNC(TEXT,__fault,z_arm_secure_fault)&lt;br /&gt;#endif /* CONFIG_ARM_SECURE_FIRMWARE */&lt;br /&gt;SECTION_SUBSEC_FUNC(TEXT,__fault,z_arm_debug_monitor)&lt;br /&gt;#else&lt;br /&gt;#error Unknown ARM architecture&lt;br /&gt;#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */&lt;br /&gt;SECTION_SUBSEC_FUNC(TEXT,__fault,z_arm_exc_spurious)&lt;/p&gt;
&lt;p&gt;mrs r0, MSP&lt;br /&gt; mrs r1, PSP&lt;br /&gt; mov r2, lr /* EXC_RETURN */&lt;/p&gt;
&lt;p&gt;push {r0, lr}&lt;/p&gt;
&lt;p&gt;bl z_arm_fault&lt;/p&gt;
&lt;p&gt;pop {r0, pc}&lt;/p&gt;
&lt;p&gt;.end&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269769?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 07:29:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b722f81c-0e00-44a5-9ac3-639081ae242b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;At my side it prints:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.3.0-rc1-ncs1  ***
Memory allocated:
Memory released:&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Have you tried debugging your session to see where it occurs?&amp;nbsp;by adding &amp;quot;&lt;span&gt;CONFIG_RESET_ON_FATAL_ERROR&lt;/span&gt;&lt;span&gt;=n&amp;quot; to your project (and to SPM!) you should enable blocking assertion, which might give you a bit more information (look for the &amp;quot;esf&amp;quot; or &amp;quot;esf_copy&amp;quot; variable, which gives information on where the fault occurred)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kind regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Håkon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269751?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 04:07:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:631149a1-7678-462b-a1ef-c9b3ce60391c</guid><dc:creator>Will Lizardo</dc:creator><description>&lt;p&gt;Hi Hakon,&lt;/p&gt;
&lt;p&gt;The heap size is 16384 I tried using k_calloc() and have the same issue where it reboots when using K_free.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Problems with k_free()</title><link>https://devzone.nordicsemi.com/thread/269640?ContentTypeID=1</link><pubDate>Tue, 15 Sep 2020 11:53:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c46d0a43-b1fc-4f62-ae1b-b15bac5a6ef0</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is your configured heap size?&lt;/p&gt;
&lt;p&gt;That can be set using&amp;nbsp;CONFIG_HEAP_MEM_POOL_SIZE.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;PS: if you&amp;#39;re anyway going to zero the data after allocation, use k_calloc() instead of k_malloc().&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>