Skip to content

Fix package test stack overflow - #52

Merged
srpatcha merged 1 commit into
embeddedos-org:masterfrom
Sougata0100:fix/package-test-stack-overflow
Aug 29, 2026
Merged

srpatcha merged 1 commit into
embeddedos-org:masterfrom
Sougata0100:fix/package-test-stack-overflow

Conversation

@Sougata0100

Copy link
Copy Markdown
Contributor

Summary

Fixes a stack overflow issue in the package tests.

Changes

  • Changed EosPackageSet set from automatic (stack) storage to static storage in the affected package test functions.
  • This prevents the large EosPackageSet object from consuming excessive stack space during test execution.
  • No production eOS code was modified.

Testing

  • Ran the complete CTest suite.
  • 21/21 tests passed (100%).
  • Total test time: 1.32 seconds.

Commit

838b759 — Fix package test stack overflow

@srpatcha

Copy link
Copy Markdown
Member

Review — verified correct; overlaps with #48

Built merged onto current master: 24/24 ctest pass. The fix is right: sizeof(EosPackageSet) is ~3.9 MB and overflows the default 1 MB thread stack on Windows and other small-stack hosts.

Being straight with you: this change is byte-identical to the same hunk in #48 (I compared git blob hashes — both produce de4400a). #48 additionally carries a comment explaining why the sets are static, which is what stops someone reverting it later, so that is the one I'd suggest merging.

That does not make this PR wrong or unwelcome — you found a real defect and fixed it correctly, and you got there independently. Two options, both fine:

If you want a follow-up with more surface: tests/test_heap.c and several other test files have related issues, and 13 test files in tests/ are not registered in any CMakeLists.txt at all, so they have never been compiled or run.

@srpatcha

Copy link
Copy Markdown
Member

Same fix as #48, which just merged — yours was correct

You and #48 independently made the identical change: every EosPackageSet in tests/test_package.c moved from automatic to static. I verified both against master and both were green at 24/24.

I merged #48 for one reason, and it is not the code — the two diffs are byte-for-byte the same on every line that matters. #48 carries a comment explaining why:

EosPackageSet is EOS_MAX_PACKAGES * sizeof(EosPackage) = ~3.8 MB, which overflows the 1 MB default thread stack on Windows and on any other small-stack host, crashing these tests before main() gets to run them.

That is the part a future reader needs. A bare static on a test-local invites someone to "tidy" it back to an automatic and silently reintroduce the crash, and it also raises the obvious question of whether state now leaks between tests — which the same comment answers by pointing at the memset on entry.

Nothing wrong with this PR; it is a coin toss decided by documentation. The diagnosis was right and the fix was right.

If you would like a follow-up in the same area: cmd/eos/main.c declares the same type the same way, and there is no assertion anywhere that EosPackageSet stays within a sane size. A static assert on sizeof(EosPackageSet) would turn the next growth of EOS_MAX_PACKAGES into a compile error rather than a stack crash on one platform. Happy to review that if you want to pick it up.

@srpatcha
srpatcha self-requested a review August 29, 2026 06:21
@srpatcha
srpatcha merged commit 02b2674 into embeddedos-org:master Aug 29, 2026
7 of 24 checks passed
Aswin-V added a commit that referenced this pull request Oct 29, 2026
New docs/safety/robot-control-contract.md: the on-device contract
a real rover build must satisfy (companion to the EoSim cmd_vel/
odom adapter from EoSim #52). Every section is labelled READ or
PROPOSED: READ = verified from the step-1 sources below at eos
master ce2f110; PROPOSED = needs implementation and/or a
maintainer decision. No code file touched; no value in the
PROPOSED sections is a measurement.

Step-1 sources actually read: kernel/src/task.c,
kernel/include/eos/kernel.h, kernel/include/eos/kernel_internal.h,
kernel/src/sync.c, docs/safety/work-in-progress/iso26262/
safety_plan.md, docs/book/part7-advanced/ch35-safety.md,
services/os/include/eos/os_services.h, services/init/src/
service.c, eNI/common/src/stim_safety.c (BCI-only confirmation),
plus an eos code search for cmd_vel (0 hits at ce2f110).

Watchdog finding (read, not assumed): eos HAS watchdog surfaces
— services/os EosWatchdog API and services/init per-service
health-check watchdog (30 s default) — but NO robot velocity
watchdog: no cmd_vel consumer, no command-timeout to safe-stop
rule exists in eos. The doc's velocity watchdog (PROPOSED
T = 500 ms) is new contract composed from the existing
primitives, not a duplicate.

No #202 position taken: the doc records only the kernel wait
convention as read (EOS_NO_WAIT = 0, EOS_WAIT_FOREVER =
0xFFFFFFFF, sync.c honours both); the compat-layer timeout
question stays the maintainer's decision.

Also regen llms.txt + llms-full.txt in the same commit, per the
eos-mqtt-client-design precedent (c313e66): new doc added to
the Docs list, the llms-full Sources list, and appended as the
final section.

Refs #199 (programme context only; #199 is the MQTT tracker and
is NOT closed by a doc).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants