Bug 250916 - sysutils/lsof: Unbreak for 12.2-RELEASE
Summary: sysutils/lsof: Unbreak for 12.2-RELEASE
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Craig Leres
URL:
Keywords: patch-ready
Depends on:
Blocks:
 
Reported: 2020-11-06 22:20 UTC by Craig Leres
Modified: 2021-02-01 10:32 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (ler)


Attachments
patch (1.50 KB, patch)
2020-11-06 22:20 UTC, Craig Leres
no flags Details | Diff
revised patch (1.52 KB, patch)
2020-11-06 23:04 UTC, Craig Leres
no flags Details | Diff
revised patch (1.67 KB, patch)
2020-11-07 01:29 UTC, Craig Leres
leres: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Leres freebsd_committer freebsd_triage 2020-11-06 22:20:23 UTC
lsof has been broken for me since upgrading to 12.2-RELEASE. The symptom is for it to go cpu bound and never output any results. This appears to be fallout resulting from the reordering of the namecache struct in kern/vfs_cache.c:

    r363891 | mjg | 2020-08-05 02:24:38 -0700 (Wed, 05 Aug 2020) | 9 lines
    [..]
    While here reorder struct namecache so that most commonly used
    fields are closer.

Since the namecache struct is not public lsof defines it's own copy which needs to be different for 12.2 and newer.

I've tested the patch on 12.2-RELEASE and 13.0-CURRENT (r367338).
Comment 1 Craig Leres freebsd_committer freebsd_triage 2020-11-06 22:20:55 UTC
Created attachment 219405 [details]
patch
Comment 2 Craig Leres freebsd_committer freebsd_triage 2020-11-06 23:04:19 UTC
Created attachment 219408 [details]
revised patch

Key changes off of __FreeBSD_version instead of FREEBSDV and avoid breaking 12.1 as suggested by @ler. Tested on 12.1 and 12.2.
Comment 3 Craig Leres freebsd_committer freebsd_triage 2020-11-07 01:29:01 UTC
Created attachment 219410 [details]
revised patch

As per @ler 13-CURRENT did not reorder the namecache struct until 1300105; adjust patch to handle this as well. Tested on 12.1, 12.2, and 13.0 (r367338).
Comment 4 commit-hook freebsd_committer freebsd_triage 2020-11-11 22:12:36 UTC
A commit references this bug:

Author: leres
Date: Wed Nov 11 22:11:46 UTC 2020
New revision: 554915
URL: https://svnweb.freebsd.org/changeset/ports/554915

Log:
  sysutils/lsof: Unbreak for 12.2-RELEASE and newer 13.0-CURRENT

  The the order of fields in the namecache struct changed in stable/12
  (r363891) and head (r367338); this definition is not public so lsof
  has it's own copy that needs to be conditionally adjusted accordingly.

  PR:		250916
  Approved by:	ler (maintainer)

Changes:
  head/sysutils/lsof/Makefile
  head/sysutils/lsof/files/patch-dialects-freebsd-dlsof.h
Comment 5 Craig Leres freebsd_committer freebsd_triage 2020-11-11 22:14:46 UTC
Committed (with offline email approval from @ler).
Comment 6 David Chisnall freebsd_committer freebsd_triage 2021-02-01 10:32:30 UTC
I am not sure that this is fixed.  250929 appears to be a symptom of the same root cause: lsof opens /dev/kmem and then keeps trying to walk a data structure that is not the shape that it expects.  Looking at the things it's reading, it seems to be grabbing random pages from the buffer cache.  I suspect that it sees some null bytes and stops on some systems but on others it just keeps going until it runs out of memory.