# Upgrading Packages After a Major Version Upgrade, Seg Fault



## BostonBSD (Apr 15, 2021)

I just did an upgrade from 12.2 to 13.0, following Ch 24 of the handbook, everything went well enough until:
`pkg-static upgrade -f`


```
root@BostonBSD:~ # pkg-static upgrade -f
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (1351 candidates): 100%
Processing candidates (1351 candidates): 100%
Child process pid=88745 terminated abnormally: Segmentation fault
```
It downloaded all of the packages due to the ABI change, same versions different ABI, however it has trouble installing them.

This is pkg:

```
root@BostonBSD:~ # pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (1342 candidates): 100%
Processing candidates (1342 candidates): 100%
Cannot solve problem using SAT solver, trying another plan
Child process pid=89083 terminated abnormally: Segmentation fault
```

I suppose I could do a fresh install from an image file, however, I am wondering if this is correctable?

It only seems like some sort of an issue with pkg.


----------



## bakul (Apr 15, 2021)

I believe you have to do `pkg bootstrap -f`


----------



## VladiBG (Apr 15, 2021)

use pkg-static only to upgrade the pkg to the new version.



> *pkg-static* is a statically linked vari-
> ant of *pkg*    typically only used for    the initial installation of *pkg*.


----------



## BostonBSD (Apr 15, 2021)

As I am doing this in console I cannot give a screen grab, however, I performed
`pkg -d upgrade -f`
(debug option)


and discovered pkg was leaving a core dump while processing texlive-texmf (a very very very large package), so I removed that package and ran

`pkg -d upgrade -f`

again and it appears to be working, I am watching it currently.


----------



## BostonBSD (Apr 15, 2021)

So everything finished perfectly.  However, this one package, texlive-texmf, causes pkg to seg fault, upon trying to install it afterwards.

It is a huge package, several gigabytes, perhaps there is something different since the older version of pkg which renders it unable to handle packages of this magnitude.



```
root@BostonBSD:~ # pkg install texlive-texmf
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Child process pid=31660 terminated abnormally: Segmentation fault
```

texlive-full has the same outcome.


```
root@BostonBSD:~ # pkg install texlive-full
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Child process pid=34717 terminated abnormally: Segmentation fault
```

Given that this used to work with the older version of pkg in 12.2, I think this is a problem with pkg [or possibly 13.0 release version of FreeBSD] and not a problem with the texlive port.


----------



## BostonBSD (Apr 15, 2021)

This is the output of `pkg -d install texlive-texmf`


```
root@BostonBSD:~ # pkg -d install texlive-texmf
DBG(1)[43039]> pkg initialized
Updating FreeBSD repository catalogue...
DBG(1)[43039]> PkgRepo: verifying update for FreeBSD
DBG(1)[43039]> Pkgrepo, begin update of '/var/db/pkg/repo-FreeBSD.sqlite'
DBG(1)[43039]> Request to fetch pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly/meta.conf
DBG(1)[43039]> opening libfetch fetcher
DBG(1)[43039]> Fetch > libfetch: connecting
DBG(1)[43039]> Fetch: fetching from: http://pkgmir.geo.freebsd.org/FreeBSD:13:amd64/quarterly/meta.conf with opts "i"
DBG(1)[43039]> Request to fetch pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly/packagesite.txz
DBG(1)[43039]> opening libfetch fetcher
DBG(1)[43039]> Fetch > libfetch: connecting
DBG(1)[43039]> Fetch: fetching from: http://pkgmir.geo.freebsd.org/FreeBSD:13:amd64/quarterly/packagesite.txz with opts "i"
FreeBSD repository is up to date.
All repositories are up to date.
DBG(1)[43039]> want to get an advisory lock on a database
DBG(1)[43039]> Binary> loading /var/cache/pkg/texlive-texmf-20150523_4~0af75238f8.txz
Segmentation fault (core dumped)
```


----------



## zirias@ (Apr 15, 2021)

