[Bug 287720] ports-mgmt/pkg: segfault if calledwith root privileleges

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 22 Jun 2025 12:47:36 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=287720

            Bug ID: 287720
           Summary: ports-mgmt/pkg: segfault if calledwith root
                    privileleges
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: pkg@FreeBSD.org
          Reporter: alexey@ocaml.nl
             Flags: maintainer-feedback?(pkg@FreeBSD.org)
          Assignee: pkg@FreeBSD.org

I have a really strange problem. It appeared on one of my 14.3-RELEASE machines
after source upgrade. Another machine underwent the same upgrade, albeit in
binary way (via freebsd-update) and has no such problem.

🌐 eldanna in ~ took 3h57m37s
❯ sudo pkg-static upgrade -f pkg
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
Updating FreeBSD-kmods repository catalogue...
FreeBSD-kmods repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The following 1 package(s) will be affected (of 0 checked):

Installed packages to be REINSTALLED:
        pkg-2.2.0 [FreeBSD]

Number of packages to be reinstalled: 1

Proceed with this action? [y/N]: y
[1/1] Reinstalling pkg-2.2.0...
[1/1] Extracting pkg-2.2.0: 100%
You may need to manually remove /usr/local/etc/pkg.conf if it is no longer
needed.
🌐 eldanna in ~ took 4s
❯ /usr/local/sbin/pkg search foobar
🌐 eldanna in ~
❯ sudo !!
sudo /usr/local/sbin/pkg search foobar
Child process pid=71720 terminated abnormally: Segmentation fault
🌐 eldanna in ~
❯ freebsd-version
14.3-RELEASE

Core file is mostly useless:
❯ sudo gdb -core pkg.core
[...]
[New LWP 1048325]
Core was generated by `pkg search foobar'.
Program terminated with signal SIGSEGV, Segmentation fault.
Address not mapped to object.
#0  0x00000008279bb8da in ?? ()
GNU gdb (GDB) 15.1 [GDB v15.1 for FreeBSD]
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd14.2".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".

Segfault happens after every operation, performed as root, but the operation
itself is first performed.

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