lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] memory leaking inside LwIP ?


From: Noam weissman
Subject: [lwip-users] memory leaking inside LwIP ?
Date: Thu, 21 Mar 2013 10:54:44 +0200

Hi,

 

I have a new/old problem.

 

1.

I am running a simple TCP terminal server that works like a telnet server but with no Protocol.

It works ok but as far as I was able to spot I have memory leaks inside the LWIP stack. This was observed

when lots of data was sent to the server.

 

My server accepts a pBuf and process it. The transferred data in that pBuf is simple text lines. My server reads

char by char and when it finds a CR it copies this string to a command processor (text parser). This text parser reads

the text and if necessary sends some data back to the connected client terminal.

 

The command processor is running at a separate thread.

 

If I pass a large file larger than the command processor queue data is lost.

 

I added code to stall the pBuf processing until some space Is freed in the command processor.

That means I do not free the accepted pBuf until It is processed.

 

That means the original pBuf is not immediately freed and at the same time the command processor sends data

to the client TCP terminal. The pBuf is eventually freed after all the data is processed or if there is an error etc…

 

All is well so far.

 

If I disconnect the terminal (connected to my server) either in the middle of the file transfer or even if I wait to the file

end I can do that about 15-20 times. I have added error handling, polling, abort code etc…

 

Nothing helped so far and after 20 or something iteration the TCP stopped working.

 

Although the Stack should free all pBuf’s I added code to free the received pBuf in case of abort. I also added f

reeing the recived pBuf in all the cases (abort, close or error).

 

Adding that extra freeing stopped the server from being completely un-responsive but it is not able to send large amount

of data.

 

All the above suggests that memory handling is not working properly inside LwIP and therefore it is leaking. Another

option is that I am not handling properly LwIP call back’s ???

 

Normally we work with an older stable version of LWIP (1.32 + FreeRTOS 6.05)

 

I have tried using the latest LwIP version 1.41 and also the latest FreeRTOS (7.4) but it behaves the same.

 

I feel that something basic is not working properly inside LwIP.

 

The code was tested STR912 or STM32F207

 

I have attached my TCP server source code + lwipopts.h

 

2.

When I tested the code on the STM32F207 with all the latest updates I found another problem:

 

> in file tcp_out.c in line 937:

>

>  if (useg != NULL) {

>    for (; useg->next != NULL; useg = useg->next);

>

>

In some cases useg and useg-next points to the same value. That means an endless loop ???

 

 

Any input will help.

 

Thanks,

Noam.

 

 





************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************


reply via email to

[Prev in Thread] Current Thread [Next in Thread]