buglwIP - A Lightweight TCP/IP stack - Bugs: bug #38219, Assert on TCP netconn_write with...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #38219: Assert on TCP netconn_write with sndtimeout set

Submitter:  Marco Jakobs <marcoj>
Submitted:  Fri 01 Feb 2013 12:13:29 PM UTC
   
 
Category:  sockets/netconn Severity:  3 - Normal
Item Group:  Crash Error Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  1.4.1

Jump to the original submission

Tue 21 Oct 2014 09:10:46 AM UTC, comment #6: 

Yes. I've just committed the fix.

Simon Goldschmidt <goldsimon>
Group administrator
Tue 21 Oct 2014 08:47:42 AM UTC, comment #5: 

Hi,

since I got similar problems, it would be interesting for me, if the fix from Matthias is ok.

Sandra <blindcarboncopy>
Wed 27 Mar 2013 09:54:05 AM UTC, comment #4: 

Hi,

i've tried the fix from Matthias and it seems to also fix it in my environment.

@Core-team: Can we treat this as official fix or will it have any side effects?

Marco Jakobs <marcoj>
Mon 18 Feb 2013 01:29:26 PM UTC, comment #3: 

I also just ran into this issue. The assert triggers, because msg->conn->current_msg is 0, but msg->conn->write_offset is not.

I tried adding conn->write_offset = 0; in the partial write branch if do_write_more:

#if LWIP_SO_SNDTIMEO
  if ((conn->send_timeout != 0) &&
      ((s32_t)(sys_now() - conn->current_msg->msg.w.time_started) >= conn->send_timeout)) {
    write_finished = 1;
    if (conn->write_offset == 0) {
      /* nothing has been written */
      err = ERR_WOULDBLOCK;
      conn->current_msg->msg.w.len = 0;
    } else {
      /* partial write */
      err = ERR_OK;
      conn->current_msg->msg.w.len = conn->write_offset;
      conn->write_offset = 0; /* <= ADDED THIS */
    }
  } else
#endif /* LWIP_SO_SNDTIMEO */

Which seems to fix my problems.

Matthias Blaicher <mabl>
Fri 01 Feb 2013 01:54:21 PM UTC, comment #2: 

Ah, of course ... the connection is BLOCKING!

(Can't edit the entry below)

Marco Jakobs <marcoj>
Fri 01 Feb 2013 01:44:37 PM UTC, comment #1: 


> The sndtimeout of a nonblocking TCP connection (incoming) is set to 10ms.


From the post on lwip-users, I thought that the connection was blocking but with send-timeout instead of being nonblocking???

Simon Goldschmidt <goldsimon>
Group administrator
Fri 01 Feb 2013 12:13:29 PM UTC, original submission:  

The sndtimeout of a nonblocking TCP connection (incoming) is set to 10ms.

An application sends a large number of packets on this TCP connection which is using the internet, so ACK packets will need some time to return. So the outgoing TCP packets will fill up the buffer until no space is left.

At this point the next netconn_write will not be able to write its data within the set timeout of 10ms.

Expecting the netconn_write returning with an error (ERR_INPROGRESS), unfortunately i'll get an LWIP-assert in this scenario:

ASSERT: C:/Projekte/HCS-CPU2/Libraries/lwIP/src/api/api_msg.c:1357:already writing or closing

which points into the "do_write" function in api_msg.c

Additional info: Setting the timeout to 5000ms will make a short pause (blocking) at the same place where 10ms produces the assert, and then continue as soon as a buffer gets freed. This is just to prove that the assert is a result of the sndtimeout running off.

Marco Jakobs <marcoj>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by blindcarboncopy (Posted a comment)
  • -email is unavailable- added by mabl (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by marcoj
  • -email is unavailable- added by marcoj (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-10-21 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2013-02-01 marcoj Carbon-Copy- Added marcoj

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code