Skip to content

Commit bb4ff33

Browse files
committed
DYMO: fix: double-free of RREQ wait timer when route discovery is exhausted
processRreqWaitRrepTimer() deletes the wait-timer message at the end of the method. On the final retry (retryCount == discoveryAttemptsMax - 1) it also called deleteRreqTimer(target), which does `delete targetAddressToRREQTimer[target]` -- and that entry IS the message being processed -- so the message was freed twice (and `target`, a reference into the message, dangled for the rest of the branch). This corrupts the heap and crashes; it triggers whenever a route discovery runs out of attempts, e.g. once nodes shut down in the DynamicIPv6 scenario. Drop the redundant cancel/delete of the timer in that branch (the message is deleted at the end) and take `target` by value. Enables the manetrouting/dymo DynamicIPv6 fingerprint example (was ERROR, "IPv6: Shutdown not supported"). Recorded with tplx;~tNl;tyf like its siblings (DYMO has no packet serializer, so ~tND is not applicable).
1 parent dfe270b commit bb4ff33

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/inet/routing/dymo/Dymo.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,13 @@ void Dymo::scheduleRreqWaitRrepTimer(RreqWaitRrepTimer *message)
304304
void Dymo::processRreqWaitRrepTimer(RreqWaitRrepTimer *message)
305305
{
306306
EV_DETAIL << "Processing RREQ wait RREP timer" << endl;
307-
const L3Address& target = message->getTarget();
307+
// Note: 'message' is the timer stored in targetAddressToRREQTimer[target] and is
308+
// deleted at the end of this method, so we must not delete it via deleteRreqTimer()
309+
// here (that would double-free it). We also take 'target' by value because the
310+
// reference would dangle once 'message' is deleted.
311+
const L3Address target = message->getTarget();
308312
if (message->getRetryCount() == discoveryAttemptsMax - 1) {
309313
cancelRouteDiscovery(target);
310-
cancelRreqTimer(target);
311-
deleteRreqTimer(target);
312314
eraseRreqTimer(target);
313315
scheduleRreqHolddownTimer(createRreqHolddownTimer(target));
314316
}

tests/fingerprint/examples.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@
357357
/examples/manetrouting/dymo/, -f omnetpp.ini -c MultiGeneric -r 0, 10s, 0354-6dd4/tplx;735c-957d/~tNl;31f0-2788/tyf, PASS, wireless adhoc
358358
# /examples/manetrouting/dymo/, -f omnetpp.ini -c _Dynamic -r 0 # abstract-config
359359
/examples/manetrouting/dymo/, -f omnetpp.ini -c DynamicIPv4 -r 0, 22s, 2f57-3280/tplx;8f96-3d9c/~tNl;c33f-4f8c/tyf, PASS, wireless adhoc Ipv4
360-
/examples/manetrouting/dymo/, -f omnetpp.ini -c DynamicIPv6 -r 0, 22s, 5fe9-22ea/tplx;0000-0000/~tNl;0000-0000/~tND, ERROR, wireless adhoc # IPv6: Shutdown not supported
360+
/examples/manetrouting/dymo/, -f omnetpp.ini -c DynamicIPv6 -r 0, 22s, 1e32-4f69/tplx;c684-e25f/~tNl;3469-a611/tyf, PASS, wireless adhoc
361361
/examples/manetrouting/dymo/, -f omnetpp.ini -c DynamicGeneric -r 0, 22s, b68e-dfe3/tplx;9c68-c2d4/~tNl;8c4d-6bc7/tyf, PASS, wireless adhoc
362362

363363
# /examples/manetrouting/gpsr/, -f omnetpp.ini -c Random -r 0, # abstract-config

0 commit comments

Comments
 (0)