AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
Expand all | Collapse all

GNU patch dies with an out of memory error on AIX 7.1 when applying a patch to a file in a non-current directory

  • 1.  GNU patch dies with an out of memory error on AIX 7.1 when applying a patch to a file in a non-current directory

    Posted Thu August 25, 2022 01:48 PM
    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
    ------------------------------


  • 2.  RE: GNU patch dies with an out of memory error on AIX 7.1 when applying a patch to a file in a non-current directory

    Posted Thu August 25, 2022 02:20 PM
    Digging into this more, I discovered that this is probably due to my system's rlimit being set to unlimited.  I've done some debugging in gdb on GNU patch after rebuilding it with no optimization and all debugging symbols intact, and ended up with this bug report to their bug tracker: https://savannah.gnu.org/bugs/index.php?62958
    If anybody else runs into this issue, you might be able to fix it just by setting a lower nofile rlimit.

    ------------------------------
    Taylor Richberger
    ------------------------------



  • 3.  RE: GNU patch dies with an out of memory error on AIX 7.1 when applying a patch to a file in a non-current directory

    Posted Thu September 01, 2022 11:03 AM
    Thank you Taylor !!

    ------------------------------
    SANKET RATHI
    ------------------------------