Looks like a local error. Maybe you're lucky and it's just a corrupted package in your cache; in that case, `pkg install -f texlive-texmf` should help (although, of course, even then `pkg` shouldn't crash, so there's also a bug…)

If that doesn't help, first thing I'd recommend would be a filesystem check.


----------



## SirDice (Apr 15, 2021)

Zirias said:


> ; in that case, `pkg install -f texlive-texmf` should help (although, of course, even then `pkg` shouldn't crash, so there's also a bug…)


This won't re-download the cached package. And it looks like the problem is there. It will just try to reinstall whatever was stored in the package cache. 

Try cleaning out your cached packages first; `pkg clean -a`. Then `pkg install texlive-texmf`.


----------



## zirias@ (Apr 15, 2021)

SirDice said:


> This won't re-download the cached package.


It does for me.

```
nexus# pkg install thunderbird
Updating PalmenIT repository catalogue...
PalmenIT repository is up to date.
All repositories are up to date.
Checking integrity... done (0 conflicting)
The most recent versions of packages are already installed

nexus# ls /var/cache/pkg/thunderbird-78.9.1_1.txz
/var/cache/pkg/thunderbird-78.9.1_1.txz

nexus# pkg install -f thunderbird
Updating PalmenIT repository catalogue...
PalmenIT repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

Installed packages to be REINSTALLED:
    thunderbird-78.9.1_1

Number of packages to be reinstalled: 1

47 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching thunderbird-78.9.1_1.txz: 100%   47 MiB  49.5MB/s    00:01   
Checking integrity... done (0 conflicting)
[1/1] Reinstalling thunderbird-78.9.1_1...
[1/1] Extracting thunderbird-78.9.1_1: 100%
```
… and I really think it _should_


----------



## bakul (Apr 15, 2021)

When something fails, rather than randomly trying something (or _after_ randomly trying things that don’t work!) consider isolating the problem. Check that the locally cached pkg is fine. For example,

```
tar tvf /var/cache/pkg/texlive-texmf-20150523_4.txz>/dev/null
```

That should not fail. Next, check that you have enough free space. Next, since it is pkg that is crashing, refetch it using “pkg bootstrap -f” and reinstall texlive-texmf. You don’t have to fetch it again if the local cached copies are fine.


----------



## BostonBSD (Apr 15, 2021)

I thought this might work, but it still gives the same result.



```
root@BostonBSD:~ # pkg clean -a
Nothing to do.
root@BostonBSD:~ # pkg install texlive-texmf
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    texlive-texmf: 20150523_4

Number of packages to be installed: 1

The process will require 1 GiB more space.
589 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching texlive-texmf-20150523_4.txz: 100%  589 MiB 742.9kB/s    13:51   
Checking integrity...Child process pid=51461 terminated abnormally: Segmentation fault
```


----------



## BostonBSD (Apr 15, 2021)

bakul said:


> tar tvf /var/cache/pkg/texlive-texmf-20150523_4.txz>/dev/null


This worked fine.  No errors [I've also bootstrapped pkg two or three times, it doesn't make a difference].

However, pkg is giving me address boundary errors on this one texlive-texmf package ['fish' in the code below is the name of the shell].



