Updating from an older 8.2-Stable to 8.4-Stable, after running /usr/local/sbin/pkg2ng, pkg immediately seg faults: Converting packages from /var/db/pkg Converting en-freebsd-doc-20110110... Child process pid=21252 terminated abnormally: Segmentation fault: 11 After building again with debug symbols, gdb provides the following stack trace: #0 0x000000080175412a in strlcpy () from /lib/libc.so.7 #1 0x00000008006df44b in plist_new (pkg=0x801a9c800, stage=0x0) at pkg_ports.c:1083 #2 0x00000008006dfd14 in ports_parse_plist (pkg=0x801a9c800, plist=0x7fffffffdec0 "/var/db/pkg/en-freebsd-doc-20110110/+CONTENTS", stage=0x0) at pkg_ports.c:1140 #3 0x000000080070cd34 in pkg_old_load_from_path (pkg=0x801a9c800, path=0x7fffffffe380 "/var/db/pkg/en-freebsd-doc-20110110") at pkg_old.c:72 #4 0x000000000040e20d in convert_from_old (pkg_add_dbdir=0x425b3d "/var/db/pkg", dry_run=false) at convert.c:308 #5 0x000000000040e471 in exec_convert (argc=0, argv=0x7fffffffeaf8) at convert.c:368 #6 0x00000000004144d9 in main (argc=1, argv=0x7fffffffeaf0) at main.c:822 In frame 1: 1083 strlcpy(p->prefix, prefix, sizeof(p->prefix)); prefix is a null pointer, so the strlcpy seg faults. This suggests that the previous line: pkg_get(pkg, PKG_PREFIX, &prefix); Set &prefix to a null pointer, which was unchecked before the strlcpy. As a result no errors are provided, no warnings offered, no workarounds are performed, and the program crashes instead of handling whatever problem exists gracefully. It appears to be trying to work with "/var/db/pkg/en-freebsd-doc-20110110/+CONTENTS" at the time of the crash. How-To-Repeat: Have an older ports db. Try to upgrade. Fix: Not known at this time.
I kept a copy of pkg 1.3.7 around after I, too, noticed this a couple days ago (tracked down to the same issue trying to get PKG_PREFIX in plist_new()). pkg convert from 1.3.7 still works for converting old pkg_* installations. Not a fix, of course, but it might help you move on while a fix is worked. Note, this is easy to reproduce on a /var/db/pkg with just one old style package in it. The 'Component' for this bug could reasonably be considered to be 'ports infrastructure'.
I'll have a fix out for this soon.
pkg_ports.c changed a lot from 1.3.7 to 1.3.8. Hard to identify a fix if you don't know the code already. bdrewery's on it, though - hopefully with a relatively easy fix.
bapt fixed this in r369323.