Bug 226637

Summary: misc/mbuffer: Update to 2018.03.18 to fix immediate failures
Product: Ports & Packages Reporter: eborisch+FreeBSD
Component: Individual Port(s)Assignee: Tobias Kortkamp <tobik>
Status: Closed FIXED    
Severity: Affects Many People CC: tobik
Priority: --- Flags: bugzilla: maintainer-feedback? (mm)
Version: Latest   
Hardware: Any   
OS: Any   
Description Flags
Patches to fix and improve mbuffer behavior on FreeBSD. none

Description eborisch+FreeBSD 2018-03-15 18:07:32 UTC
Created attachment 191527 [details]
Patches to fix and improve mbuffer behavior on FreeBSD.


With no explicit counts set, mbuffer 2017.10.11 fails immediately on FreeBSD if the physical memory on the system > ~ 6GB and kern.ipc.semvmx is its default (32767 * 50 * 4096).

Steps to reproduce:

$ mbuffer -q < /dev/zero > /dev/null
mbuffer: fatal: cannot allocate more than 32767 blocks.
This is a system dependent limit, depending on the maximum semaphore value.
Please choose a bigger block size.

Additional information:

Attached is a patch to fix/improve this behavior. Will also submit upstream. 

Fixed (settings.c): reads the wrong parameter (checked SysV, but wants posix semaphore limits), and into an uninitialized and wrong-sized variable with sysctlbyname. Completely remove that part and just use 'mxnrsem = sysconf(_SC_SEM_VALUE_MAX)' which returns the desired value (such that sem_init(,,<=mxnrsem) will not fail EINVAL). Tested on 11.1; I don't have a <= 10.x around to test. Removes almost all __FreeBSD__ switches from settings.c.

Fixed (mbuffer.c): Don't allow default setting to be invalid. Clamp Numblocks to mxnrsem.

Enhancement (mbuffer.c): Actually get free memory (similar value to the check of _SC_AVPHYS_PAGES used where available) rather than total system memory when calculating NumP/50 memory to use.
Comment 1 eborisch+FreeBSD 2018-03-19 02:13:44 UTC
Now fixed upstream with revision 20180318.

Please update port version.
Comment 2 Tobias Kortkamp freebsd_committer 2018-03-19 06:12:05 UTC
Committed. Thanks!
Comment 3 commit-hook freebsd_committer 2018-03-19 06:12:30 UTC
A commit references this bug:

Author: tobik
Date: Mon Mar 19 06:11:49 UTC 2018
New revision: 464984
URL: https://svnweb.freebsd.org/changeset/ports/464984

  misc/mbuffer: Update to 20180318

  - Fixes a bug where mbuffer would immediatly fail with no explicit
    counts set
  - Take maintainership after the last 6 months maintainer timeout from

  PR:		226637
  Submitted by:	eborisch+FreeBSD@gmail.com