lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] double free errors


From: Diego Guglielmi
Subject: [lwip-users] double free errors
Date: Thu, 29 Aug 2019 20:57:59 -0300

Hi i'm having some serious trouble developing a modbus server in lwip using raw api, basically i got the server answering the requests, the problem is that seemingly at random i get the following

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

The interesting part is that it seems to do so when closing a connection due to an error if im not mistaken
i put a breakpoint where the message is produced and got the following call stack

mem_free (void * rmem) Line: 717 pbuf_free (struct pbuf * p) Line: 780 tcp_seg_free (struct tcp_seg * seg) Line: 1631 tcp_segs_free (struct tcp_seg * seg) Line: 1616 tcp_pcb_purge (struct tcp_pcb * pcb, struct tcp_pcb * pcb@entry) Line: 2169 tcp_pcb_purge (struct tcp_pcb * pcb) Line: 2139 tcp_pcb_remove (struct tcp_pcb ** pcblist, struct tcp_pcb * pcb, struct tcp_pcb * pcb@entry) Line: 2191 tcp_input (struct pbuf * p, struct pbuf * p@entry, struct netif * inp, struct netif * inp@entry) Line: 448 ip4_input (struct pbuf * p, struct pbuf * p@entry, struct netif * inp, struct netif * inp@entry) Line: 709 ethernet_input (struct pbuf * p, struct netif * netif) Line: 186 ethernetif_input (struct netif * netif) Line: 788 ethernet_task Line: 247 main Line: 929

so maybe this is related to lwipopts rather than the app?

the lwipopts file is the following


#define LWIP_NETIF_HOSTNAME 1 #define LWIP_NETIF_API 0 #define LWIP_NETIF_STATUS_CALLBACK 1 #define LWIP_NETIF_LINK_CALLBACK 1 #define LWIP_SOCKET 0 #define LWIP_NETCONN 0 #define SO_REUSE 1 #define LWIP_IGMP 1 //#include <stmlib/rand.h> //#define LWIP_RAND rand_value #define LWIP_STATS 1 #define LWIP_STATS_DISPLAY 1 extern int printf(const char *format, ...); #define LWIP_PLATFORM_DIAG(x) {printf x;} #define LWIP_DEBUG #define LWIP_NOASSERT #define LWIP_DBG_TYPES_ON (LWIP_DBG_STATE | LWIP_DBG_ON) #define ETHARP_DEBUG LWIP_DBG_OFF #define NETIF_DEBUG LWIP_DBG_OFF #define DHCP_DEBUG LWIP_DBG_OFF #define AUTOIP_DEBUG LWIP_DBG_OFF #define IGMP_DEBUG LWIP_DBG_OFF #define IP_DEBUG LWIP_DBG_OFF #define PBUF_DEBUG LWIP_DBG_LEVEL_SERIOUS #define MEM_DEBUG LWIP_DBG_LEVEL_SERIOUS #define SIMPLE_DISCOVERY_DEBUG LWIP_DBG_LEVEL_SERIOUS #define TCP_TMR_INTERVAL 10
attached are the application files 
if anyone can provide any lead i would be really grateful since i've been stuck with this for a while and i don't think i know the innards of lwip good enough to track this

modbusBal.h is the one that handles the queued packets

also i know this code isn't really clean and tidy, this is my first lwip app and initially i just want to get it working more or less reliably
best, diego

Attachment: modbusTcp.h
Description: Text Data

Attachment: modbusBal.h
Description: Text Data

Attachment: modbusTcp.c
Description: Text Data


reply via email to

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