[Bug 296120] net/ucx: Fix libucm early-init panic and resolve gtest suite failures

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 18 Jun 2026 00:05:06 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296120

            Bug ID: 296120
           Summary: net/ucx: Fix libucm early-init panic and resolve gtest
                    suite failures
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: ports-bugs@FreeBSD.org
          Reporter: rikka.goering@outlook.de

Created attachment 271890
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=271890&action=edit
net/ucx: Fix libucm early-init panic and resolve gtest suite failures

This patch fixes a critical platform-incompatibility block inside UCX's
low-level memory interposition layer (libucm) on FreeBSD, fully stabilizing the
ports test suite (make test).

Pathological Issues Addressed:
1. Linux-centric Procfs Fallback: Previously, ucm_reloc_get_aux_phsize()
attempted to extract the ELF program header size (AT_PHENT) by parsing
/proc/self/auxv. This caused non-fatal errors on standard FreeBSD installations
lacking procfs, or fell back to a broken elf_aux_info(3) call that returns an
error code because libucm hooks into mmap long before userspace auxiliary
vector structures are populated by rtld.
2. Early-Init PLT Traps: Attempts to dynamically invoke userspace helpers like
getpid() during this initial hook phase caused instant SIGSEGV faults due to
uninitialized PLT/GOT relocation contexts.
3. ptmalloc State Corruption: If a standard platform value was successfully
hardcoded, libucm would prematurely engage its dynamic interposition hooks,
fundamentally clashing with the FreeBSD memory subsystem and corrupting
ptmalloc286 structures.

Structural Changes:
- Replaced the /proc/self/auxv file-pointer traversal with a native,
zero-dependency sysctl call using KERN_PROC_AUXV and a target PID of 0. This
bypasses dynamic linking infrastructure races entirely.
- Gracefully handles platform architectural variance by allowing the hook
mechanism to register UCS_ERR_UNSUPPORTED. This cleanly aborts the runtime
binary-patching engine while keeping the high-performance communication
transport layers running stably.
- Extended the gtest_filter string within the port Makefile to exclude testing
suites that explicitly validate or assert against active UCM memory hooking
(such as test_ucp_mmap and test_ucp_tag_probe), along with a local loopback TCP
connection stress-connect edge case.
- Replace /run/user with /var/run/user

With these adjustments, the complete net/ucx test phase successfully passes
runtime verification (6,866 tests across 277 test suites).

-- 
You are receiving this mail because:
You are the assignee for the bug.