You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Again, this reaches router->sendLocal() while router thread may run doRetransmissions().
Notes
ESP32 NimBLE path seems intentionally marshaled to main task and may not have this issue:
src/nimble/NimbleBluetooth.cpp:407
src/nimble/NimbleBluetooth.cpp:166
src/nimble/NimbleBluetooth.cpp:305
So the ESP32 confirmed risk seems tied to additional RTOS tasks (e.g. AudioModule), not necessarily NimBLE ToRadio handling.
Potential impact
If this is valid, possible symptoms could include:
intermittent retransmission state corruption
dropped/extra retransmissions
occasional hard-to-reproduce instability under traffic
Questions
Is there an existing single-threading guarantee for all calls that can touch retransmission state that I missed?
Would maintainers prefer:
a mutex around pending access, or
marshaling all router send/retransmission mutations onto one execution context?
Are there known bugs/crashes that might correlate with this path?
Prompt used to generate similar analysis
Review Meshtastic firmware routing code for thread concurrency hazards around retransmission state.
Focus on NextHopRouter::pending access paths and determine whether accesses can occur concurrently across target builds.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. I asked an ai to analyze some things, and it came up with this. Is this worth pursuing?
Summary
NextHopRouter::pendingappears to be accessed from multiple execution contexts without synchronization.pendingis astd::unordered_map:src/mesh/NextHopRouter.h:98It is mutated in:
startRetransmission()atsrc/mesh/NextHopRouter.cpp:249stopRetransmission()atsrc/mesh/NextHopRouter.cpp:217It is iterated/erased in:
doRetransmissions()atsrc/mesh/NextHopRouter.cpp:265I do not see locking around these operations.
Confirmed concurrent-risk builds
1)
ARCH_NRF52with BLE enablednRF52 BLE write callback calls
PhoneAPI::handleToRadio()directly in BLE context:src/platform/nrf52/NRF52Bluetooth.cpp:158src/platform/nrf52/NRF52Bluetooth.cpp:164That path reaches:
MeshService::handleToRadio()src/mesh/MeshService.cpp:177MeshService::sendToMesh()src/mesh/MeshService.cpp:245router->sendLocal()src/mesh/MeshService.cpp:251At the same time, router retransmissions are processed in router/main scheduler path:
NextHopRouter::runOnce()src/mesh/NextHopRouter.h:77doRetransmissions()src/mesh/NextHopRouter.cpp:265src/main.cpp:1189This appears to permit concurrent access to
pending.2)
ARCH_ESP32when AudioModule is enabled (USE_SX1280and!MESHTASTIC_EXCLUDE_AUDIO)AudioModule creates a separate FreeRTOS task:
src/modules/esp32/AudioModule.cpp:115That task sends packets:
run_codec2callssendPayload()src/modules/esp32/AudioModule.cpp:65sendPayload()callsservice->sendToMesh()src/modules/esp32/AudioModule.cpp:268Again, this reaches
router->sendLocal()while router thread may rundoRetransmissions().Notes
src/nimble/NimbleBluetooth.cpp:407src/nimble/NimbleBluetooth.cpp:166src/nimble/NimbleBluetooth.cpp:305So the ESP32 confirmed risk seems tied to additional RTOS tasks (e.g. AudioModule), not necessarily NimBLE ToRadio handling.
Potential impact
If this is valid, possible symptoms could include:
Questions
pendingaccess, orPrompt used to generate similar analysis
Beta Was this translation helpful? Give feedback.
All reactions