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

Submitted by:  Tim Cussins <tcussins>
Submitted on:  Fri 26 May 2017 04:41:47 PM UTC  
 
Category: sockets/netconnSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned 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>
Project AdministratorIn charge of this item.
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>
Project 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>
Project AdministratorIn charge of this item.
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>

 

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jcunningham (Posted a comment)
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by tcussins (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 13 Jun 2017 07:08:39 PM UTCgoldsimonStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Mon 29 May 2017 07:58:52 PM UTCgoldsimonAssigned toNone=>goldsimon
    Fri 26 May 2017 04:41:47 PM UTCtcussinsAttached File-=>Added 0001-sockets.c-Fix-lwip_select-socket-usage-accounting.patch, #40794

    Back to the top


    Powered by Savane 3.1-cleanup1