Solved pkg upgrade error, Segmentation fault

Code:
% sudo pkg upgrade
......

Number of packages to be removed: 6
Number of packages to be installed: 93
Number of packages to be upgraded: 459
Number of packages to be reinstalled: 51

The process will require 3 GiB more space.

Proceed with this action? [y/N]: y
Child process pid=52144 terminated abnormally: Segmentation fault
The system is 14.2. I've tried pkg clean -a, deleting pkg and reinstalling pkg, and the error persists.
Please help.
 
Number of packages to be upgraded: 459
That looks like a lot of packages to be upgraded. Is this after a major version upgrade? Or haven't you updated in quite a while? In any case, even with a large number of packages to upgrade it shouldn't crash. Is there a core dump perhaps? You might be able to figure out why it crashed by analyzing the core dump.
 
I haven't run into this but a segmentation fault wrt to pkg has been reported: PR 287738; it is now in progress.

What might help, try this first: sudo pkg upgrade -r FreeBSD pkg. Then the rest of the upgrades.
Please report back if this works or not.

Note that, when using 14.2-RELEASE, be extra careful to get the latest version (=highest numbered version) of all relevant packages containing kernel modules, such as (graphics) packages like graphics/drm-61-kmod or packages containing kernel modules for relevant wireless drivers, matched to your specific minor version.

If you built such packages yourself on 14.2-RELEASE, for example graphics/drm-61-kmod, you'll get the correct version.

If you use packages, you should use the FreeBSD-kmods repository; by default, not enabled on 14.2-RELEASE. For information about the FreeBSD-kmods, see thread, message #66 and subsequent messages.

Having an enabled FreeBSD-kmods repository, upgrading of packages can be a problem. Using a two-step upgrade process has always worked reliably for me*:
pkg upgrade -r FreeBSD
pkg upgrade -r FreeBSD-kmods


Recently a new pkg version was released:
ports-mgmt/pkg: update to 2.2.1 - 2025-06-27 09:11:01

For the supported 14.2-RELEASE and 14.3-RELEASE it is at the moment only available as a package using Latest.
On 14.2-R or 14.3-RELEASE using Quarterly:
Rich (BB code):
[0-0] # date -u
Wed Jul  2 06:34:25 UTC 2025
[1-0] # pkg rquery -e '%n = pkg' '[%R] %n %v'
[FreeBSD] pkg 2.2.0

On 14.2-R or 14.3-RELEASE using Latest:
Rich (BB code):
[10-0] # pkg rquery -e '%n = pkg' '[%R] %n %v'
[FreeBSD] pkg 2.2.1

With the new quarter 2025Q3 having just started, I'm expecting it to appear on Quarterly soon.

___
* EDIT
Note: this is not how it should be; it should be sufficient to just use: sudo pkg upgrade
Unfortunately, pkg does not handle multiple enabled repositories well in all cases; we're all waiting for this to be resolved.
 
I encountered this recently within a jail that was upgraded from 14.2 to 14.3-RELEASE.
IIRC it boiled down to pkg being unable to solve some recursive dependencies and version conflicts ("A depends on B but B v2 conflicts with installed B v1.9 and B v2 wants A installed" or something like that...) and just crashed (same with pkg-static).
I resolved it by manually re-installing some ports from pkg prime-list by hand and trying to pkg upgrade -f after each manual upgrade. At some point it suddenly worked without pkg falling over. You could also try to just feed the prime-list to 'pkg install -f'.

(I prefer to run pkg upgrade -f after release upgrades; my buildhost re-builds all packages on the new release anyways)
 
I encountered this recently within a jail that was upgraded from 14.2 to 14.3-RELEASE.
Do you happen to know which pkg version you were using when executing the initial pkg upgrade ... command? This would be particularly relevant when using pkg v. 2.2.1.

We've gone from 2.2.0 to 2.2.1 in a very short time; I'm expecting 2.2.2 coming up rather quickly; PR 287738 has been reported as being actively worked on.
 
Sorry, I really can't remember - but from the timeframe and version history of pkg it must have been version 2.1.4 or 2.2.0.

The initial upgrade of 'pkg' went through (to 2.2.0) and then it failed at the following bulk upgrade of all other packages.
 
I just upgraded to 14.3, pkg upgrade still gives me segmentation fault. Then,
Code:
# pkg upgrade -r FreeBSD pkg
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
FreeBSD is up to date.
Checking integrity... done (0 conflicting)
Your packages are up to date.

pkg upgrade -r FreeBSD behaves same as pkg upgrade. And,
Code:
# pkg upgrade -r FreeBSD-kmods
Updating FreeBSD-kmods repository catalogue...
FreeBSD-kmods repository is up to date.
FreeBSD-kmods is up to date.
Checking for upgrades (0 candidates): 100%
Processing candidates (0 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.
 
I got a segfault attempting to upgrade a 14.3-RELEASE to 15-CURRENT using PkgBase.
As all is experimental, the very idea to complain didn't come to me.

What I believe is that pkg is in rapid development phase. The new versions come very often and you have to expect more bugs.
 
Two completely different systems, same problem when trying to update packages after updating from 14.2-RELEASE to 14.3-RELEASE. For my desktop system I ended up removing all packages and reinstalling from my prime-list by hand. That worked except for several packages that triggered glib-schemas.ucl. When that happened the shell would lock up after displaying this:

Code:
==> Running trigger: glib-schemas.ucl
Compiling glib schemas
Warning: Schema �org.gnome.system.locale�/system/locale/�/apps/�/desktop/�/system/�org.gnome.system.proxy�/system/proxy/�/apps/�/desktop/�/system/�org.gnome.system.proxy.http�/system/proxy/http/�/apps/�/desktop/�/system/�org.gnome.system.proxy.https�/system/proxy/https/�/apps/�/desktop/�/system/�org.gnome.system.proxy.ftp�/system/proxy/ftp/�/apps/�/desktop/�/system/�org.gnome.system.proxy.socks�/system/proxy/socks/�/apps/�/desktop/�/system/

My laptop is still in the pkg segmentation faulting state. I came here hoping for a solution. I haven't decided if I'm going to do the manual package remove and install again or perhaps just wait for a later version of pkg.
I decided try Kalabic's suggestion of building the latest version of pkg and so far it seems to be working...
Code:
[315/2519]...
 
Back
Top