|
From: | Noam weissman |
Subject: | [Savannah-hackers-public] memory leak or bad uasge ? |
Date: | Mon, 25 Feb 2013 16:49:53 +0200 |
Hi, I am running a simple TCP terminal server that works like a telnet server but with no Protocol. Actually a s simple TCP server. I use raw TCP terminal. It works ok but as far as I was able to spot I have memory leaks inside the LWIP stack. 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 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 client terminal. If I pass a large file larger than the command processor queue I need to stall the pBuf processing until some space Is freed in the command processor. If all is OK 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 more than 15-20 times. I have added error handling, polling, abort code etc… Nothing helped and after 20 or something iteration the TCP stoped working. Although the Stack should free all pBuf’s I added code to free the received pBuf in case of abort. I also added Freeing 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. Normally we work with an older stable version of LWIP (1.32 + FreeRTOS) I have tried using the latest version 1.41, I even added a few patches and installed the latest FreeRTOS but it behaves the same. I feel that something basic is not working properly inside LwIP. The code is running on STR91 with 96K RAM I have attached my TCP server source code + lwipopts.h 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. ************************************************************************************ |
tcp_term.rar
Description: tcp_term.rar
[Prev in Thread] | Current Thread | [Next in Thread] |