LWIP assertion triggers after +10 hours
Posted: Tue Dec 17, 2019 2:34 pm
I have a UDP server, receiving a stream a calculating the jitter to send a package back after 50 packets received.
My application must run indefinitely, but after more than 3 hours the following assertion gests triggered.
My application must run indefinitely, but after more than 3 hours the following assertion gests triggered.
assertion "pbuf_free: p->ref > 0" failed: file "/home/user/esp/esp-idf/components/lwip/lwip/src/core/pbuf.c", line 757, function: pbuf_free
abort() was called at PC 0x4016d06b on core 0
0x4016d06b: __assert_func at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/assert.c:62 (discriminator 8)
ELF file SHA256: e8aca13bf40ee60f6921fe1cd7ee8f2fb5c34c654f2ed21fd7527937fa2bcde3
Backtrace: 0x40094995:0x3ffcbca0 0x40094d85:0x3ffcbcc0 0x4016d06b:0x3ffcbce0 0x40091dee:0x3ffcbd10 0x4009173e:0x3ffcbd30 0x4009277f:0x3ffcbd50 0x400dc77b:0x3ffcbdb0 0x4009824d:0x3ffcc780
0x40094995: invoke_abort at /home/user/esp/esp-idf/components/esp32/panic.c:157
0x40094d85: abort at /home/user/esp/esp-idf/components/esp32/panic.c:174
0x4016d06b: __assert_func at /builds/idf/crosstool-NG/.build/xtensa-esp32-elf/src/newlib/newlib/libc/stdlib/assert.c:62 (discriminator 8)
0x40091dee: pbuf_free at /home/user/esp/esp-idf/components/lwip/lwip/src/core/pbuf.c:757 (discriminator 1)
0x4009173e: netbuf_free at /home/user/esp/esp-idf/components/lwip/lwip/src/api/netbuf.c:131
0x4009277f: lwip_sendto at /home/user/esp/esp-idf/components/lwip/lwip/src/api/sockets.c:1678
0x400dc77b: sendto at /home/user/esp/esp-idf/components/lwip/lwip/src/include/lwip/sockets.h:654
(inlined by) tUDPserver(void*) at /home/user/esp/UDP/build/../main/main.cpp:766
0x4009824d: vPortTaskWrapper at /home/user/esp/esp-idf/components/freertos/port.c:143
Code: Select all
void tUDPserver(void *pvParameters)
{
struct sockaddr_in udpAddr;
udpAddr.sin_addr.s_addr = htonl(INADDR_ANY);
udpAddr.sin_family = AF_INET;
udpAddr.sin_port = htons(cam->client_rtp_port);
int sock_udp;
source stream;
rtcp_rr_t rr;
uint8_t cont_pqtes = 0;
uint8_t rx_data[2048] = {0};
int32_t rx_size = 0;
while (1) {
if (sock_udp < 0)
{
sock_udp = socket(udpAddr.sin_family, SOCK_DGRAM, IPPROTO_IP);
if (sock_udp < 0) {
ESP_LOGE(tag, "Unable to create socket RTP_server: %d : %s", errno, strerror(errno));
close_socket(&sock_udp);
continue;
}
ESP_LOGI(tag, "Socket created");
int err = bind(cam->sock_udp, (struct sockaddr *)&udpAddr, sizeof(udpAddr));
if (err < 0) {
ESP_LOGE(tag, "Socket unable to bind", errno, strerror(errno));
close_socket(&cam->sock_udp);
continue;
}
} else ESP_LOGW (tag, "Socket is open");
while (1)
{
struct sockaddr_in6 source_addr; // Large enough for both IPv4 or IPv6
socklen_t socklen = sizeof(source_addr);
rx_size = recvfrom(cam->sock_udp, rx_data, sizeof(rx_data) - 1, 0, (struct sockaddr *)&source_addr, &socklen);
// Error occured during receiving
if (rx_size < 0) {
ESP_LOGE(tag, "recvfrom udp failed: %d : %s", errno, strerror(errno));
break;
}
else {
cal_jitter(&stream, &rr, &rtp_hdr, esp_timer_get_time()/1000);
cont_pqtes ++;
// Send reciever report
if (cont_pqtes >= 50){
rr.ssrc = rtp_hdr.ssrc;
uint8_t buff_report [32];
uint8_t len_buf = reciever_report(&stream, &rr, buff_report, sizeof(buff_report));
cont_pqtes = 0;
// Send data
int err = sendto(cam->sock_udp, buff_report, len_buf, 0, (struct sockaddr *)&source_addr, sizeof(source_addr));
if (err < 0) {
ESP_LOGE(tag, "Error Sending ReceiverRepor failed: %d : %s", errno, strerror(errno));
}
}
}
}
}
vTaskDelete(NULL);
}