Tool/software: Code Composer Studio
Hello!
I work on project where custom board based on TM4C129K MCU is connecting to external device via TCP/IP. The traffic is rather big - device sends me data at up to 125kb/sec, but controlling traffic from my board to device is not big.
Rarely (about once per couple of days) I got hard fault inside tcp_output() function:
if (TCP_TCPLEN(seg) > 0) { seg->next = NULL; /* unacked list is empty? */ if (pcb->unacked == NULL) { pcb->unacked = seg; useg = seg; /* unacked list is not empty? */ } else { /* In the case of fast retransmit, the packet should not go to the tail * of the unacked queue, but rather somewhere before it. We need to check for * this case. -STJ Jul 27, 2004 */ if (TCP_SEQ_LT(ntohl(seg->tcphdr->seqno), ntohl(useg->tcphdr->seqno))) { /* add segment to before tail of unacked list, keeping the list sorted */ struct tcp_seg **cur_seg = &(pcb->unacked); while (*cur_seg && TCP_SEQ_LT(ntohl((*cur_seg)->tcphdr->seqno), ntohl(seg->tcphdr->seqno))) { cur_seg = &((*cur_seg)->next ); } seg->next = (*cur_seg); (*cur_seg) = seg; } else { /* add segment to tail of unacked list */ useg->next = seg; useg = useg->next; // <---- HERE! } } /* do not queue empty segments on the unacked list */ } else { tcp_seg_free(seg); } seg = pcb->unsent;
in the line
useg = useg->next;
and useg here is ether 0 of corrupt.
Asked on lwip support forum, but they said the version of lwip is old and is a port by TI, so I should ask TI engineers.
Currently device is stopped in debug state right after hard fault, so I can browse any variables or memory.
The heap state at time of fault is ok, as I embedded heap checking in hard fault ISR.