buglwIP - A Lightweight TCP/IP stack - Bugs: bug #62749, Memory leak in tcp_write

 
 

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

bug #62749: Memory leak in tcp_write

Submitter:  Bill Auerbach <billauerbach>
Submitted:  Mon 11 Jul 2022 06:58:43 PM UTC
   
 
Category:  TCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Invalid
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  2.1.3

Tue 12 Jul 2022 07:51:53 PM UTC, comment #3: 

I'm glad it's not a bug (other than yet another occurrence of us having too much options that are not handled correctly)

Simon Goldschmidt <goldsimon>
Group administrator
Tue 12 Jul 2022 05:36:18 PM UTC, comment #2: 

This bug can be deleted.  Xilinx neglected to

#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1

which I'm sure they never noticed or no one else noticed due to what it takes to cause a problem. We've been running tests for 3 months before we hit it.

Note this finding is in SDK 2019.1 and so it may have been fixed.

Sorry for the noise - I was following the debug output messages...

Bill Auerbach <billauerbach>
Mon 11 Jul 2022 08:25:14 PM UTC, comment #1: 

I've added more debug information and run into a memory error:

mem_free: illegal memory: non-linked: double free?

Called from tcp_free_acked_segments

Bill Auerbach <billauerbach>
Mon 11 Jul 2022 06:58:43 PM UTC, original submission:  

Platform: Xilinx Zynq 7030 ARM with lwIP RAW API and NO_SYS=1. Not using LIBC_MALLOC. There are a 8k of pbufs and MEM_SIZE is 128k. The hardware descriptor RX size was increased to 1k.

On a 1Gb connection at very high burst receive rates seen only connected to a 10Gb switch, tcp_output and/or tcp_write will not release its pbuf mem_alloced payload. This payload is lost causing an out of memory in tcp_write after many hours into a run.

Communications entail receiving 1200-1500 packets with a single ~300 byte payload return. The memory leak is 320 bytes. PC Task Manager shows average NIC output at 500-700Mbs. This leak doesn't occur at slower speeds.

The rate of packets is crucial. Connections to a 1Gb switch do not show a problem. When this leak occurs there are no mem stat or link errors (although hours into the run I've seen mem stats illegal have a count). These errors occur before that.

I see the leak logging lwip_stats.mem.avail which is slowly growing by 320 bytes. It is program speed related as well.  Running lwip and the BSP in debug mode doesn't produce the error. At least not within the hour.

I've wondered if we didn't handle the TCP ACK for this packet and it's payload isn't being freed.

In order to be able to ship a system running at this speed, we are trying to work around this by not using TCP_WRITE_FLAG_COPY.

Bill Auerbach <billauerbach>

 

(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 goldsimon (Posted a comment)
  • -email is unavailable- added by billauerbach (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-07-12 goldsimon StatusNone Invalid
        Assigned toNone goldsimon
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code