bugGNU patch - Bugs: bug #62958, patch dies with out of memory when...


bug #62958: patch dies with out of memory when rlimit is huge, particularly when it is RLIM_INFINITY

Submitter:  Taylor C. Richberger <richbergert>
Submitted:  Thu 25 Aug 2022 06:15:27 PM UTC
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup

Thu 11 Jan 2024 01:48:42 AM UTC, comment #2: 

I can reproduce this with the latest GNU patch (2.7.6) on OS X:

% ulimit -n unlimited
% patch -p1 < ../patches/1902-cuda.patch
patch: ** out of memory

% ulimit -n 256
% patch -p1 < ../patches/xyz.patch
patching file common/xyz.cpp

This patch (unreleased) fixes the issue: https://git.savannah.gnu.org/cgit/patch.git/commit/?id=61d7788b83b302207a67b82786f4fd79e3538f30

Fri 26 Aug 2022 06:24:28 PM UTC, comment #1: 

There have been some fixes, when is the next release going to be cut of Gnu patch

Jack Woehr <jax>
Thu 25 Aug 2022 06:15:27 PM UTC, original submission:  

Working on an AIX 7.1 system with RLIM_INFINITY set to 2**63 and unlimited nofile rlimit, when I try to apply a patch with a subdirectory, I end up at src/safe.c line 103 calculating a max_cached_fds of 2305843009213693951 (~2.3 quintillion).  This proceeds into lib/hash.c line 622, which passes this number into compute_bucket_size and ends up spinning on next_prime for a while before ending up on 1152921504606840992 (~1.15 quintillion), returning 0, and then failing with out of memory because xalloc_oversized returns 0.

Maybe a check for RLIM_INFINITY is in order, but that won't fix a similar issue if somebody has their nofile rlimit set to a massive value below RLIM_INFINITY, which could cause the same problem.

Taylor C. Richberger <richbergert>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jax (Posted a comment)
  • -email is unavailable- added by richbergert (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code