```
myname@BostonBSD ~> sudo pkg -d install -f texlive-texmf-20150523_4
DBG(1)[8359]> pkg initialized
Updating FreeBSD repository catalogue...
DBG(1)[8359]> PkgRepo: verifying update for FreeBSD
DBG(1)[8359]> Pkgrepo, begin update of '/var/db/pkg/repo-FreeBSD.sqlite'
DBG(1)[8359]> Request to fetch pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly/meta.conf
DBG(1)[8359]> opening libfetch fetcher
DBG(1)[8359]> Fetch > libfetch: connecting
DBG(1)[8359]> Fetch: fetching from: http://pkgmir.geo.freebsd.org/FreeBSD:13:amd64/quarterly/meta.conf with opts "i"
DBG(1)[8359]> Request to fetch pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly/packagesite.txz
DBG(1)[8359]> opening libfetch fetcher
DBG(1)[8359]> Fetch > libfetch: connecting
DBG(1)[8359]> Fetch: fetching from: http://pkgmir.geo.freebsd.org/FreeBSD:13:amd64/quarterly/packagesite.txz with opts "i"
FreeBSD repository is up to date.
All repositories are up to date.
DBG(1)[8359]> want to get an advisory lock on a database
DBG(1)[8359]> found stale pid 5948 in lock database, my pid is: 8359
DBG(1)[8359]> no concurrent processes found, cleanup the lock
DBG(1)[8359]> want to get an advisory lock on a database
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    texlive-texmf: 20150523_4

Number of packages to be installed: 1

The process will require 1 GiB more space.
589 MiB to be downloaded.

Proceed with this action? [y/N]: y
DBG(1)[8359]> Request to fetch pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly/All/texlive-texmf-20150523_4.txz
DBG(1)[8359]> opening libfetch fetcher
DBG(1)[8359]> Fetch > libfetch: connecting
DBG(1)[8359]> Fetch: fetching from: http://pkgmir.geo.freebsd.org/FreeBSD:13:amd64/quarterly/All/texlive-texmf-20150523_4.txz with opts "i"
DBG(1)[8359]> Fetch: fetcher chosen: http
[1/1] Fetching texlive-texmf-20150523_4.txz: 100%  589 MiB 949.7kB/s    10:50 
Checking integrity...DBG(1)[8359]> Binary> loading /var/cache/pkg/texlive-texmf-20150523_4~0af75238f8.txz
fish: Job 1, 'sudo pkg -d install -f texliv...' terminated by signal SIGSEGV (Address boundary error)
```


----------



## bakul (Apr 15, 2021)

pkg doesn't use any shell called fish. Is that your login shell? You may wish to try from a more normal shell as login (sh, bash, zsh, etc.)!

Can you check your shell resource limits? I wonder if you are running into some resource limit. In zsh you'd type `limit`.

One thing you can try is to collect more data as follows:

```
ktrace -di pkg install texlive-texmf
kdump > kdump.out
```
 and look at the last couple pages of kdump.out - may be that'll provide some hint. Note that ktrace.out will be 789MB file (if it dies near the end) and kdump.out will be 1.5GB!


----------



## BostonBSD (Apr 15, 2021)

bakul said:


> pkg doesn't use any shell called fish. Is that your login shell? You may wish to try from a more normal shell as login (sh, bash, zsh, etc.)!


Fish is my user interactive shell, I also use tcsh as the root interactive shell.  I get the same issue with pkg regardless of the shell.  I'll try this fairly soon, I'm having some other issues with kernel config and vt drivers at the moment, 13.0 isn't quite the same as 12.2.


----------



## BostonBSD (Apr 16, 2021)

I actually just got back to this issue now, after recompiling the kernel I opened Octopkg just to see if it would install texlive-texmf [I know it's only a front-end to pkg, but I ran out of ideas].

It turns out that Octopkg did install texlive-full which pulls in texlive-texmf.

I do not know where this problem was coming from nor how it was able to resolve, perhaps recompiling the kernel made some sort of difference [there actually was a source code update during the interim...I am at 13.0-Release-P0, but there was an update from the git clone command to the git pull command].

There were also problems with login.conf.  I edited the changes that freebsd-update made into login.conf, removed the old portion from 12.2, and ran `cap_mkdb /etc/login.conf` which fixed those issues.

That may have had something to do with this.

====
btw I am very glad I did an upgrade rather than a fresh install.  There are far too many things I would still be tweaking with a fresh install.

It appears to run just as well as 12.2, now that all of these other issues have cleared up.  There is a slight performance boost [3-5%].  Finding the sqrt of 10 million numbers is about 3-5% faster than in 12.2 on the same hardware.  Hopefully it will be just as stable as 12.2 also.


----------

