[En-Nut-Discussion] Ethernet problem, application crash, problem in NutTcpReceive
bon at elektron.ikp.physik.tu-darmstadt.de
bon at elektron.ikp.physik.tu-darmstadt.de
Sun Dec 2 12:52:21 CET 2018
Michael Fischer writes:
> Hello List,
>
> for the test I use the trunk version 6699 and a STM3240G-EVAL board.
> The application was compiled in debug mode with the GNU Arm Embedded Toolchain
> in version 7-2017-q4.
Strange, version 6699 is on Philips branch for lm3s.
>
> The application is the iperf application for testing the Ethernet performance.
> Some more infos about JPerf can be find here on my page, which was done with lwIP:
> https://www.emb4fun.de/projects/tctsallwipuhttp/index.html
>
> JPerf, version 2.0.2, can be find here:
> https://code.google.com/archive/p/xjperf/
>
The link gives 404.
I tried iperf3 first, but could not get it to talk to the test
program. With much fiddling, I was able to find and setup iperf and
jperf in version 2
> The application I used for NutOS was attached at the end of this description too.
>
> The application does not use DHCP, it use a static IP-Adress, 192.168.1.200.
> With the JPerf GUI it is possible to use one or more stream to connect with the
> target. If the JPerf GUI is started with the "Run IPerf!" button it runs 10 seconds
> and stop automatically.
>
> This makes no problem if one or more streams are used. The application can handle up
> to 4 streams in parallel.
>
> How to produce the error?
>
> Start the JPerf with the "Run IPerf!" button, do not wait the 10 seconds, it should
> not stop automatically. Stop manually with the "Stop IPerf" button.
>
> Now the application crash, and stops in IntBusfaultHandler.
>
I tested on a Nucleo F767 with svn head and version 6700 and in no
situation could reproduce the error.
> The problem is a NULL pointer access in the while loop in NutTcpReceive:
>
> ab_cnt = 0;
> while (ab_cnt < size) {
> nb = sock->so_rx_buf;
> nb_cnt = nb->nb_ap.sz - rd_cnt;
> mv_cnt = size - ab_cnt;
>
> nb is NULL here.
>
> The problem can be fixed with the following code after the first while loop:
>
> /*
> * Wait until any data arrived, a timeout occurs
> * or the connection terminates.
> */
> while (sock->so_rx_cnt - sock->so_rd_cnt == 0) {
> if (sock->so_state != TCPS_ESTABLISHED) {
> sock->so_last_error = ENOTCONN;
> return -1;
> }
> if (NutEventWait(&sock->so_rx_tq, sock->so_read_to))
> return 0;
> }
>
> /* @@MF start: Check for terminated connection with empty buffer */
> if ((sock->so_state != TCPS_ESTABLISHED) && (NULL == sock->so_rx_buf)) {
> sock->so_last_error = ENOTCONN;
> printf(".");
> return -1;
> }
> /* @@MF end */
>
Please, provide a diff. Textual descripton of what to change in some
code is error prone.
Even if I can not reproduces, I will consider applying.
I also consider to put your programm into the app directory as
iperf2_server. Does that naming sound right for you. I think, the
program implements an iperf server, and at the moment only for iperf2.
Bye
--
Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------
More information about the En-Nut-Discussion
mailing list