<?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>Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116975/systemview-broken-on-sdk-2-8-0-kernel-3-7-99</link><description>With the recent release of SDK 2.8.0 enabling tracing with Segger Systemview locks up the system. 
 The offending issue is buf = net_buf_alloc(&amp;amp;hci_cmd_pool, K_FOREVER); which will block forever waiting for a buffer that will never become available. I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Jan 2025 19:10:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116975/systemview-broken-on-sdk-2-8-0-kernel-3-7-99" /><item><title>RE: Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/thread/519403?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2025 19:10:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d87887af-97da-45b3-bbde-0d31aec9a959</guid><dc:creator>bearsh</dc:creator><description>&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/thread/519400?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2025 18:48:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c5fd42a-e2f0-4a6c-a29f-e21d86e2e3af</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/bearsh"&gt;bearsh&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;It seems &lt;a href="https://devzone.nordicsemi.com/members/anthony32086"&gt;anthony32086&lt;/a&gt;&amp;nbsp;created&amp;nbsp;a fix which has been merged in Zephyr upstream:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/82828"&gt;https://github.com/zephyrproject-rtos/zephyr/pull/82828&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;It doesn&amp;#39;t seem to have been merge into NCS&amp;#39;s Zephyr downstream yet, but you can create a patch from that pull request and patch the Zephyr repository yourself, if you need it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/thread/519345?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2025 14:49:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91be4749-0093-4d1c-ae2e-569166538061</guid><dc:creator>bearsh</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/vthieu"&gt;Hieu&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Has this issue been fixed in the meantime? Is there a public issue to follow?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/thread/514583?ContentTypeID=1</link><pubDate>Wed, 11 Dec 2024 16:05:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83a88dce-b002-4db8-b552-c9f82490e5b0</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi anthony32086,&lt;/p&gt;
&lt;p&gt;Thank you for the detailed report. I want to let you know that it has been relayed to our R&amp;amp;D team. The issue will be investigated and corrected.&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/thread/513753?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2024 06:07:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:801358e2-08da-441d-98b9-c63fc1a5de47</guid><dc:creator>anthony32086</dc:creator><description>&lt;p&gt;Also a quick regex check with &amp;quot;k_fifo_put\(.*\(&amp;quot; shows there are several instances in the kernel where this happens, some of which will yield memory leaks when tracing is enabled. I would say every utilization of all the tracing macros should be looked at.&lt;/p&gt;
&lt;p&gt;Some samples:&lt;/p&gt;
&lt;p&gt;zephyr/subsys/bluetooth/host/hci_core.c&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1733465018972v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;zephyr/subsys/bluetooth/host/classic/rfcomm.c&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1733465048014v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;zephyr/subsys/bluetooth/mesh/adv.c&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1733465139763v7.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/thread/513751?ContentTypeID=1</link><pubDate>Fri, 06 Dec 2024 05:49:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da7103a7-1b3b-4fbd-94fa-5da3391471c6</guid><dc:creator>anthony32086</dc:creator><description>&lt;p&gt;So turns out this is a zephyr bug from commit &lt;a href="https://github.com/nrfconnect/sdk-zephyr/commit/69fe9b0c5057c7bc5f932d5940afe2a26308593b#diff-774b3de86adb275da54becf2a0958a2d4dae03d63e47840037ecc575e9d658b4R395"&gt;69fe9b0&lt;/a&gt; which replaced the function call &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/0a2e205750dc7eff8767afa543b2fd23a1fbb332/lib/net_buf/buf.c#L446"&gt;&lt;span class="blob-code-inner blob-code-marker js-skip-tagsearch" data-code-marker="-"&gt;&lt;span class="pl-en x x-first x-last"&gt;net_buf_put&lt;/span&gt;&lt;/span&gt; &lt;/a&gt;with a macro call &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/998f7546a8b83b140794e9acc9d544df9435b34b/include/zephyr/kernel.h#L2541"&gt;&lt;span class="blob-code-inner blob-code-marker " data-code-marker="+"&gt;&lt;span class="pl-en x x-first x-last"&gt;k_fifo_put&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The problem being the second argument is a function call which gets repeated by preprocessor resulting in a double increment of the reference counter, which is unable to be freed.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:182px;max-width:477px;" alt=" " height="182" src="https://devzone.nordicsemi.com/resized-image/__size/954x364/__key/communityserver-discussions-components-files/4/pastedimage1733463796304v1.png" width="477" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Removing the function from the macro and setting a temporary value solves the problem.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:375px;max-width:483px;" alt=" " height="375" src="https://devzone.nordicsemi.com/resized-image/__size/966x750/__key/communityserver-discussions-components-files/4/pastedimage1733463856164v2.png" width="483" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/thread/513558?ContentTypeID=1</link><pubDate>Thu, 05 Dec 2024 08:07:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9c14e2a-0e21-4dcb-8792-24a5a91d559c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Yes, I agree with you, it looks like systemviewer is doing something with the buffer use. I do not see the same thing that you see and I am on latest version. Maybe there are some timing issues aswell. It is good that you are trying to get the whole picture of your application with systermviewer. Very few developers/architects do that these days. If you are unblocked with this workaround, then it should be good, just do not forget to undo this workaround in your release version.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/thread/513507?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2024 19:30:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23c7cc8c-cfa8-412d-8706-c7e56dcfd962</guid><dc:creator>anthony32086</dc:creator><description>&lt;p&gt;I&amp;#39;ve tried increasing the stack to 2048, and even 8192 for botth system workq and main stack both without success.I&amp;#39;ve also tried CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=8192 and CONFIG_SEGGER_SYSVIEW_RTT_BUFFER_SIZE=8192 which did not work.&lt;/p&gt;
&lt;p&gt;Interestingly I now get it to fail at &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/bluetooth/host/hci_core.c#L311"&gt;k_fifo_put(&amp;amp;bt_dev.cmd_tx_queue, net_buf_ref(buf));&lt;/a&gt; instead.Specifically the system is not locked up but when &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/bluetooth/host/hci_core.c#L4752"&gt;bt_tx_irq_raise()&lt;/a&gt; submit&amp;#39;s it&amp;#39;s work the system is stuck in endless idle waiting for something to complete.&lt;/p&gt;
&lt;p&gt;Replacing &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/tracing/sysview/tracing_sysview.h#L422"&gt;sys_port_trace_k_fifo_put_enter &lt;/a&gt;and &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/subsys/tracing/sysview/tracing_sysview.h#L426"&gt;sys_port_trace_k_fifo_put_exit &lt;/a&gt;with empty macros resolves the issue completely which makes me agree that sysview is doing something weird with buffer overruns corrupting the stack.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Systemview broken on SDK 2.8.0/Kernel 3.7.99</title><link>https://devzone.nordicsemi.com/thread/513432?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2024 13:07:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2a458e9-fa98-4a27-9a28-a4a78960943f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Just compiled this for nrf5340dk_nrf5340_cpuapp and running the debugger shows that it is not stuck at the shown function call that you pointed out.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1733317288594v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Tested on v2.8.0,&amp;nbsp; Not sure what is different on your end by try increasing the main stack size in case the 1024 bytes might be a border without enabling trace and systemview and when you enable it, it might cross that usage and causing some stack corruption.&lt;/p&gt;
&lt;p&gt;Add this in your prj.conf and pristine build it.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;CONFIG_MAIN_STACK_SIZE=2048&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>