Skip to content

2.34.4 on MacOS patch causes OOM #15619

@bvsn

Description

@bvsn

Describe the bug

Nix 2.34.4 on macOS causes patch: **** out of memory errors during patchPhase for packages that apply diffs (e.g. gz-transport14, freeimage, libdart). The patches themselves are valid and apply successfully outside the Nix build environment.

https://github.com/devbrom/gazebo-sim-overlay/tree/darwin-support

The issue does not occur on Nix 2.31.2 with an identical system configuration, same macOS version, same flake, and same nixpkgs pin.

Nix 2.34.x appears to result in nixbld build users running with a stack size soft limit of 8176 KB, which is insufficient for patch to process multi-chunk diffs. Running sudo -u _nixbld1 ulimit -s confirms this value.

Steps To Reproduce

  1. Install Nix 2.34.4 on macOS (arm64, darwin25)
  2. Run nix develop github:devbrom/gazebo-sim-overlay/darwin-support#default -c $SHELL
  3. Observe patch: **** out of memory during patchPhase
  4. Confirm the patch applies successfully outside the sandbox:
  5. Confirm nixbld stack limit: sudo -u _nixbld1 ulimit -s # returns 8176
  6. Downgrade to Nix 2.31.2 - builds succeed without any other changes

Expected behavior

nixbld build users should have sufficient stack size to run standard POSIX tools like patch. The stack limit applied to build processes should not regress between Nix versions on macOS.

Metadata

nix (Nix) 2.34.4
nix (Nix) 2.31.2  # works
nix log /nix/store/m6bsabwxy7ylr1rw79425fhabb9pr36k-gz-transport14-14.1.0.drv
Running phase: qtPreHook
@nix { "action": "setPhase", "phase": "qtPreHook" }
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/4kynmimn3yfdr358r77a1ik067w83dgg-gz-transport14_14.1.0-source
source root is gz-transport14_14.1.0-source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
applying patch /nix/store/d281scad7p61mqdiw87zfpc6x4dczg4f-cmd.patch
patch: **** out of memory

Additional context

  • sandbox = false does not resolve the issue - the stack limit is applied at the nixbld process level, not the sandbox
  • Raising the nix-daemon's launchd SoftResourceLimits.Stack also does not resolve it - the limit applies to child nixbld processes, not the daemon itself
  • The only working fixes are: downgrade to 2.31.2
  • Patches as small as 4 lines fail, ruling out patch file size as the cause - the issue is purely the stack constraint on the build user

Checklist

  • checked [latest Nix manual] ([source])
  • checked [open bug issues and pull requests] for possible duplicates

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions