Skip to content

Out of memory when trying to parse a simple patch #101

@gabipurcaru

Description

@gabipurcaru

I'm trying to parse a patch between 1 and 1\n2, and I get OOM in node:

$ node
> require('diff').parsePatch('Index: \n===================================================================\n--- \n+++ \n@@ -1,1 +1,2 @@\n-1\n\\ No newline at end of file\n+1\n+2\n')

<--- Last few GCs --->

   24024 ms: Scavenge 1419.3 (1476.8) -> 1419.3 (1476.8) MB, 0.3 / 0 ms (+ 2.0 ms in 1 steps since last GC) [allocation failure] [incremental marking delaying mark-sweep].
   24988 ms: Mark-sweep 1419.3 (1476.8) -> 1419.0 (1476.8) MB, 964.8 / 0 ms (+ 3.0 ms in 2 steps since start of marking, biggest step 2.0 ms) [last resort gc].
   26155 ms: Mark-sweep 1419.0 (1476.8) -> 1419.0 (1476.8) MB, 1167.0 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 000003E2ABFE3AD1 <JS Object>
    1: parseIndex(aka parseIndex) [C:\Users\Gabi\Work\dedo\www\node_modules\diff\lib\patch\parse.js:~13] [pc=0000035BE40D5B0C] (this=000003E2ABF04189 <undefined>)
    2: parsePatch [C:\Users\Gabi\Work\dedo\www\node_modules\diff\lib\patch\parse.js:~6] [pc=0000035BE40C769F] (this=000003F143E6E4B9 <an Object with map 000003A58872F0D9>,uniDiff=0000028734AACC19 <St
ring[139]\: Index: \n============...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

I also tried it in the browser and it hangs, and also the npmjs.org testing utility fails: https://tonicdev.com/56b3841f8b1a9a0f005eec3b/56b8a9eaca44d40c003d191e

The patch is the result of require('diff').createPatch('', '1', '1\n2').

This seems to be related to fact that the file name is empty.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions