Bug 262746 - lib/libsysdecode/mkioctls sometimes fails spuriously
Summary: lib/libsysdecode/mkioctls sometimes fails spuriously
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-23 18:05 UTC by Navdeep Parhar
Modified: 2022-03-24 04:12 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Navdeep Parhar freebsd_committer freebsd_triage 2022-03-23 18:05:23 UTC
mkioctls uses a "find | sort | tee | xargs egrep -l | awk" pipeline to generate a list of header files.  This pipeline fails spuriously if the shell's pipefail option is enabled and one of the egrep launched by xargs returns 1 because there are no _IO* markers in that particular batch of files.

set -o pipefail was added in ec45ce6222366e69adf1fad1b33ec8598229c8c0
pipefail support was added to /bin/sh in 484160a9cf236a5892c1ab8344de287d7a1472c1
This also means the comment about /bin/bash in mkioctls is now stale.

Here is a DTrace script (and its output) that shows the failure when "sh ./lib/libsysdecode/mkioctls ." is run inside a tree with this problem.

cat mkioctl.d
#!/usr/sbin/dtrace -s
syscall:freebsd:exit:entry
/execname == "awk" || \
 execname == "egrep" || \
 execname == "find" || \
 execname == "grep" || \
 execname == "sh" || \
 execname == "tee" || \
 execname == "xargs"/
{
        trace(execname);
        trace(arg0)
}


dtrace: script '/tmp/mkioctl.d' matched 1 probe
CPU     ID FUNCTION:NAME
  3  88534 exit:entry   sh     0
  1  88534 exit:entry   grep   0
  4  88534 exit:entry   find   0
  2  88534 exit:entry   egrep  1
  0  88534 exit:entry   egrep  0
  2  88534 exit:entry   egrep  0
  7  88534 exit:entry   tee    0
  4  88534 exit:entry   egrep  0
  6  88534 exit:entry   xargs  1
  2  88534 exit:entry   awk    0
  0  88534 exit:entry   sh     1
  3  88534 exit:entry   sh     1