Repository navigation
fix(foundation): use HW_PHYSMEM for physical memory detection on FreeBSD - #1093
Conversation
Signed-off-by: Pedro Ramos <[email protected]>
|
Thanks for the focused FreeBSD fix and the on-platform validation. FreeBSD's current sys/sysctl.h defines HW_PHYSMEM for this MIB and not HW_PHYSMEM64, so the direction is correct. I have triaged this as a high-priority 0.9.1-rc stability bug. The one-line diff adds no dependency, network, secret, or broader runtime surface. The remaining blocker is the repository's reproduce-first requirement: the PR currently has no automated guard that fails on main. Because the normal matrix has no FreeBSD runner, please add the smallest testable regression or propose a narrow test seam for the MIB-selection contract before changing CI. Do not add a new workflow or dependency without design approval. The unrelated Perl/ASan duplicate-symbol problem should stay outside this PR. |
|
I've updated the PR with a regression test for The original issue is a compile-time regression on FreeBSD ( Here is the test suite output running and passing successfully on FreeBSD: |
Signed-off-by: Pedro Ramos <[email protected]>
de6c1af to
62808da
Compare
|
I've updated the PR with an optional, non-intrusive production hardening option in When enabled via
The implementation keeps upstream impact minimal:
I verified this locally on FreeBSD 15.1: gmake -f Makefile.cbm clean-c
gmake -f Makefile.cbm cbm FREEBSD_HARDENING=1The resulting ELF binary was verified with: readelf -d build/c/codebase-memory-mcp | grep BIND_NOWOutput: and: readelf -l build/c/codebase-memory-mcp | grep GNU_RELROOutput: The same option was also tested successfully with: gmake -f Makefile.cbm cbm-with-ui FREEBSD_HARDENING=1 |
Add .github/workflows/freebsd.yml, a standalone workflow triggered only by workflow_dispatch. It builds the UI-embedded binary inside FreeBSD 15.1 and 14.4 x86_64 VMs (vmactions/freebsd-vm, full-SHA pin to v1.5.9) with the canonical scripts/build.sh and runs the binary with --version. It declares read-only permissions, uploads and publishes nothing, is not part of ci-ok and is not called by release.yml or dry-run.yml, so a FreeBSD red never gates a pull request or a release. scripts/env.sh now detects FreeBSD and selects gmake there (BSD make cannot read the GNU make syntax of Makefile.cbm) and make everywhere else; the environment summary line reports the choice. scripts/build.sh runs $MAKE at all three build call sites. macOS, Linux and Windows still run make, so their builds are unchanged. Distilled from #1422 by PR9000: the release matrix, the x86_64-host choice, the aarch64 exclusion, the vmactions VM approach with a SHA pin, fail-fast: false and the gmake detection all come from that pull request, which built on the FreeBSD groundwork of #1093, #1423 and #1467. Co-authored-by: Pedro Ramos <[email protected]> Signed-off-by: Martin Vogel <[email protected]>
What does this PR do?
This PR fixes physical memory detection on FreeBSD by using the standard
HW_PHYSMEMsysctl indetect_system_bsd().On FreeBSD 15.1-STABLE, the current implementation using
HW_PHYSMEM64does not return the expected physical memory size during system initialization. This change routes FreeBSD through the existingHW_PHYSMEMcode path already used by OpenBSD.Changes
src/foundation/system_info.c.to:
so FreeBSD uses
HW_PHYSMEMfor physical memory detection.Testing
Tested on FreeBSD 15.1-STABLE (amd64).
Validation performed:
codebase-memory-mcpusing:Result:
The test suite was also executed:
gmake -f Makefile.cbm testHowever, the test build currently fails during linking with an unrelated AddressSanitizer duplicate symbol error:
This failure is independent from this change and occurs in the test infrastructure/linking stage before the tests are executed.
Why this is safe
This is a small, localized, platform-specific change affecting only the FreeBSD BSD implementation path.
Linux, macOS, Windows, and other supported platforms are unaffected. The change reuses the existing
HW_PHYSMEMimplementation already used for OpenBSD and does not modify the behavior of other operating systems.Checklist
git commit -s) — required, CI rejects unsigned commits ([DCO](../DCO), see [CONTRIBUTING.md](../CONTRIBUTING.md))make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)