Re: I've got a pkg 2.3.1 "pkg-static autoremove" that has grown to have over 1 GiByte of RAM resident after more than 77 minutes of cpu time [backtrace added]

From: Mark Millard <marklmi_at_yahoo.com>
Date: Sun, 14 Sep 2025 17:46:55 UTC
On Sep 14, 2025, at 09:38, Mark Millard <marklmi@yahoo.com> wrote:

> [Some prior testing was also seeing such for pkg, not just pkg-static .]
> 
> The context here is a armv7 chroot on an aarch64 system,
> in case that turns out to matter.
> 
> # pkg-static -v
> 2.3.1
> 
> 
> For reference:
> 
> load: 1.44  cmd: pkg-static 57217 [running] 4856.83r 4619.81u 2.24s 99% 1056180k
> 
> ..PID   JID USERNAME    PRI NICE     SIZE       RES STATE    C   TIME     CPU COMMAND
> 57217     0 root        141    0   1096Mi    1038Mi CPU3     3  78:07 100.00% pkg-static autoremove
> 
> The boot system:
> 
> # uname -apKU
> FreeBSD aarch64-main-pbase 16.0-CURRENT FreeBSD 16.0-CURRENT main-n280292-3c60ea77649d GENERIC-NODEBUG arm64 aarch64 1600000 1600000
> 
> Inside the chroot:
> 
> # uname -apKU
> FreeBSD aarch64-main-pbase 16.0-CURRENT FreeBSD 16.0-CURRENT main-n280292-3c60ea77649d GENERIC-NODEBUG arm armv7 1600000 1600000
> 
> # truss -p 57217
> freebsd32_mmap(0x0,20480,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926179328 (0x37346000)
> freebsd32_mmap(0x0,20480,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926199808 (0x3734b000)
> freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926220288 (0x37350000)
> freebsd32_mmap(0x0,12288,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926224384 (0x37351000)
> freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926236672 (0x37354000)
> freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926240768 (0x37355000)
> freebsd32_mmap(0x0,20480,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926244864 (0x37356000)
> freebsd32_mmap(0x0,20480,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926265344 (0x3735b000)
> freebsd32_mmap(0x0,12288,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926285824 (0x37360000)
> freebsd32_mmap(0x0,20480,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926298112 (0x37363000)
> freebsd32_mmap(0x0,12288,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926318592 (0x37368000)
> freebsd32_mmap(0x0,28672,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926330880 (0x3736b000)
> freebsd32_mmap(0x0,20480,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926359552 (0x37372000)
> freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 926380032 (0x37377000)
> . . .
> 
> No other activity reported by truss, other than freebsd32_mmap use,
> at least for what i looked at.


I was able to run the pkg-static in the background and attach gdb
to it in the chroot:

Reading symbols from /usr/local/sbin/pkg-static...
0x0029632c in btreeCursor ()
(gdb) bt
#0  0x0029632c in btreeCursor ()
#1  0x00285d04 in sqlite3VdbeExec ()
#2  0x00254060 in sqlite3_step ()
#3  0x002496a0 in pkgdb_it_next ()
#4  0x00400374 in pkg_jobs_test_automatic ()
#5  0x00400d04 in is_orphaned ()
#6  0x00400274 in pkg_jobs_test_automatic ()
#7  0x00400d04 in is_orphaned ()
#8  0x0040038c in pkg_jobs_test_automatic ()
#9  0x00400d04 in is_orphaned ()
#10 0x00400274 in pkg_jobs_test_automatic ()
#11 0x00400d04 in is_orphaned ()
#12 0x0040038c in pkg_jobs_test_automatic ()
#13 0x00400d04 in is_orphaned ()
#14 0x00400274 in pkg_jobs_test_automatic ()
#15 0x00400d04 in is_orphaned ()
#16 0x0040038c in pkg_jobs_test_automatic ()
#17 0x00400d04 in is_orphaned ()
#18 0x00400274 in pkg_jobs_test_automatic ()
#19 0x00400d04 in is_orphaned ()
#20 0x0040038c in pkg_jobs_test_automatic ()
. . .
#54858 0x00400274 in pkg_jobs_test_automatic ()
#54859 0x00400d04 in is_orphaned ()
#54860 0x0040038c in pkg_jobs_test_automatic ()
#54861 0x003fecac in pkg_jobs_solve ()
#54862 0x001cc5c4 in exec_autoremove ()
#54863 0x001d55dc in main ()

I had previously done:

pkg-static del FreeBSD-set-base FreeBSD-set-base-dbg FreeBSD-set-devel FreeBSD-set-devel-dbg FreeBSD-set-minimal FreeBSD-set-minimal-dbg FreeBSD-set-kernels FreeBSD-set-kernels-dbg

( FreeBSD-set-lib32* are missing only because this is an armv7 context that can not have such. )


===
Mark Millard
marklmi at yahoo.com