This issue is a little baffling to me. I first hit it trying to apply some patches for zeromq (context: I'm compiling it statically for software distribution to client machines that can't/won't install other RPMs), but found that even a simple contrived example triggers it:
-bash-5.1$ oslevel -s
7100-05-09-2148
-bash-5.1$ which patch
/opt/freeware/bin/patch
-bash-5.1$ cd $(mktemp -d)
-bash-5.1$ mkdir old
-bash-5.1$ mkdir new
-bash-5.1$ echo old > old/file.txt
-bash-5.1$ echo new > new/file.txt
-bash-5.1$ diff -u old/file.txt new/file.txt |tee diff.patch
--- old/file.txt 2022-08-25 11:59:31 +0000
+++ new/file.txt 2022-08-25 11:59:37 +0000
@@ -1 +1 @@
-old
+new
-bash-5.1$ time patch -p0 <diff.patch
patch: **** out of memory
real 0m1.984s
user 0m1.155s
sys 0m0.001s
-bash-5.1$ cd old
-bash-5.1$ time patch -p1 <../diff.patch
patching file file.txt
real 0m0.015s
user 0m0.001s
sys 0m0.001s
I thought it might be my fix level, so I installed up to the newest service pack and rebooted, but still have the same issue. I also thought it might be the Toolbox RPM, so I rebuilt GNU patch from source and still have the same problem, so I think this has something to do with my system. /usr/bin/patch works fine, but that expects slightly differently-formatted patches (non-GNU AIX patch expects two leading columns in unified diffs), so to work with that, I have to manually reformat all patches. I'm also nervous about other potential future breakage elsewhere, since GNU patch works fine on other non-7.1 systems I have available.
I've watched nmon and don't actually see any memory use spikes at all during the few seconds that GNU patch spins before failing, and truss is silent during that 2-second wait as well. Really curious as to what might be going wrong. I'm going to probably start digging into the source code of GNU patch and see where it's spinning, but thought I'd reach out to the community in the interim and see if somebody else had thoughts.
Thanks.
------------------------------
Taylor Richberger
------------------------------