buglwIP - A Lightweight TCP/IP stack - Bugs: bug #52112, Unavoidable hazards when calling...

 
 

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

bug #52112: Unavoidable hazards when calling tcp_close from callback

Submitted by:  Ambroz Bizjak <abizjak>
Submitted on:  Mon 25 Sep 2017 06:39:05 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: None
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned Release: None
lwIP version: git head

Mon 25 Sep 2017 07:24:52 PM UTC, comment #3:

This has indeed been buggy with older releases.

Simon Goldschmidt <goldsimon>
Project Administrator
Mon 25 Sep 2017 07:22:17 PM UTC, comment #2:

Please close this, I don't seem to be able to.

Ambroz Bizjak <abizjak>
Mon 25 Sep 2017 07:21:01 PM UTC, comment #1:

I see that lwIP avoids freeing the PCB from tcp_close when called from tcp_input, so the correct approach is to return ERR_ABRT if and only if the application called tcp_abort. I must have seen the "tcp_close freeing PCB" issue with an older lwIP version and chose to return ERR_ABRT whenever I called tcp_close and this became broken with newer lwIP.

Ambroz Bizjak <abizjak>
Mon 25 Sep 2017 06:39:05 PM UTC, original submission:

Consider an application calling tcp_close from one of the PCB callbacks, where tcp_close succeeds. In this case the application can either return ERR_ABRT or not. It seems to me that either way things break.

- If the application does not return ERR_ABRT: There are cases where tcp_close frees the PCB, but since the callback does not return ERR_ABRT, lwIP will try to access the freed PCB.

- If the application returns ERR_ABRT: Consider the case where tcp_close_shutdown called tcp_trigger_input_pcb_close(), having removed the PCB from tcp_active pcbs but not freeing it. Since the callback returned ERR_ABRT, tcp_input_delayed_close() is inhibited and the PCB is leaked.

My application is currently taking the second approach and I am seeing leaked PCBs. I have not proven this is the same leak but I see no other way for a PCB to be leaked.

Ambroz Bizjak <abizjak>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by dziegel (Updated the item)
  • -unavailable- added by abizjak (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 25 Sep 2017 07:24:52 PM UTCgoldsimonStatusInvalid=>None
    Mon 25 Sep 2017 07:23:22 PM UTCdziegelStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1