buglwIP - A Lightweight TCP/IP stack - Bugs: bug #51122, Mismatched socket->fd_used...

 
 

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

bug #51122: Mismatched socket->fd_used accounting when using lwip_select

Submitter:  Tim Cussins <tcussins>
Submitted:  Fri 26 May 2017 04:41:47 PM UTC
   
 
Category:  sockets/netconn Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

Tue 13 Jun 2017 07:08:39 PM UTC, comment #5: 

Fixed in a slightly different way. I've also added a test case to check this.
Thanks for reporting.

Simon Goldschmidt <goldsimon>
Group administrator
Thu 01 Jun 2017 10:09:32 AM UTC, comment #4: 

I've just taken a look at our issues with ABC: It's unrelated to this bug (#51122).

The new bug is at #51154.

Tim Cussins <tcussins>
Wed 31 May 2017 02:58:44 PM UTC, comment #3: 

Tim,

Would you be able to open another bug for the TCP performance issue you're seeing

Joel Cunningham <jcunningham>
Group Member
Tue 30 May 2017 06:39:23 AM UTC, comment #2: 

Cool.

FYI: I've mentioned an ongoing problem with my benchmark - this appears to be caused by the Appropriate Byte Counting patch, which I've backed out locally until I can investigate further.

Tim Cussins <tcussins>
Mon 29 May 2017 07:58:52 PM UTC, comment #1: 

I see your point ;-)

Originally, tryget_socket_unconn() did not increase the use count... I'll have to find a nice fix for this. In the meantime, your patch should fix this good enough.

Simon Goldschmidt <goldsimon>
Group administrator
Fri 26 May 2017 04:41:47 PM UTC, original submission:  

Hi all,

I've had some trouble with LwIP of late. Recent snapshots, taken from the git head, have caused assertions in sock_inc_used().

I've completed a bisection this afternoon, and found that commit a38e937d introduces the problem.

Our configuration uses sockets extensively, and with LWIP_NETCONN_FULLDUPLEX - a configuration that has been stable until this patch.

I believe I've found part of the issue. As you may know,

lwip_select_inc_sockets_used_set()
and
lwip_select_dec_sockets_used()

are tasked with projecting fdset selections into the fd_used field of struct lwip_sock.

Unfortunately, both functions fail to anticipate that tryget_socket_unconn() will actually increment sock->fd_used. As such:

lwip_select_inc_sockets_used_set() calls tryget_socket_unconn() [+1], then sock_inc_used() explicitly [+1]. Net change = +2

lwip_select_dec_sockets_used() calls tryget_socket_unconn() [+1], before calling done_socket() [-1]. Net change = 0

See attached patch for an admittedly pretty awful correction.

I still have an issue wherein a tcp simple send benchmark stalls after ~40MB of data sent (recv remains ok), so this might not be a complete fix, or there may be another issue elsewhere.

Cheers!
Tim

Tim Cussins <tcussins>

 

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

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jcunningham (Posted a comment)
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by tcussins (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
    2017-06-13 goldsimon StatusNone Fixed
        Open/ClosedOpen Closed
    2017-05-29 goldsimon Assigned toNone goldsimon
    2017-05-26 tcussins Attached File- Added 0001-sockets.c-Fix-lwip_select-socket-usage-accounting.patch, #40794

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code