lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] lwip 1.4.1 pcb->next != pcb assert


From: Markus Pischinger
Subject: Re: [lwip-users] lwip 1.4.1 pcb->next != pcb assert
Date: Fri, 1 Sep 2017 09:24:16 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

Thanks Simon!

I've gone through my project and resolved some issues and the pbc->next ! pcb hasn't appeared anymore. In the process i also updated to lwip 2.0.2.
But i've got another issue now.. My device is listening to port 502 and as soon as someone connects and it starts receiving packages i get:
Assertion "pbuf_free: p->ref > 0" failed at line 747 in ../src/ASF/thirdparty/lwip/lwip-2.0.2/src/core/pbuf.c
and sometimes even p!=NULL in pbuf.c. All my lwip tasks are called from the mainloop where the low_level_input is beeing polled and forwarded to netif->input (i'm using the netif_input function). My application is initialised with:
pcb = tcp_new()
tcp_bind(pcb,IP_ADDR_ANY, 502)
pcb = tcp_listen_with_backlog(pcb,5) //as far as i've understood this limits the number of connections to 5?
tcp_accept(pcb, accept_callback)
In the Accept callback i just assign a receive_callback and a poll_callback. If all pcb's are !=NULL and therefore beeing used i call tcp_close(pcb).
Now here comes the receive_callback which i think throws the p->ref > 0 error sometimes:
if(p==NULL) return close_conn(); //calls tcp_close and returns ERR_CLSD
copy payload to buffer and check, if somethings wrong (too much data e.g.) close connection.
pbuf_free(p); //called at the end
My application sends back data from a function called from mainloop which uses:
if(tcp_sndbuf(pcb) >= length){
    if(tcp_write(pcb, ..) == ERR_OK){
        tcp_output(pcb);
    }
}
Other than that my application has got 2 timer interrupts which i need for other hardware tasks. I've got SYS_LIGHTWEIGHT_PROT set to 1 and sys_arch_protect() disables interrupts.

Thanks in advance,
Markus

Am 31.08.2017 um 21:09 schrieb address@hidden:
Markus Pischinger wrote:
LWIP_ASSERT("tcp_input: pcb->next != pcb (before cache)", pcb->next != pcb);

Normally, this is a strong indication that you are violating lwIP's threading requirements. Read http://www.nongnu.org/lwip/2_0_x/pitfalls.html

Simon


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users


reply via email to

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