boards/esp32-devkitc: Let ostest finish on the knsh configuration - #19790
Merged
Conversation
A full ostest run never reached the end on esp32-devkitc:knsh. It stopped in the barrier test: barrier_test: ERROR thread 6 create, status=12 ostest_main: Exiting with status 256 The cause is the interaction of two settings that are each reasonable on their own. CONFIG_TLS_ALIGNED is set and CONFIG_TLS_LOG2_MAXSTACK is 13, so every pthread stack must start on an 8 KiB boundary. The barrier threads take the 2 KiB default stack, so each one occupies an 8 KiB aligned slot. Eight of them do not fit the 96 KiB user heap of a protected build once the tests before them have fragmented it, and up_create_stack() fails: up_create_stack: ERROR: Failed to allocate stack, size 2048 The flat build has the same two settings and passes, because its heap is 320 KiB against 96 KiB here. So this lowers the barrier thread count for this configuration only. Four threads still test a barrier, and they leave margin: six was the most that ever started, so six would pass with none. The user heap cannot grow far. User data has to sit in the MMU governed window of SRAM2, which is 128 KiB in total, and the kernel holds the first 32 KiB of it. Verified on an ESP32-DevKitC V4, ESP32-D0WD-V3 revision 3.1. All four threads reach the barrier and ostest reports "Exiting with status 0". Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
xiaoxiang781216
approved these changes
Aug 11, 2026
acassis
approved these changes
Aug 11, 2026
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.
Summary
A full
ostestrun never reached the end onesp32-devkitc:knsh. It stopped in the barrier test:This lowers the barrier thread count for that configuration, and the run completes.
Cause
Two settings that are each reasonable on their own.
CONFIG_TLS_ALIGNEDis set andCONFIG_TLS_LOG2_MAXSTACKis 13, so every pthread stack must begin on an 8 KiB boundary. The barrier threads take the 2 KiB default stack, so each one occupies an 8 KiB aligned slot — four times what it uses.A protected build has a 96 KiB user heap. Eight aligned slots do not fit it once the tests before the barrier have fragmented it, and the allocation fails:
The flat build has the same two settings and passes, because its heap is 320 KiB against 96 KiB here. That is the whole difference.
Two things this is not, both measured rather than assumed. It is not the user heap running out: 75,544 bytes were free with a 47,096 byte largest block when a 2048 byte request failed. It is not the kernel heap: raising
CONFIG_MM_KERNEL_HEAPSIZEfrom 8 KiB to 32 KiB changed nothing, and the failure stayed on thread 6 exactly.Why not grow the heap instead
The user heap cannot grow far. User data has to sit in the MMU governed window of SRAM2,
0x3ffc0000to0x3ffdffff, which is 128 KiB in total, and the kernel currently holds the first 32 KiB of it. Recovering that would move the kernel/user boundary and the per-page access rights inesp32_userspace.c, which is a larger change to an experimental subsystem and does not belong in a fix for a test configuration.Four threads still test a barrier. They also leave margin: six was the most that ever started, so six would pass with none at all.
Testing
Board: ESP32-DevKitC V4, with an ESP32-D0WD-V3 revision 3.1.
Host: macOS 15 on Apple Silicon,
xtensa-esp32-elf-gcc12.2.0.Configured from the edited
defconfigafter adistclean, so the result comes from the committed file:Before this change the same board and toolchain gave
Exiting with status 256.tools/checkpatch.sh -c -u -m -greports no errors.