Repository navigation
fix(rtps): the QEMU restart case no longer runs the device out of internal RAM - #922
Merged
Merged
Conversation
…ernal RAM The QEMU matrix has failed on main since #909: its restart case tears the participant down and builds a new one while a dozen peers from the earlier cases are still announcing. The new participant discovers them all at once: the proxies (small allocations, internal RAM first) and lwIP's receive / reassembly buffers (internal-only by default) took the byte-addressable internal RAM a task stack needs, so the firmware's publish timer could not create its task (std::thread -> "pthread: Failed to create task!" -> abort with exceptions off). The device rebooted, QEMU's emulated chip cannot boot again from a software reset, and every later case failed with it. From the device log: endpoints used ~20 KB of internal RAM at first boot but ~84 KB after the restart (internal free 139 KB vs 75 KB, most of the latter IRAM, which stacks cannot use). #909's own CI run passed: the case was at the edge of the budget. - sdkconfig.defaults: CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y (lwIP from PSRAM first) and CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=65536 (twice the default kept for allocations that need internal RAM: FreeRTOS stacks, DMA). - The memory markers and the status line also report dram= / dram_min= / dram_largest= (internal AND 8-bit: what a stack comes from), since `internal` includes IRAM and hid the shortage. Appended, so the memory suite's parser is unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
|
✅Static analysis result - no issues found! ✅ |
rtps memory footprint (QEMU, esp32)Deltas in parentheses are against main @ e80f55a (run 45033145457): a bigger size or a smaller free heap than the baseline's is a cost of this change. librtps.a in the image (bytes,
|
| embedded | host | host_large | |
|---|---|---|---|
| flash code | 162,072 (-4) | 163,430 (-8) | 163,846 (+0) |
| flash data | 1,272 (+0) | 1,272 (+0) | 1,272 (+0) |
| DRAM (.data + .bss) | 126 (+0) | 126 (+0) | 126 (+0) |
| IRAM | 0 (+0) | 0 (+0) | 0 (+0) |
engine objects, sizeof (bytes; the Domain is allocated from the heap at start())
| object | embedded | host | host_large |
|---|---|---|---|
| rtps::Domain (holds every pool below) | 99,208 (+0) | 569,968 (+0) | 3,156,208 (+0) |
| rtps::Participant | 34,304 (+0) | 42,736 (+0) | 52,720 (+0) |
| rtps::StatefulWriter | 2,528 (+0) | 2,960 (+0) | 6,416 (+0) |
| rtps::StatelessWriter | 1,872 (+0) | 2,256 (+0) | 3,792 (+0) |
| rtps::StatefulReader | 1,968 (+0) | 2,008 (+0) | 2,104 (+0) |
| rtps::StatelessReader | 1,960 (+0) | 2,000 (+0) | 2,096 (+0) |
| espp::RtpsParticipant | 608 (+0) | 608 (+0) | 608 (+0) |
embedded: heap by stage (free bytes; a cost is a negative delta)
| stage | internal | delta | internal low-water mark | largest internal block | PSRAM | delta |
|---|---|---|---|---|---|---|
| boot | 220,279 (-264) | 218,168 (+700) | 131,072 | 4,191,440 (-100) | ||
| started | 160,371 (+908) | -59,908 | 159,800 (+2,620) | 73,728 | 4,090,192 (-856) | -101,248 |
| endpoints | 139,791 (+908) | -20,580 | 138,416 (+1,892) | 69,632 | 4,090,192 (-856) | +0 |
embedded: heap after each host-driven step (free bytes; deltas against the previous row; the pools are preallocated, so a peer costs little heap - the low-water mark shows the transients)
| step | internal | delta | internal low-water mark | largest internal block | PSRAM | delta |
|---|---|---|---|---|---|---|
| baseline | 133,255 (+432) | 130,860 (+1,800) | 69,632 | 4,090,224 (-824) | ||
| +1 remote participant (no match) | 133,123 (+420) | -132 | 126,360 (+2,324) | 69,632 | 4,090,224 (-824) | +0 |
| +1 more remote participant (no match) | 133,119 (+464) | -4 | 125,872 (+1,836) | 69,632 | 4,090,224 (-824) | +0 |
| +1 remote participant with a matched publisher | 133,091 (+464) | -28 | 123,300 (+1,856) | 69,632 | 4,090,224 (-824) | +0 |
| after a service call | 133,075 (+464) | -16 | 98,280 (+3,000) | 69,632 | 4,090,224 (-824) | +0 |
| after an action goal | 132,019 (+480) | -1,056 | 83,728 (-520) | 69,632 | 4,090,224 (-824) | +0 |
| after one 30 KB sample | 132,015 (+476) | -4 | 75,960 (+1,308) | 69,632 | 4,060,012 (-824) | -30,212 |
| all peers gone | 132,015 (+484) | +0 | 75,960 (+1,308) | 69,632 | 4,060,012 (-824) | +0 |
host: heap by stage (free bytes; a cost is a negative delta)
| stage | internal | delta | internal low-water mark | largest internal block | PSRAM | delta |
|---|---|---|---|---|---|---|
| boot | 219,047 (-264) | 216,936 (+700) | 131,072 | 4,191,440 (-100) | ||
| started | 130,459 (+372) | -88,588 | 129,676 (+1,168) | 69,632 | 3,617,120 (-840) | -574,320 |
| endpoints | 109,915 (+624) | -20,544 | 108,540 (+1,608) | 69,632 | 3,617,120 (-840) | +0 |
host_large: the participant did not start on this target - the profile does not fit (panicked while the engine was being built - internal RAM exhausted building the Domain's mutexes (the first error logged: [RtpsTransport/E][2.779]: Failed to create valid UDP socket for port 7401)); its sizeof is in the table above, the boot heap below
host_large: heap by stage (free bytes; a cost is a negative delta)
| stage | internal | delta | internal low-water mark | largest internal block | PSRAM | delta |
|---|---|---|---|---|---|---|
| boot | 219,047 (-264) | 218,320 (+720) | 131,072 | 4,191,440 (-100) | ||
| started | n/a | |||||
| endpoints | n/a |
The QEMU memory suite on eaf6716 (run); the full numbers are the run's rtps-memory artifact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The RTPS interop QEMU matrix (
qemu (matrix)) has failed on main since #909. Its 33 failures are one problem.The restart case tears the device's participant down and builds a new one, while about a dozen peers from the earlier cases are still announcing. The new participant discovers them all at once. Two things then took the byte-addressable internal RAM that a task stack needs:
The firmware's publish timer then could not create its task.
std::threadfailed withpthread: Failed to create task!, which aborts because exceptions are off. The device rebooted, QEMU's emulated chip cannot boot again after a software reset, and every later case failed with it.The cause, from the uploaded device log and a backtrace decoded against a local build of the same firmware (
app_main→espp::Timer→espp::Task::start→std::thread→ abort):#909's own CI run passed: the case was at the edge of the budget.
sdkconfig.defaults:CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y: lwIP allocates from PSRAM first.CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=65536: twice the default is kept for allocations that must be internal, such as FreeRTOS stacks and DMA.dram=/dram_min=/dram_largest=(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT, where a stack comes from). The existinginternalfigure includes IRAM, which is what hid the shortage. The new fields are appended, so the memory suite'sname=<digits>parser is unaffected.How has this been tested?
sdkconfig.defaults;sdkconfig.ci.defaults, IDF 6.1), and both settings are in the generated sdkconfig.Types of changes
Checklist:
.github/workflows/build.ymlfile to add my new test to the automated cloud build github action.🤖 Generated with Claude Code
https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU