Ethernet problem, application crash, problem in NutTcpReceive

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Ethernet problem, application crash, problem in NutTcpReceive

Michael Fischer
Hello Uwe,

>I compiled for the STM32F746 Discovery and can start and stop iperf2
>runs without crashes. Do crashes happen for you on the F7 disco?
I can reproduce the crash here too with the F7 disco board. With the patch it works.

Attached is my patch too.

Best regards,
Michael

-------------- next part --------------
diff -Naur nut-r6730/nut/net/tcpsock.c nut-r6730-new/nut/net/tcpsock.c
--- nut-r6730/nut/net/tcpsock.c 2017-04-13 16:05:46.000000000 +0200
+++ nut-r6730-new/nut/net/tcpsock.c 2018-12-02 17:11:52.662014000 +0100
@@ -637,6 +637,14 @@
             return 0;
     }
 
+
+    /* Check again for terminated connection with empty buffer */
+    if ((sock->so_state != TCPS_ESTABLISHED) && (NULL == sock->so_rx_buf)) {
+        sock->so_last_error = ENOTCONN;
+        return -1;
+    }
+
+
     if (size > sock->so_rx_cnt - sock->so_rd_cnt)
         size = sock->so_rx_cnt - sock->so_rd_cnt;
     if (size) {
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Ethernet problem, application crash, problem in NutTcpReceive

Thiago A. Corrêa
I also had to patch tcpsm.c with:

===================================================================
--- tcpsm.c (revision 6727)
+++ tcpsm.c (working copy)
@@ -1943,8 +1943,8 @@
     NutEventBroadcast(&sock->so_ac_tq);
     /* Check if we had a timeout on NutTcpConnect(). In this case there is no
        need for a notification of the select wait queues.
-     */
-    if (!((current_state == TCPS_SYN_SENT) && (last_error == ETIMEDOUT))) {
+    */
+    if (!(current_state == TCPS_SYN_SENT)) {
         /* Wake up all running selects on this socket */
         NutSelectWakeup(sock->so_rx_wq_list, WQ_FLAG_READ);
         NutSelectWakeup(sock->so_tx_wq_list, WQ_FLAG_WRITE);

Was having a crash related to the socket not being signaled as
disconnected and all available memory would be allocated for
retransmissions. I was using select(), not sure if it would only
happen with programs using the newer select api.
It was fairly simple to reproduce using Clumsy and configuring a
packet loss between 3% and 5%


On Sun, Dec 2, 2018 at 2:24 PM Michael Fischer <[hidden email]> wrote:

>
> Hello Uwe,
>
> >I compiled for the STM32F746 Discovery and can start and stop iperf2
> >runs without crashes. Do crashes happen for you on the F7 disco?
> I can reproduce the crash here too with the F7 disco board. With the patch it works.
>
> Attached is my patch too.
>
> Best regards,
> Michael
>
> -------------- next part --------------
> diff -Naur nut-r6730/nut/net/tcpsock.c nut-r6730-new/nut/net/tcpsock.c
> --- nut-r6730/nut/net/tcpsock.c 2017-04-13 16:05:46.000000000 +0200
> +++ nut-r6730-new/nut/net/tcpsock.c     2018-12-02 17:11:52.662014000 +0100
> @@ -637,6 +637,14 @@
>              return 0;
>      }
>
> +
> +    /* Check again for terminated connection with empty buffer */
> +    if ((sock->so_state != TCPS_ESTABLISHED) && (NULL == sock->so_rx_buf)) {
> +        sock->so_last_error = ENOTCONN;
> +        return -1;
> +    }
> +
> +
>      if (size > sock->so_rx_cnt - sock->so_rd_cnt)
>          size = sock->so_rx_cnt - sock->so_rd_cnt;
>      if (size) {
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Ethernet problem, application crash, problem in NutTcpReceive

Uwe Bonnes
Hello Thiago and Michael,

do you think both patches are necessary? Can you perhaps try to
reproduce the error with the patch of the other applied and without
your own patch applied and report?

Thanks
--
Uwe Bonnes                [hidden email]

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Ethernet problem, application crash, problem in NutTcpReceive

Michael Fischer
In reply to this post by Michael Fischer
Hello,

the patch from Thiago does not solve the problem here.

Best regards,
Michael
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion
Reply | Threaded
Open this post in threaded view
|

Re: Ethernet problem, application crash, problem in NutTcpReceive

Thiago A. Corrêa
From what I can tell, both patches should be necessary and they are
both "corner cases", they fix different crashes. The one I sent looks
like manifests only if your application uses select, and Michaels
should be time sensitive. The one I sent improved the crash we saw on
the field by a lot. In the end I reworked the code to use UDP instead
of TCP and it was the end of the issue in that particular case.

Do you both still see crashes on TCP applications? Can you provide any
details that I could use to reproduce the problem?

Kind Regards,
    Thiago A. Correa


On Thu, Dec 6, 2018 at 3:09 PM Michael Fischer <[hidden email]> wrote:
>
> Hello,
>
> the patch from Thiago does not solve the problem here.
>
> Best regards,
> Michael
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion