lwipUDP: fix pbuf leak in endPacket() and uninitialised members #560
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 401 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.359
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #560"
general
weight: 0.35
facchinm
Problem
On the Portenta C33,
WiFiUDPstops sending after roughly a hundred datagrams. From then onendPacket()returns 0 for every packet, whileWiFi.status()still reportsWL_CONNECTED.lwipUDP::endPacket()clears its pointer after a successfuludp_sendto()without freeing the pbuf:udp_sendto()does not take ownership of the pbuf, so each datagram leaks one. When the lwIP heap is used up,write()can no longer allocate and sending stops.Changes
1.
endPacket(): callpbuf_free(_data)after a successfuludp_sendto(). It uses the same__disable_irq()/__enable_irq()guard as the other pbuf calls in this file. A singlepbuf_free()is used (notpbuffer_free_data(), which loops until the pbuf is gone) so that a reference lwIP may still hold, for example in the ARP queue, stays valid.2. Constructor: initialise
_port,_data,_remainingand the POD members of_udp. The constructor was empty, so an instance that is not zero-filled (created withnewor on the stack) could start with a garbage_udp.pcb.begin()then returns 0 because it believes a socket is already open.Both changes are in
libraries/lwIpWrapper/src/lwipUDP.cpp. Each is its own commit.Test
Portenta C33, core 1.6.0 (same commit as current
main), Wi-Fi, no shield or other hardware attached. The sketch sends one ~55 byte line every 200 ms and prints its own counters. A PC on the same network counts the datagrams it receives.| | Board counters | Received on the PC |
|---|---|---|
| Core 1.6.0, unmodified |
sentstops at 111, every later packet fails | 111, then nothing || With the
endPacket()change | 526 sent, 0 failed (stopped by hand after ~2 min) | 100% of the 449 produced while the receiver ran |Serial output, unmodified core:
Serial output, with the change: