[OnePlus 3T ROMs, Kernels, Recoveries, & Other Deve] :
FIXED: ISSUE: crashing substratum (and for sure much more...)

The problem:

FIX BUILD: toybox: disable egrep, fgrep, grep and iotop.

OORDER MATTERS!

For reference see:
https://github.com/nvertigo/android_external_toybox/commit/cd40f1d10b9eb648aac44c83632e7f21e7430a3b

This breaks the rom by breaking toybox:

I two modules of the build process try to install /system/bin/XX, the
consequences are quite expectable: the LAST write wins. So far so good.

If the later of the two modules is not creating a regular file, but a
symblic link with "ln -sf" "unlink();" is called and the creation of the
symlink does not fail.

The other side around is expectable as well: if a module tries to
install the XX binary, when XX is already in place as symlink pointing
to toybox, "open();" is called. Depending on the way "install" is called
(or cp - for this matter), this just writing to /system/bin/XX.

Since XX is just a reference to toybox, toybox is overwritten.

For iotop (i.e.) this is currently happening:
1. The toolbox symlinks are setup pointing to toybox, which is not
installed at this moment. iotop symlink pointing to toybox is in
place.
2. toolbox binary is installed.
3. iotop (standalone command) is written to iotop symlink.
4. toybox was overwritten by iotop in 3.

Why is this happening?
If you've initializedna clean BUILD_TOP with only oneplus3t manifest,
there are two runs of toybox-instlist (host binary build in toybox,
sourcing generated/newtoys.h for generating symlink list). The second
one AFTER all standalone binaries were installed: so the standalone
binaries are replaced (due to "unlink();" prior to creating the
symlink).

So we don't have the intended standalone binaries, but this is hard to know,
because toybox is serving the requests for the command.

On different build environments this order has changed suddenly - so
toybox gets overwritten and having iotop or grep instead of toybox leads
up to all kinds of funny side effects. In deed, all shell scripts
relaying on shell comands served by toybox and every app doing "exec();"
on these commands, will crash as a matter of fact.

Symptons of this include, but don't limit to:
* terminal gets started, but never delivers a shell prompt.
* Substratum crashing on startup.
* some subsystems are not initialized correctly (i.e. lte/ims).
* ...

Why is the build order changing?
On the fresh and only for op3/T created build tree some more devices
were added. For my build environment I added bacon, gemini, marlin and
chagallwifi. After adding chagallwifi, the build order regarding toybox
has changed.

As explained en detail in the referenced commit message, there are some
sources to populate /system/bin. I decided to disable grep and iotop in
toybox, because I think, if a standalone binary's sourcecode has been
pulled to the build tree, it has been put in to be used... Maybe this is
a false assumption, but since no design- or configuration-concept is
visible for me, this is the best guess.

The other poss8ble fix would be deleting iotop's source dir, and
configure toolbox not to build ef-grep. But this would mean, that sorce
code that is not used, was added by intend to increase build time and
overwite it in the end, relaying on something fragile like the order of
building packages.

The fix:

toys: disable grep (egrep, fgrep) and iotop.

/system/bin is populated from 4 sources (at least: I don't claim
completeness).

Two of these are multi-call-
binaries:
* toybox (which is this package)
* toolbox (which is not completely build in one binary - i.e. grep
is build from toolbox' sources, but is a standalone (aka external)
command.

The other two possible sources are this two directories with source code
for standalone commands:
* ${ANDROID_BUILD_TOP}/external
* ${ANDROID_BUILD_TOP}/system/extras

While toolbox and toybox can be configured, the lineage/aosp build
system calls the module names for the standalone binaries implicitly.

Since there is no check if the symlinks of the multi-call-binaries
collide in any way with each other or the standalone commands, we (devs
and builders) have to take care of this.

This toybox modules are removed:

* grep (incl. egrep and fgrep): use toolbox' standalone grep binary
* iotop: use ${ANDROID_BUILD_TOP}/system/extras/iotop

The problem is /system/bin/iotop.

when toybox is build and stripped the build system is building a host binary, which installs the links for all included modules (at about 30%), among others there is iotop linked to toybox. At about 60% a standalone binary for iotop is build from BUILDTREE/system/extras/iotop. If this is ready, it is installed to /system/bin/iotop, which is a symbolic link to toybox...

I have no clue, when and why this package collision has occured - but this fixes this issue:

diff --git a/.config b/.config
index 0459e0a..4f3371e 100644
--- a/.config
+++ b/.config
@@ -73,7 +73,7 @@ CONFIG_PATCH=y
CONFIG_PRINTF=y
CONFIG_PS=y
CONFIG_TOP=y
-CONFIG_IOTOP=y
+# CONFIG_IOTOP is not set
CONFIG_TOP_COMMON=y
CONFIG_PGREP=y
CONFIG_PGKILL_COMMON=y

EDIT: [MENTION=313982]home[/MENTION]builders:

I have made a quick and ugly hotfix in local_manifest (It's only in branch my-gps, if you build an otjer branch just cherry-pick):

https://github.com/nvertigo/local_manifest/commit/83a4d68bfacb69d151f314ff87fdb38fc3fc2b95

EDIT2: I have no clue at all, what exactly is triggering this, nor why the times it occurs are so damn different. If you look here: https://review.lineageos.org/#/c/61653/ (cherry-picking this has the same effect as my quick hack) you can see Ethan was hit by this in Dezember, at least one homebuilder in this thread was hit some days ago, and my build system was hit today... this is strange.

EDIT3: Since getprop is also a link to toybox, this could also be the reason, lte settings does not work like expected.

EDIT4: have to rework the patch - mine is not working, since .config is not used with Android.mk. Hopefully fixed now with cherry-picking Ethan's commit. Or you d8sable TASKSTATS in the kernel config.

EDIT5:

Still not fixed.

This is sad: I hate the laos toybox so much: network tools like arp are broken since cm switched away from busybox, because the gpl lic. Since then toybox is broken. Now this is even breaking the build...

If I have more time, I'll send this broken **** to hell and bring up busybox again. This has at least a single file to enable/disable a module.

EDIT6: still nor really fixed. To get an working rom, dirty build a second time.

Let me get up an updated rom for you, after that I'll describe the error en detail. Short story: if one decides gpl copyleft is for idiots and could stand in the way of earning money, this leads to bad karma. Bad Karma makes devs forgetting to configure the non-gpl software...