<?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>peripheral-and-central-uart-sample-crash</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86647/peripheral-and-central-uart-sample-crash</link><description>Hi, 
 I did respond to this: 
 https://devzone.nordicsemi.com/f/nordic-q-a/86426/peripheral-and-central-uart-sample-crash-when-sending-longer-messages 
 I do not see a update on a response, maybe that im not part of this ticket ?? 
 Could you please have</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 19 Apr 2022 06:29:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86647/peripheral-and-central-uart-sample-crash" /><item><title>RE: peripheral-and-central-uart-sample-crash</title><link>https://devzone.nordicsemi.com/thread/363418?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 06:29:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10efbdc0-c36d-4e60-b113-3aa85c1739c4</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;We now have a pull request up with a fix for the double free issue in these samples.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/pull/7190"&gt;https://github.com/nrfconnect/sdk-nrf/pull/7190&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you for your patience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: peripheral-and-central-uart-sample-crash</title><link>https://devzone.nordicsemi.com/thread/362540?ContentTypeID=1</link><pubDate>Fri, 08 Apr 2022 09:53:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d017c1d-8d5f-4af0-9a45-62cbd8229f83</guid><dc:creator>TF mulder</dc:creator><description>&lt;p&gt;Ah Ok i see, thanks&lt;/p&gt;
&lt;p&gt;it is becoming more clear now&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: peripheral-and-central-uart-sample-crash</title><link>https://devzone.nordicsemi.com/thread/362515?ContentTypeID=1</link><pubDate>Fri, 08 Apr 2022 08:34:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4370120-0aad-4fe6-b331-25da4878a65b</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Great to see that you are trying to figure out what the issue is, but I unfortunately have to inform you that both those buffers already have an associated k_free().&lt;/p&gt;
&lt;p&gt;The buffers allocated in central_uart&amp;#39;s ble_data_received() and in peripheral_uart&amp;#39;s bt_receive_cb() are later passed to k_free in the UART_TX_DONE case of uart_cb().&lt;/p&gt;
&lt;p&gt;If you are seeing improvements from your changes, you should double check that uart_cb is getting the UART_TX_DONE event and freeing the buffer properly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: peripheral-and-central-uart-sample-crash</title><link>https://devzone.nordicsemi.com/thread/362418?ContentTypeID=1</link><pubDate>Thu, 07 Apr 2022 15:09:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e52c781f-bdc5-4a13-abaa-5cfc79ea00b1</guid><dc:creator>TF mulder</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/oivind"&gt;&amp;Oslash;ivind&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;I have now only removed the k_free(), to prevent the crash, at the beginning.&lt;/p&gt;
&lt;p&gt;After further working with the Central_uart AND the Peripheral_uart.. after some communication running it reveals an other-crash on both sides.&lt;/p&gt;
&lt;p&gt;I found a memory leakage situation&amp;nbsp; in the central AND in the peripheral...&lt;/p&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;-&amp;gt;in the central_uart:&amp;nbsp; in ble_data_received()&amp;nbsp; there is a&amp;nbsp;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;uart_data_t&lt;/span&gt;&lt;span&gt; *&lt;/span&gt;&lt;span&gt;tx&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;k_malloc&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;sizeof&lt;/span&gt;&lt;span&gt;(*&lt;/span&gt;&lt;span&gt;tx&lt;/span&gt;&lt;span&gt;));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;but there is no&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;k_free&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;tx&lt;/span&gt;&lt;span&gt;) ;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;-&amp;gt;in the periferal_uart in bt_recive_cb() there is a&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;uart_data_t&lt;/span&gt;&lt;span&gt;&amp;nbsp;*&lt;/span&gt;&lt;span&gt;tx&lt;/span&gt;&lt;span&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span&gt;k_malloc&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;sizeof&lt;/span&gt;&lt;span&gt;(*&lt;/span&gt;&lt;span&gt;tx&lt;/span&gt;&lt;span&gt;));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;but there is no&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;k_free&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;tx&lt;/span&gt;&lt;span&gt;) ;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;After i added these k_free()&amp;#39;s&amp;nbsp; &amp;nbsp;i had a continiously running communication...&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;-----&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Do i now have&amp;nbsp;earned a free nrf5340_DK board ?? :-),&amp;nbsp; or several nrf52840-dongles.. ?? :-)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Best Regards,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Theo&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;span&gt;&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: peripheral-and-central-uart-sample-crash</title><link>https://devzone.nordicsemi.com/thread/362078?ContentTypeID=1</link><pubDate>Wed, 06 Apr 2022 12:27:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a270bc48-3b61-425f-87f7-de38817032fe</guid><dc:creator>TF mulder</dc:creator><description>&lt;p&gt;Ok Thanks &lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/oivind"&gt;&amp;Oslash;ivind&lt;/a&gt;,&amp;nbsp; Looking forward to the update&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Theo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: peripheral-and-central-uart-sample-crash</title><link>https://devzone.nordicsemi.com/thread/362020?ContentTypeID=1</link><pubDate>Wed, 06 Apr 2022 09:37:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:772b62e1-a83e-45b9-ac82-f743f7b530cf</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As I said in the ticket you linked, we are working on a fix and I will update you when I have more to share.&lt;/p&gt;
&lt;blockquote&gt;
&lt;div&gt;&lt;span&gt;probably not THE sollution, but when i empty (remove the code) of&amp;nbsp; the routine:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;static&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;ble_data_sent&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;bt_nus_client&lt;/span&gt;&lt;span&gt; *&lt;/span&gt;&lt;span&gt;nus&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;err&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt; *&lt;/span&gt;&lt;span&gt;const&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;uint16_t&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;len&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;the the crash is gone, and the send data i see on the peripheral.&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;...but,&amp;nbsp; probably i have now a missing feature ????&amp;nbsp;&lt;/div&gt;
&lt;/blockquote&gt;
&lt;p&gt;Removing the k_sem_give() in that callback would not be good, but it looks like it would mostly slow the sample down and produce a lot of warnings.&lt;/p&gt;
&lt;p&gt;Removing the rest of the code, along with the k_free() would cause a memory leak and the sample would crash after enough messages were sent.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>