Skip to content

Hardening - #2

Merged
maximmenshikov merged 8 commits into
mainfrom
feature/harden2
Aug 5, 2026
Merged

maximmenshikov merged 8 commits into
mainfrom
feature/harden2

Conversation

@maximmenshikov

Copy link
Copy Markdown
Collaborator

No description provided.

Move all non-trivial uGC logic into plain C (ugc_core.c, ugc_zalloc.c) with ACSL
contracts so Frama-C can verify it with WP and Eva; the C++ classes uGCHeap,
uGCHandleStore and uGCHandleManager become thin wrappers over these functions.
The zeroing allocator lives in its own translation unit so the core is verified
against its contract only. Update build.sh and release.yml to pick up object
files from the new subdirectory.

Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Add a dependency-free test harness and CTest-driven suites covering the bump
allocator (refill, exact fit, overflow, bypass) and the handle store (creation
variants, dependent slots, exhaustion, slot CAS). The top-level CMakeLists gains
a UGC_BUILD_TESTS option and skips the ugc-zero library when
UGC_RUNTIME_INCLUDE_DIR is not set, enabling host-only test builds.

Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Add verify.sh, which proves the ACSL contracts of ugc/core with WP (failing
unless every goal is discharged) and runs Eva value analysis to check for
absence of runtime errors. Add eva_main.c, a Frama-C-only driver that exercises
allocation, handle store, and slot operations with unconstrained inputs.

Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Run unit tests on ubuntu with no sanitizer, ASan, and UBSan, and run the Frama-C
WP + Eva gate in a docker container alongside the riscv64 cross-build. Harden
the object-file check to fail when no .obj files are produced, and ignore the
build-tests and .frama-c directories.

Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Describe the ACSL-specified C core, host-side unit tests, and the Frama-C
verification gate (WP + Eva) added in recent commits, including local run
instructions via Docker.

Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Ship a prebuilt uGC archive for the riscv64 architecture so the library can be
deployed on RISC-V targets without building from source.

Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Handle slots were never reclaimed, so runtime GCHandle churn would exhaust the
fixed-capacity store. Add ugc_handle_destroy_at, which scrubs the slot, guards
against double destroy, and pushes the index on a free stack popped before the
array grows; wire it into the manager's destroy paths, give dependent handles a
HandleType, and extend the ACSL contracts, unit tests, and Eva harness.

Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Count bytes served by the slow-path Alloc (including per-context SOH/UOH
counters) and report them from GetTotalAllocatedBytes, GetTotalBytesInUse,
GetCurrentObjSize and GetMemoryInfo. Correct stub returns the BCL depends on:
MaxGeneration is 2, RegisterForFinalization and IsPromoted succeed,
WaitForFullGC* report not-applicable, and GetLOHThreshold reports the standard
large-object threshold.

Signed-off-by: Maxim Menshikov <maksim.menshikov@nethermind.io>
Comment thread .github/workflows/ci.yml
Comment on lines +17 to +42
name: Unit tests (${{ matrix.sanitizer }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sanitizer: [none, address, undefined]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Configure
run: |
if [ "${{ matrix.sanitizer }}" != "none" ]; then
export CFLAGS="-fsanitize=${{ matrix.sanitizer }} -fno-sanitize-recover=all -g"
export LDFLAGS="-fsanitize=${{ matrix.sanitizer }}"
fi
cmake -S . -B build-tests -DUGC_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug

- name: Build
run: cmake --build build-tests

- name: Run tests
run: ctest --test-dir build-tests --output-on-failure

formal-verification:
Comment thread .github/workflows/ci.yml Outdated
Comment on lines 60 to 99
@maximmenshikov
maximmenshikov merged commit 370e262 into main Aug 5, 2026
7 of 8 checks passed
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