Skip to content

Implement heap integrity testing and add PMM stub for memory management#9

Merged
Zaid-maker merged 2 commits intomainfrom
heap-tests
Mar 31, 2026
Merged

Implement heap integrity testing and add PMM stub for memory management#9
Zaid-maker merged 2 commits intomainfrom
heap-tests

Conversation

@Zaid-maker
Copy link
Copy Markdown
Owner

@Zaid-maker Zaid-maker commented Mar 31, 2026

Summary by CodeRabbit

  • Tests
    • Added an automated heap integrity test suite that injects corruption to verify allocator integrity detection (corrupted headers, alignment issues, unmerged free blocks, pointer regressions).
  • Build / Chores
    • Test and coverage targets updated to build/run the new integrity tests and include them in coverage runs.
  • Documentation
    • Docs and README updated to document the new tests and local build/test steps.
  • Release
    • Kernel version incremented.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ccdf6f0a-585e-40c7-81cb-ad6f775f0cec

📥 Commits

Reviewing files that changed from the base of the PR and between c32e3ab and 49a244f.

📒 Files selected for processing (4)
  • README.md
  • kernel/VERSION
  • site/docs.html
  • site/index.html

📝 Walkthrough

Walkthrough

Adds conditional heap test hooks and a host-side heap integrity test binary plus a PMM stub, updates Makefile to build/run these tests and include them in coverage, and documents the new test artifacts and version bump.

Changes

Cohort / File(s) Summary
Build Configuration
kernel/Makefile
Adds building and running of heap_integrity_test and coverage-instrumented heap_integrity_test_cov; compiles src/heap.c with -DHEAP_ENABLE_TEST_HOOKS for host tests and includes tests/pmm_stub.c in test/link units.
Heap Test Hooks
kernel/src/heap.c, kernel/src/heap.h
Introduces HEAP_ENABLE_TEST_HOOKS-guarded test scaffold: in-memory test arena, tracking arrays, and five debug APIs (heap_debug_seed_chain, heap_debug_corrupt_magic, heap_debug_misalign_size, heap_debug_make_next_regression, heap_debug_clear_chain) for seeding and mutating heap state.
Tests & Stubs
kernel/tests/heap_integrity_test.c, kernel/tests/pmm_stub.c
Adds host test program that seeds chains, injects corruptions, calls heap_check_integrity() and asserts counters; adds minimal PMM stub implementing pmm_initialize/alloc/free/get_stats for test isolation.
Docs & Metadata
README.md, site/*.html, kernel/VERSION
Updates build instructions, project layout and docs to include heap diagnostics/tests; updates site pages and increments kernel/VERSION to v0.0.20260331.1.

Sequence Diagram(s)

sequenceDiagram
    participant Test as "heap_integrity_test (host)"
    participant Heap as "kernel/src/heap (test hooks)"
    participant Checker as "heap_check_integrity"
    participant PMM as "pmm_stub"

    Test->>Heap: heap_debug_seed_chain(sizes, free_flags, count)
    Note right of Heap: builds synthetic blocks in test arena
    Test->>Heap: (optionally) heap_debug_corrupt_magic/index/misalign/next_regression
    Test->>Checker: heap_check_integrity(&report)
    Checker->>Heap: read block headers/pointers
    Checker->>PMM: (if queried) pmm_get_stats()
    Checker-->>Test: report (pass/fail, counters)
    Test->>Heap: heap_debug_clear_chain()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I stitched a chain of blocks in sand and stone,
I nudged a magic byte to dance alone,
The checker sniffed the spoor and raised a bell—
Hooray, the rabbit found the bug and rang it well! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: implementing heap integrity testing and adding a PMM stub for memory management, matching the changeset content.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch heap-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.42857% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.47%. Comparing base (ce60547) to head (c32e3ab).

Files with missing lines Patch % Lines
kernel/src/heap.c 91.42% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main       #9       +/-   ##
===========================================
- Coverage   99.26%   67.47%   -31.80%     
===========================================
  Files           3        4        +1     
  Lines         136      289      +153     
===========================================
+ Hits          135      195       +60     
- Misses          1       94       +93     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Zaid-maker Zaid-maker merged commit 2ca716c into main Mar 31, 2026
3 checks passed
@Zaid-maker Zaid-maker deleted the heap-tests branch March 31, 2026 17:53
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