{"thread":{"id":"38362","subject":"Segmentation fault in git apply","startedAt":"2015-01-14T18:20:02Z","lastAt":"2015-01-23T00:12:48Z","messageCount":26,"participants":["Michael Blume","Junio C Hamano","Kyle J. McKay","Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"254670","messageId":"CAO2U3QjGUfnTRO_poS+=-MfE4aYGuWpVJTe20H-u=FgkVy-RYg@mail.gmail.com","threadId":"38362","inReplyTo":null,"subject":"Segmentation fault in git apply","fromName":"Michael Blume","fromEmail":"blume.mike@gmail.com","sentAt":"2015-01-14T18:20:02Z","receivedAt":"2015-01-14T18:20:02Z","isPatch":false,"sender":{"key":"blume.mike@gmail.com","avatar":"https://gravatar.com/avatar/1a7b440e1d942425ff4098ac7fc15b86b30cecaa56e1692a7ef8b5939ba25ea7?d=mp&s=160"},"body":"This is a mac with a fresh build of git from pu branch, commit 53b80d0.\n\nWith my gitconfig looking like\n\n[user]\n    email = blume.mike@gmail.com\n    name = Michael Blume\n[apply]\n    whitespace = fix\n[core]\n    whitespace = fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4\n\nIf I run\ngit clone git@github.com:MichaelBlume/clojure.git\ncd clojure\ngit checkout origin/rebase-start\ngit rebase origin/rebase-base\n\nI get\n\nsrc/jvm/clojure/lang/Compiler.java                          |  26\n+++++++++++++++++---------\n test/clojure/test_clojure/compilation.clj                   |  33\n++++++++++++++++++++++++++++++++-\n test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 170 insertions(+), 10 deletions(-)\n create mode 100644 test/clojure/test_clojure/compilation/examples_clj_1561.clj\nFirst, rewinding head to replay your work on top of it...\nApplying: CLJ-1603 - add reducible cycle, iterate, repeat\nApplying: CLJ-1515 Reify range\nApplying: CLJ-1499 Direct iterators for PersistentHashMap,\nAPersistentSet, PersistentQueue, and PersistentStructMap, and records.\nAdded new IMapIterable interface for key and val iterators.\nApplying: CLJ-1602 Make keys and vals return Iterable result\nApplying: fix AOT bug preventing overriding of clojure.core functions\nApplying: catch multiple rest forms\nApplying: zipmap using iterators and transient maps\nApplying: Define merge/merge-with after reduce has loaded\nApplying: very simple test of the merge function\nApplying: Support get on arbitrary java.util.List instances\nApplying: CLJ-1451 add take-until\nApplying: CLJ-1606 - complete eduction's xform without completing outer rfn\nApplying: add unrolled vector implementation\nApplying: add transient? predicate\nApplying: fix emitted line numbers\nUsing index info to reconstruct a base tree...\nM src/jvm/clojure/lang/Compiler.java\nFalling back to patching base and 3-way merge...\nAuto-merging src/jvm/clojure/lang/Compiler.java\nApplying: just use a not\nApplying: trailing whitespace\nApplying: don't mix tabs/spaces in clojure.xml/emit-element\nApplying: avoid mixing tabs with spaces in clojure core code\nApplying: don't optimize for defrecord lookup if keyword is namespaced\nApplying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity\nApplying: unrolled impls for maps\nApplying: CLJ-703: Remove flush and sync calls when writing class files.\nApplying: CLJ-1078: Add queue and queue? to clojure.core\nApplying: make RT.boundedLength lazier\nApplying: first try for adding compare\nApplying: Fix for #CLJ-1565\nApplying: CLJ-1074: Read +/- Infinity and NaN\nApplying: Fix CLJ-1074 for EdnReader too, see\neaeda2e7bf2697e565decdf14a8a99fbf8588c57\nApplying: add get-and-set! to expose AtomicReference.getAndSet() for atoms\nApplying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit\nApplying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string\nApplying: if test expr of an if statement is a literal, don't emit the\nruntime test\nApplying: evaluate def symbol metadata only once\nApplying: CLJ-1295: Speed up dissoc on array-maps\nApplying: some throwing\nApplying: don't pass offset to ArrayChunk\nApplying: make EMPTY accessible\nApplying: add handy create methods\nApplying: regenerate\nApplying: regenerate\n/Users/michael.blume/libexec/git-core/git-am: line 854: 92059\nSegmentation fault: 11  git apply --index \"$dotest/patch\" > /dev/null\n2>&1\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab\nin indent.\n   IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab\nin indent.\n   .persistent();\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:15: tab\nin indent.\n   return (IPersistentVector) ((IObj) v).withMeta(meta);\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:25: tab\nin indent.\nITransientCollection coll = PersistentVector.EMPTY\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:27: tab\nin indent.\nreturn (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\nwarning: squelched 1 whitespace error\nwarning: 6 lines add whitespace errors.\nUsing index info to reconstruct a base tree...\nM src/jvm/clojure/lang/PersistentUnrolledVector.java\n<stdin>:13: tab in indent.\n   IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n<stdin>:14: tab in indent.\n   .persistent();\n<stdin>:15: tab in indent.\n   return (IPersistentVector) ((IObj) v).withMeta(meta);\n<stdin>:25: tab in indent.\nITransientCollection coll = PersistentVector.EMPTY\n<stdin>:27: tab in indent.\nreturn (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\nwarning: squelched 1 whitespace error\nwarning: 6 lines applied after fixing whitespace errors.\nFalling back to patching base and 3-way merge...\nfatal: Unable to create\n'/Users/michael.blume/workspace/clojure/.git/index.lock': File exists.\n\nIf no other git process is currently running, this probably means a\ngit process crashed in this repository earlier. Make sure no other git\nprocess is running and remove the file manually to continue.\nFailed to merge in the changes.\nPatch failed at 0041 regenerate\nThe copy of the patch that failed is found in:\n   /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch\n\nWhen you have resolved this problem, run \"git rebase --continue\".\nIf you prefer to skip this patch, run \"git rebase --skip\" instead.\nTo check out the original branch and stop rebasing, run \"git rebase --abort\".\n"},{"id":"254673","messageId":"CAO2U3Qjn9o_eYayEMCC3S6DBr9kVH7mPL00QGrXAnV2iYRP-=A@mail.gmail.com","threadId":"38362","inReplyTo":"CAO2U3QjGUfnTRO_poS+=-MfE4aYGuWpVJTe20H-u=FgkVy-RYg@mail.gmail.com","subject":"Re: Segmentation fault in git apply","fromName":"Michael Blume","fromEmail":"blume.mike@gmail.com","sentAt":"2015-01-14T18:40:06Z","receivedAt":"2015-01-14T18:40:06Z","isPatch":false,"sender":{"key":"blume.mike@gmail.com","avatar":"https://gravatar.com/avatar/1a7b440e1d942425ff4098ac7fc15b86b30cecaa56e1692a7ef8b5939ba25ea7?d=mp&s=160"},"body":"On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume <blume.mike@gmail.com> wrote:\n> This is a mac with a fresh build of git from pu branch, commit 53b80d0.\n>\n> With my gitconfig looking like\n>\n> [user]\n>     email = blume.mike@gmail.com\n>     name = Michael Blume\n> [apply]\n>     whitespace = fix\n> [core]\n>     whitespace = fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4\n>\n> If I run\n> git clone git@github.com:MichaelBlume/clojure.git\n> cd clojure\n> git checkout origin/rebase-start\n> git rebase origin/rebase-base\n>\n> I get\n>\n> src/jvm/clojure/lang/Compiler.java                          |  26\n> +++++++++++++++++---------\n>  test/clojure/test_clojure/compilation.clj                   |  33\n> ++++++++++++++++++++++++++++++++-\n>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121\n> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>  3 files changed, 170 insertions(+), 10 deletions(-)\n>  create mode 100644 test/clojure/test_clojure/compilation/examples_clj_1561.clj\n> First, rewinding head to replay your work on top of it...\n> Applying: CLJ-1603 - add reducible cycle, iterate, repeat\n> Applying: CLJ-1515 Reify range\n> Applying: CLJ-1499 Direct iterators for PersistentHashMap,\n> APersistentSet, PersistentQueue, and PersistentStructMap, and records.\n> Added new IMapIterable interface for key and val iterators.\n> Applying: CLJ-1602 Make keys and vals return Iterable result\n> Applying: fix AOT bug preventing overriding of clojure.core functions\n> Applying: catch multiple rest forms\n> Applying: zipmap using iterators and transient maps\n> Applying: Define merge/merge-with after reduce has loaded\n> Applying: very simple test of the merge function\n> Applying: Support get on arbitrary java.util.List instances\n> Applying: CLJ-1451 add take-until\n> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn\n> Applying: add unrolled vector implementation\n> Applying: add transient? predicate\n> Applying: fix emitted line numbers\n> Using index info to reconstruct a base tree...\n> M src/jvm/clojure/lang/Compiler.java\n> Falling back to patching base and 3-way merge...\n> Auto-merging src/jvm/clojure/lang/Compiler.java\n> Applying: just use a not\n> Applying: trailing whitespace\n> Applying: don't mix tabs/spaces in clojure.xml/emit-element\n> Applying: avoid mixing tabs with spaces in clojure core code\n> Applying: don't optimize for defrecord lookup if keyword is namespaced\n> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity\n> Applying: unrolled impls for maps\n> Applying: CLJ-703: Remove flush and sync calls when writing class files.\n> Applying: CLJ-1078: Add queue and queue? to clojure.core\n> Applying: make RT.boundedLength lazier\n> Applying: first try for adding compare\n> Applying: Fix for #CLJ-1565\n> Applying: CLJ-1074: Read +/- Infinity and NaN\n> Applying: Fix CLJ-1074 for EdnReader too, see\n> eaeda2e7bf2697e565decdf14a8a99fbf8588c57\n> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms\n> Applying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit\n> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string\n> Applying: if test expr of an if statement is a literal, don't emit the\n> runtime test\n> Applying: evaluate def symbol metadata only once\n> Applying: CLJ-1295: Speed up dissoc on array-maps\n> Applying: some throwing\n> Applying: don't pass offset to ArrayChunk\n> Applying: make EMPTY accessible\n> Applying: add handy create methods\n> Applying: regenerate\n> Applying: regenerate\n> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059\n> Segmentation fault: 11  git apply --index \"$dotest/patch\" > /dev/null\n> 2>&1\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab\n> in indent.\n>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab\n> in indent.\n>    .persistent();\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:15: tab\n> in indent.\n>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:25: tab\n> in indent.\n> ITransientCollection coll = PersistentVector.EMPTY\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:27: tab\n> in indent.\n> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n> warning: squelched 1 whitespace error\n> warning: 6 lines add whitespace errors.\n> Using index info to reconstruct a base tree...\n> M src/jvm/clojure/lang/PersistentUnrolledVector.java\n> <stdin>:13: tab in indent.\n>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n> <stdin>:14: tab in indent.\n>    .persistent();\n> <stdin>:15: tab in indent.\n>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n> <stdin>:25: tab in indent.\n> ITransientCollection coll = PersistentVector.EMPTY\n> <stdin>:27: tab in indent.\n> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n> warning: squelched 1 whitespace error\n> warning: 6 lines applied after fixing whitespace errors.\n> Falling back to patching base and 3-way merge...\n> fatal: Unable to create\n> '/Users/michael.blume/workspace/clojure/.git/index.lock': File exists.\n>\n> If no other git process is currently running, this probably means a\n> git process crashed in this repository earlier. Make sure no other git\n> process is running and remove the file manually to continue.\n> Failed to merge in the changes.\n> Patch failed at 0041 regenerate\n> The copy of the patch that failed is found in:\n>    /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch\n>\n> When you have resolved this problem, run \"git rebase --continue\".\n> If you prefer to skip this patch, run \"git rebase --skip\" instead.\n> To check out the original branch and stop rebasing, run \"git rebase --abort\".\n\nSame problem, exists on master, checking 2.2.2\n"},{"id":"254674","messageId":"CAO2U3Qj-Hg2tb72NgO6wb-aqAxFG7aga2ZDeZNDCPJzGtmHTAA@mail.gmail.com","threadId":"38362","inReplyTo":"CAO2U3Qjn9o_eYayEMCC3S6DBr9kVH7mPL00QGrXAnV2iYRP-=A@mail.gmail.com","subject":"Re: Segmentation fault in git apply","fromName":"Michael Blume","fromEmail":"blume.mike@gmail.com","sentAt":"2015-01-14T18:44:05Z","receivedAt":"2015-01-14T18:44:05Z","isPatch":false,"sender":{"key":"blume.mike@gmail.com","avatar":"https://gravatar.com/avatar/1a7b440e1d942425ff4098ac7fc15b86b30cecaa56e1692a7ef8b5939ba25ea7?d=mp&s=160"},"body":"On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume <blume.mike@gmail.com> wrote:\n> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>> This is a mac with a fresh build of git from pu branch, commit 53b80d0.\n>>\n>> With my gitconfig looking like\n>>\n>> [user]\n>>     email = blume.mike@gmail.com\n>>     name = Michael Blume\n>> [apply]\n>>     whitespace = fix\n>> [core]\n>>     whitespace = fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4\n>>\n>> If I run\n>> git clone git@github.com:MichaelBlume/clojure.git\n>> cd clojure\n>> git checkout origin/rebase-start\n>> git rebase origin/rebase-base\n>>\n>> I get\n>>\n>> src/jvm/clojure/lang/Compiler.java                          |  26\n>> +++++++++++++++++---------\n>>  test/clojure/test_clojure/compilation.clj                   |  33\n>> ++++++++++++++++++++++++++++++++-\n>>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121\n>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>>  3 files changed, 170 insertions(+), 10 deletions(-)\n>>  create mode 100644 test/clojure/test_clojure/compilation/examples_clj_1561.clj\n>> First, rewinding head to replay your work on top of it...\n>> Applying: CLJ-1603 - add reducible cycle, iterate, repeat\n>> Applying: CLJ-1515 Reify range\n>> Applying: CLJ-1499 Direct iterators for PersistentHashMap,\n>> APersistentSet, PersistentQueue, and PersistentStructMap, and records.\n>> Added new IMapIterable interface for key and val iterators.\n>> Applying: CLJ-1602 Make keys and vals return Iterable result\n>> Applying: fix AOT bug preventing overriding of clojure.core functions\n>> Applying: catch multiple rest forms\n>> Applying: zipmap using iterators and transient maps\n>> Applying: Define merge/merge-with after reduce has loaded\n>> Applying: very simple test of the merge function\n>> Applying: Support get on arbitrary java.util.List instances\n>> Applying: CLJ-1451 add take-until\n>> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn\n>> Applying: add unrolled vector implementation\n>> Applying: add transient? predicate\n>> Applying: fix emitted line numbers\n>> Using index info to reconstruct a base tree...\n>> M src/jvm/clojure/lang/Compiler.java\n>> Falling back to patching base and 3-way merge...\n>> Auto-merging src/jvm/clojure/lang/Compiler.java\n>> Applying: just use a not\n>> Applying: trailing whitespace\n>> Applying: don't mix tabs/spaces in clojure.xml/emit-element\n>> Applying: avoid mixing tabs with spaces in clojure core code\n>> Applying: don't optimize for defrecord lookup if keyword is namespaced\n>> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity\n>> Applying: unrolled impls for maps\n>> Applying: CLJ-703: Remove flush and sync calls when writing class files.\n>> Applying: CLJ-1078: Add queue and queue? to clojure.core\n>> Applying: make RT.boundedLength lazier\n>> Applying: first try for adding compare\n>> Applying: Fix for #CLJ-1565\n>> Applying: CLJ-1074: Read +/- Infinity and NaN\n>> Applying: Fix CLJ-1074 for EdnReader too, see\n>> eaeda2e7bf2697e565decdf14a8a99fbf8588c57\n>> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms\n>> Applying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit\n>> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string\n>> Applying: if test expr of an if statement is a literal, don't emit the\n>> runtime test\n>> Applying: evaluate def symbol metadata only once\n>> Applying: CLJ-1295: Speed up dissoc on array-maps\n>> Applying: some throwing\n>> Applying: don't pass offset to ArrayChunk\n>> Applying: make EMPTY accessible\n>> Applying: add handy create methods\n>> Applying: regenerate\n>> Applying: regenerate\n>> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059\n>> Segmentation fault: 11  git apply --index \"$dotest/patch\" > /dev/null\n>> 2>&1\n>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab\n>> in indent.\n>>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab\n>> in indent.\n>>    .persistent();\n>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:15: tab\n>> in indent.\n>>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:25: tab\n>> in indent.\n>> ITransientCollection coll = PersistentVector.EMPTY\n>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:27: tab\n>> in indent.\n>> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n>> warning: squelched 1 whitespace error\n>> warning: 6 lines add whitespace errors.\n>> Using index info to reconstruct a base tree...\n>> M src/jvm/clojure/lang/PersistentUnrolledVector.java\n>> <stdin>:13: tab in indent.\n>>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n>> <stdin>:14: tab in indent.\n>>    .persistent();\n>> <stdin>:15: tab in indent.\n>>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n>> <stdin>:25: tab in indent.\n>> ITransientCollection coll = PersistentVector.EMPTY\n>> <stdin>:27: tab in indent.\n>> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n>> warning: squelched 1 whitespace error\n>> warning: 6 lines applied after fixing whitespace errors.\n>> Falling back to patching base and 3-way merge...\n>> fatal: Unable to create\n>> '/Users/michael.blume/workspace/clojure/.git/index.lock': File exists.\n>>\n>> If no other git process is currently running, this probably means a\n>> git process crashed in this repository earlier. Make sure no other git\n>> process is running and remove the file manually to continue.\n>> Failed to merge in the changes.\n>> Patch failed at 0041 regenerate\n>> The copy of the patch that failed is found in:\n>>    /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch\n>>\n>> When you have resolved this problem, run \"git rebase --continue\".\n>> If you prefer to skip this patch, run \"git rebase --skip\" instead.\n>> To check out the original branch and stop rebasing, run \"git rebase --abort\".\n>\n> Same problem, exists on master, checking 2.2.2\nExists in 2.2.2, checking 2.0.0\n"},{"id":"254675","messageId":"CAO2U3Qhd_DPP09BUyMr6NKUtOe4EQQ7G83BRg7MbtQXFPjKv8w@mail.gmail.com","threadId":"38362","inReplyTo":"CAO2U3Qj-Hg2tb72NgO6wb-aqAxFG7aga2ZDeZNDCPJzGtmHTAA@mail.gmail.com","subject":"Re: Segmentation fault in git apply","fromName":"Michael Blume","fromEmail":"blume.mike@gmail.com","sentAt":"2015-01-14T18:48:51Z","receivedAt":"2015-01-14T18:48:51Z","isPatch":false,"sender":{"key":"blume.mike@gmail.com","avatar":"https://gravatar.com/avatar/1a7b440e1d942425ff4098ac7fc15b86b30cecaa56e1692a7ef8b5939ba25ea7?d=mp&s=160"},"body":"On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume <blume.mike@gmail.com> wrote:\n> On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>>> This is a mac with a fresh build of git from pu branch, commit 53b80d0.\n>>>\n>>> With my gitconfig looking like\n>>>\n>>> [user]\n>>>     email = blume.mike@gmail.com\n>>>     name = Michael Blume\n>>> [apply]\n>>>     whitespace = fix\n>>> [core]\n>>>     whitespace = fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4\n>>>\n>>> If I run\n>>> git clone git@github.com:MichaelBlume/clojure.git\n>>> cd clojure\n>>> git checkout origin/rebase-start\n>>> git rebase origin/rebase-base\n>>>\n>>> I get\n>>>\n>>> src/jvm/clojure/lang/Compiler.java                          |  26\n>>> +++++++++++++++++---------\n>>>  test/clojure/test_clojure/compilation.clj                   |  33\n>>> ++++++++++++++++++++++++++++++++-\n>>>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121\n>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>>>  3 files changed, 170 insertions(+), 10 deletions(-)\n>>>  create mode 100644 test/clojure/test_clojure/compilation/examples_clj_1561.clj\n>>> First, rewinding head to replay your work on top of it...\n>>> Applying: CLJ-1603 - add reducible cycle, iterate, repeat\n>>> Applying: CLJ-1515 Reify range\n>>> Applying: CLJ-1499 Direct iterators for PersistentHashMap,\n>>> APersistentSet, PersistentQueue, and PersistentStructMap, and records.\n>>> Added new IMapIterable interface for key and val iterators.\n>>> Applying: CLJ-1602 Make keys and vals return Iterable result\n>>> Applying: fix AOT bug preventing overriding of clojure.core functions\n>>> Applying: catch multiple rest forms\n>>> Applying: zipmap using iterators and transient maps\n>>> Applying: Define merge/merge-with after reduce has loaded\n>>> Applying: very simple test of the merge function\n>>> Applying: Support get on arbitrary java.util.List instances\n>>> Applying: CLJ-1451 add take-until\n>>> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn\n>>> Applying: add unrolled vector implementation\n>>> Applying: add transient? predicate\n>>> Applying: fix emitted line numbers\n>>> Using index info to reconstruct a base tree...\n>>> M src/jvm/clojure/lang/Compiler.java\n>>> Falling back to patching base and 3-way merge...\n>>> Auto-merging src/jvm/clojure/lang/Compiler.java\n>>> Applying: just use a not\n>>> Applying: trailing whitespace\n>>> Applying: don't mix tabs/spaces in clojure.xml/emit-element\n>>> Applying: avoid mixing tabs with spaces in clojure core code\n>>> Applying: don't optimize for defrecord lookup if keyword is namespaced\n>>> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity\n>>> Applying: unrolled impls for maps\n>>> Applying: CLJ-703: Remove flush and sync calls when writing class files.\n>>> Applying: CLJ-1078: Add queue and queue? to clojure.core\n>>> Applying: make RT.boundedLength lazier\n>>> Applying: first try for adding compare\n>>> Applying: Fix for #CLJ-1565\n>>> Applying: CLJ-1074: Read +/- Infinity and NaN\n>>> Applying: Fix CLJ-1074 for EdnReader too, see\n>>> eaeda2e7bf2697e565decdf14a8a99fbf8588c57\n>>> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms\n>>> Applying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit\n>>> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string\n>>> Applying: if test expr of an if statement is a literal, don't emit the\n>>> runtime test\n>>> Applying: evaluate def symbol metadata only once\n>>> Applying: CLJ-1295: Speed up dissoc on array-maps\n>>> Applying: some throwing\n>>> Applying: don't pass offset to ArrayChunk\n>>> Applying: make EMPTY accessible\n>>> Applying: add handy create methods\n>>> Applying: regenerate\n>>> Applying: regenerate\n>>> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059\n>>> Segmentation fault: 11  git apply --index \"$dotest/patch\" > /dev/null\n>>> 2>&1\n>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab\n>>> in indent.\n>>>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab\n>>> in indent.\n>>>    .persistent();\n>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:15: tab\n>>> in indent.\n>>>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:25: tab\n>>> in indent.\n>>> ITransientCollection coll = PersistentVector.EMPTY\n>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:27: tab\n>>> in indent.\n>>> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n>>> warning: squelched 1 whitespace error\n>>> warning: 6 lines add whitespace errors.\n>>> Using index info to reconstruct a base tree...\n>>> M src/jvm/clojure/lang/PersistentUnrolledVector.java\n>>> <stdin>:13: tab in indent.\n>>>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n>>> <stdin>:14: tab in indent.\n>>>    .persistent();\n>>> <stdin>:15: tab in indent.\n>>>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n>>> <stdin>:25: tab in indent.\n>>> ITransientCollection coll = PersistentVector.EMPTY\n>>> <stdin>:27: tab in indent.\n>>> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n>>> warning: squelched 1 whitespace error\n>>> warning: 6 lines applied after fixing whitespace errors.\n>>> Falling back to patching base and 3-way merge...\n>>> fatal: Unable to create\n>>> '/Users/michael.blume/workspace/clojure/.git/index.lock': File exists.\n>>>\n>>> If no other git process is currently running, this probably means a\n>>> git process crashed in this repository earlier. Make sure no other git\n>>> process is running and remove the file manually to continue.\n>>> Failed to merge in the changes.\n>>> Patch failed at 0041 regenerate\n>>> The copy of the patch that failed is found in:\n>>>    /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch\n>>>\n>>> When you have resolved this problem, run \"git rebase --continue\".\n>>> If you prefer to skip this patch, run \"git rebase --skip\" instead.\n>>> To check out the original branch and stop rebasing, run \"git rebase --abort\".\n>>\n>> Same problem, exists on master, checking 2.2.2\n> Exists in 2.2.2, checking 2.0.0\nOk, problem exists in 2.0.0 but not in 1.8.0, bisecting...\n"},{"id":"254676","messageId":"xmqqiog99ox9.fsf@gitster.dls.corp.google.com","threadId":"38362","inReplyTo":"CAO2U3QjGUfnTRO_poS+=-MfE4aYGuWpVJTe20H-u=FgkVy-RYg@mail.gmail.com","subject":"Re: Segmentation fault in git apply","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-14T18:50:58Z","receivedAt":"2015-01-14T18:50:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Blume <blume.mike@gmail.com> writes:\n\n> This is a mac with a fresh build of git from pu branch, commit 53b80d0.\n\nHmm, I do not see anything suspicious between master and pu.  Is it\npossible to bisect?\n"},{"id":"254678","messageId":"CAO2U3Qje-YwcV1d5BK_zZqrTki4AU=emdkUZzEEieRjmoQdmGg@mail.gmail.com","threadId":"38362","inReplyTo":"CAO2U3Qhd_DPP09BUyMr6NKUtOe4EQQ7G83BRg7MbtQXFPjKv8w@mail.gmail.com","subject":"Re: Segmentation fault in git apply","fromName":"Michael Blume","fromEmail":"blume.mike@gmail.com","sentAt":"2015-01-14T18:58:47Z","receivedAt":"2015-01-14T18:58:47Z","isPatch":false,"sender":{"key":"blume.mike@gmail.com","avatar":"https://gravatar.com/avatar/1a7b440e1d942425ff4098ac7fc15b86b30cecaa56e1692a7ef8b5939ba25ea7?d=mp&s=160"},"body":"On Wed, Jan 14, 2015 at 10:48 AM, Michael Blume <blume.mike@gmail.com> wrote:\n> On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>> On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>>> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>>>> This is a mac with a fresh build of git from pu branch, commit 53b80d0.\n>>>>\n>>>> With my gitconfig looking like\n>>>>\n>>>> [user]\n>>>>     email = blume.mike@gmail.com\n>>>>     name = Michael Blume\n>>>> [apply]\n>>>>     whitespace = fix\n>>>> [core]\n>>>>     whitespace = fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4\n>>>>\n>>>> If I run\n>>>> git clone git@github.com:MichaelBlume/clojure.git\n>>>> cd clojure\n>>>> git checkout origin/rebase-start\n>>>> git rebase origin/rebase-base\n>>>>\n>>>> I get\n>>>>\n>>>> src/jvm/clojure/lang/Compiler.java                          |  26\n>>>> +++++++++++++++++---------\n>>>>  test/clojure/test_clojure/compilation.clj                   |  33\n>>>> ++++++++++++++++++++++++++++++++-\n>>>>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121\n>>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>>>>  3 files changed, 170 insertions(+), 10 deletions(-)\n>>>>  create mode 100644 test/clojure/test_clojure/compilation/examples_clj_1561.clj\n>>>> First, rewinding head to replay your work on top of it...\n>>>> Applying: CLJ-1603 - add reducible cycle, iterate, repeat\n>>>> Applying: CLJ-1515 Reify range\n>>>> Applying: CLJ-1499 Direct iterators for PersistentHashMap,\n>>>> APersistentSet, PersistentQueue, and PersistentStructMap, and records.\n>>>> Added new IMapIterable interface for key and val iterators.\n>>>> Applying: CLJ-1602 Make keys and vals return Iterable result\n>>>> Applying: fix AOT bug preventing overriding of clojure.core functions\n>>>> Applying: catch multiple rest forms\n>>>> Applying: zipmap using iterators and transient maps\n>>>> Applying: Define merge/merge-with after reduce has loaded\n>>>> Applying: very simple test of the merge function\n>>>> Applying: Support get on arbitrary java.util.List instances\n>>>> Applying: CLJ-1451 add take-until\n>>>> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn\n>>>> Applying: add unrolled vector implementation\n>>>> Applying: add transient? predicate\n>>>> Applying: fix emitted line numbers\n>>>> Using index info to reconstruct a base tree...\n>>>> M src/jvm/clojure/lang/Compiler.java\n>>>> Falling back to patching base and 3-way merge...\n>>>> Auto-merging src/jvm/clojure/lang/Compiler.java\n>>>> Applying: just use a not\n>>>> Applying: trailing whitespace\n>>>> Applying: don't mix tabs/spaces in clojure.xml/emit-element\n>>>> Applying: avoid mixing tabs with spaces in clojure core code\n>>>> Applying: don't optimize for defrecord lookup if keyword is namespaced\n>>>> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity\n>>>> Applying: unrolled impls for maps\n>>>> Applying: CLJ-703: Remove flush and sync calls when writing class files.\n>>>> Applying: CLJ-1078: Add queue and queue? to clojure.core\n>>>> Applying: make RT.boundedLength lazier\n>>>> Applying: first try for adding compare\n>>>> Applying: Fix for #CLJ-1565\n>>>> Applying: CLJ-1074: Read +/- Infinity and NaN\n>>>> Applying: Fix CLJ-1074 for EdnReader too, see\n>>>> eaeda2e7bf2697e565decdf14a8a99fbf8588c57\n>>>> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms\n>>>> Applying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit\n>>>> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string\n>>>> Applying: if test expr of an if statement is a literal, don't emit the\n>>>> runtime test\n>>>> Applying: evaluate def symbol metadata only once\n>>>> Applying: CLJ-1295: Speed up dissoc on array-maps\n>>>> Applying: some throwing\n>>>> Applying: don't pass offset to ArrayChunk\n>>>> Applying: make EMPTY accessible\n>>>> Applying: add handy create methods\n>>>> Applying: regenerate\n>>>> Applying: regenerate\n>>>> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059\n>>>> Segmentation fault: 11  git apply --index \"$dotest/patch\" > /dev/null\n>>>> 2>&1\n>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab\n>>>> in indent.\n>>>>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab\n>>>> in indent.\n>>>>    .persistent();\n>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:15: tab\n>>>> in indent.\n>>>>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:25: tab\n>>>> in indent.\n>>>> ITransientCollection coll = PersistentVector.EMPTY\n>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:27: tab\n>>>> in indent.\n>>>> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n>>>> warning: squelched 1 whitespace error\n>>>> warning: 6 lines add whitespace errors.\n>>>> Using index info to reconstruct a base tree...\n>>>> M src/jvm/clojure/lang/PersistentUnrolledVector.java\n>>>> <stdin>:13: tab in indent.\n>>>>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n>>>> <stdin>:14: tab in indent.\n>>>>    .persistent();\n>>>> <stdin>:15: tab in indent.\n>>>>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n>>>> <stdin>:25: tab in indent.\n>>>> ITransientCollection coll = PersistentVector.EMPTY\n>>>> <stdin>:27: tab in indent.\n>>>> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n>>>> warning: squelched 1 whitespace error\n>>>> warning: 6 lines applied after fixing whitespace errors.\n>>>> Falling back to patching base and 3-way merge...\n>>>> fatal: Unable to create\n>>>> '/Users/michael.blume/workspace/clojure/.git/index.lock': File exists.\n>>>>\n>>>> If no other git process is currently running, this probably means a\n>>>> git process crashed in this repository earlier. Make sure no other git\n>>>> process is running and remove the file manually to continue.\n>>>> Failed to merge in the changes.\n>>>> Patch failed at 0041 regenerate\n>>>> The copy of the patch that failed is found in:\n>>>>    /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch\n>>>>\n>>>> When you have resolved this problem, run \"git rebase --continue\".\n>>>> If you prefer to skip this patch, run \"git rebase --skip\" instead.\n>>>> To check out the original branch and stop rebasing, run \"git rebase --abort\".\n>>>\n>>> Same problem, exists on master, checking 2.2.2\n>> Exists in 2.2.2, checking 2.0.0\n> Ok, problem exists in 2.0.0 but not in 1.8.0, bisecting...\nHmm, sorry, no, this is strange, problem actually does exist in 1.8.0\nbut waits until a later commit and has somewhat different output but\nstill looks like a crash in git-apply...\n\nFirst, rewinding head to replay your work on top of it...\nApplying: CLJ-1603 - add reducible cycle, iterate, repeat\nApplying: CLJ-1515 Reify range\nApplying: CLJ-1499 Direct iterators for PersistentHashMap,\nAPersistentSet, PersistentQueue, and PersistentStructMap, and records.\nAdded new IMapIterable interface for key and val iterators.\nApplying: CLJ-1602 Make keys and vals return Iterable result\nApplying: fix AOT bug preventing overriding of clojure.core functions\nApplying: catch multiple rest forms\nApplying: zipmap using iterators and transient maps\nApplying: Define merge/merge-with after reduce has loaded\nApplying: very simple test of the merge function\nApplying: Support get on arbitrary java.util.List instances\nApplying: CLJ-1451 add take-until\nApplying: CLJ-1606 - complete eduction's xform without completing outer rfn\nApplying: add unrolled vector implementation\nApplying: add transient? predicate\nApplying: fix emitted line numbers\nUsing index info to reconstruct a base tree...\nM src/jvm/clojure/lang/Compiler.java\nFalling back to patching base and 3-way merge...\nAuto-merging src/jvm/clojure/lang/Compiler.java\nApplying: just use a not\nApplying: trailing whitespace\nApplying: don't mix tabs/spaces in clojure.xml/emit-element\nApplying: avoid mixing tabs with spaces in clojure core code\nApplying: don't optimize for defrecord lookup if keyword is namespaced\nApplying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity\nApplying: unrolled impls for maps\nApplying: CLJ-703: Remove flush and sync calls when writing class files.\nApplying: CLJ-1078: Add queue and queue? to clojure.core\nApplying: make RT.boundedLength lazier\nApplying: first try for adding compare\nApplying: Fix for #CLJ-1565\nApplying: CLJ-1074: Read +/- Infinity and NaN\nApplying: Fix CLJ-1074 for EdnReader too, see\neaeda2e7bf2697e565decdf14a8a99fbf8588c57\nApplying: add get-and-set! to expose AtomicReference.getAndSet() for atoms\nApplying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit\nApplying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string\nApplying: if test expr of an if statement is a literal, don't emit the\nruntime test\nApplying: evaluate def symbol metadata only once\nApplying: CLJ-1295: Speed up dissoc on array-maps\nApplying: some throwing\nApplying: don't pass offset to ArrayChunk\nApplying: make EMPTY accessible\nApplying: add handy create methods\nApplying: regenerate\nApplying: regenerate\nApplying: fix handling of key meta in assoc\nApplying: don't check mapequivalence\nApplying: add editablemap\nApplying: use an arraymap in persistenthashset\nApplying: no, use an unrolledmap\nApplying: use the new stuff\nApplying: CLJ-1613: evaluate :or defaults in enclosing scope in map\ndestructuring\nApplying: CLJ-1615 ensure transient set \"keys\" and \"values\" have\nconsistent metadata\nApplying: fix the unrolledmap transient entryat thing\n/Users/michael.blume/libexec/git-core/git-am: line 811: 59793 Abort\ntrap: 6           git apply --index \"$dotest/patch\" > /dev/null 2>&1\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:10: tab\nin indent.\nIMapEntry doEntryAt(Object key) {\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:11: tab\nin indent.\n   int h = Util.hasheq(key);\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:12: tab\nin indent.\n   int idx = indexOf(h, key);\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab\nin indent.\n   switch (idx) {\n/Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab\nin indent.\n   case 0:\nwarning: squelched 15 whitespace errors\nwarning: 20 lines add whitespace errors.\nUsing index info to reconstruct a base tree...\nM src/jvm/clojure/lang/PersistentUnrolledMap.java\n<stdin>:10: tab in indent.\nIMapEntry doEntryAt(Object key) {\n<stdin>:11: tab in indent.\n   int h = Util.hasheq(key);\n<stdin>:12: tab in indent.\n   int idx = indexOf(h, key);\n<stdin>:13: tab in indent.\n   switch (idx) {\n<stdin>:14: tab in indent.\n   case 0:\nwarning: squelched 15 whitespace errors\nwarning: 20 lines applied after fixing whitespace errors.\nFalling back to patching base and 3-way merge...\nfatal: Unable to create\n'/Users/michael.blume/workspace/clojure/.git/index.lock': File exists.\n\nIf no other git process is currently running, this probably means a\ngit process crashed in this repository earlier. Make sure no other git\nprocess is running and remove the file manually to continue.\nFailed to merge in the changes.\nPatch failed at 0050 fix the unrolledmap transient entryat thing\nThe copy of the patch that failed is found in:\n   /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch\n\nWhen you have resolved this problem, run \"git rebase --continue\".\nIf you prefer to skip this patch, run \"git rebase --skip\" instead.\nTo check out the original branch and stop rebasing, run \"git rebase --abort\".\n"},{"id":"254682","messageId":"CAO2U3Qi4TWZiNoOQVSW=Ycvp3bpBySZrCGmRLCbRJJes_n2Wkw@mail.gmail.com","threadId":"38362","inReplyTo":"CAO2U3Qje-YwcV1d5BK_zZqrTki4AU=emdkUZzEEieRjmoQdmGg@mail.gmail.com","subject":"Re: Segmentation fault in git apply","fromName":"Michael Blume","fromEmail":"blume.mike@gmail.com","sentAt":"2015-01-14T19:09:30Z","receivedAt":"2015-01-14T19:09:30Z","isPatch":false,"sender":{"key":"blume.mike@gmail.com","avatar":"https://gravatar.com/avatar/1a7b440e1d942425ff4098ac7fc15b86b30cecaa56e1692a7ef8b5939ba25ea7?d=mp&s=160"},"body":"On Wed, Jan 14, 2015 at 10:58 AM, Michael Blume <blume.mike@gmail.com> wrote:\n> On Wed, Jan 14, 2015 at 10:48 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>> On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>>> On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>>>> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume <blume.mike@gmail.com> wrote:\n>>>>> This is a mac with a fresh build of git from pu branch, commit 53b80d0.\n>>>>>\n>>>>> With my gitconfig looking like\n>>>>>\n>>>>> [user]\n>>>>>     email = blume.mike@gmail.com\n>>>>>     name = Michael Blume\n>>>>> [apply]\n>>>>>     whitespace = fix\n>>>>> [core]\n>>>>>     whitespace = fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4\n>>>>>\n>>>>> If I run\n>>>>> git clone git@github.com:MichaelBlume/clojure.git\n>>>>> cd clojure\n>>>>> git checkout origin/rebase-start\n>>>>> git rebase origin/rebase-base\n>>>>>\n>>>>> I get\n>>>>>\n>>>>> src/jvm/clojure/lang/Compiler.java                          |  26\n>>>>> +++++++++++++++++---------\n>>>>>  test/clojure/test_clojure/compilation.clj                   |  33\n>>>>> ++++++++++++++++++++++++++++++++-\n>>>>>  test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121\n>>>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n>>>>>  3 files changed, 170 insertions(+), 10 deletions(-)\n>>>>>  create mode 100644 test/clojure/test_clojure/compilation/examples_clj_1561.clj\n>>>>> First, rewinding head to replay your work on top of it...\n>>>>> Applying: CLJ-1603 - add reducible cycle, iterate, repeat\n>>>>> Applying: CLJ-1515 Reify range\n>>>>> Applying: CLJ-1499 Direct iterators for PersistentHashMap,\n>>>>> APersistentSet, PersistentQueue, and PersistentStructMap, and records.\n>>>>> Added new IMapIterable interface for key and val iterators.\n>>>>> Applying: CLJ-1602 Make keys and vals return Iterable result\n>>>>> Applying: fix AOT bug preventing overriding of clojure.core functions\n>>>>> Applying: catch multiple rest forms\n>>>>> Applying: zipmap using iterators and transient maps\n>>>>> Applying: Define merge/merge-with after reduce has loaded\n>>>>> Applying: very simple test of the merge function\n>>>>> Applying: Support get on arbitrary java.util.List instances\n>>>>> Applying: CLJ-1451 add take-until\n>>>>> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn\n>>>>> Applying: add unrolled vector implementation\n>>>>> Applying: add transient? predicate\n>>>>> Applying: fix emitted line numbers\n>>>>> Using index info to reconstruct a base tree...\n>>>>> M src/jvm/clojure/lang/Compiler.java\n>>>>> Falling back to patching base and 3-way merge...\n>>>>> Auto-merging src/jvm/clojure/lang/Compiler.java\n>>>>> Applying: just use a not\n>>>>> Applying: trailing whitespace\n>>>>> Applying: don't mix tabs/spaces in clojure.xml/emit-element\n>>>>> Applying: avoid mixing tabs with spaces in clojure core code\n>>>>> Applying: don't optimize for defrecord lookup if keyword is namespaced\n>>>>> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity\n>>>>> Applying: unrolled impls for maps\n>>>>> Applying: CLJ-703: Remove flush and sync calls when writing class files.\n>>>>> Applying: CLJ-1078: Add queue and queue? to clojure.core\n>>>>> Applying: make RT.boundedLength lazier\n>>>>> Applying: first try for adding compare\n>>>>> Applying: Fix for #CLJ-1565\n>>>>> Applying: CLJ-1074: Read +/- Infinity and NaN\n>>>>> Applying: Fix CLJ-1074 for EdnReader too, see\n>>>>> eaeda2e7bf2697e565decdf14a8a99fbf8588c57\n>>>>> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms\n>>>>> Applying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit\n>>>>> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string\n>>>>> Applying: if test expr of an if statement is a literal, don't emit the\n>>>>> runtime test\n>>>>> Applying: evaluate def symbol metadata only once\n>>>>> Applying: CLJ-1295: Speed up dissoc on array-maps\n>>>>> Applying: some throwing\n>>>>> Applying: don't pass offset to ArrayChunk\n>>>>> Applying: make EMPTY accessible\n>>>>> Applying: add handy create methods\n>>>>> Applying: regenerate\n>>>>> Applying: regenerate\n>>>>> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059\n>>>>> Segmentation fault: 11  git apply --index \"$dotest/patch\" > /dev/null\n>>>>> 2>&1\n>>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab\n>>>>> in indent.\n>>>>>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n>>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab\n>>>>> in indent.\n>>>>>    .persistent();\n>>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:15: tab\n>>>>> in indent.\n>>>>>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n>>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:25: tab\n>>>>> in indent.\n>>>>> ITransientCollection coll = PersistentVector.EMPTY\n>>>>> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:27: tab\n>>>>> in indent.\n>>>>> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n>>>>> warning: squelched 1 whitespace error\n>>>>> warning: 6 lines add whitespace errors.\n>>>>> Using index info to reconstruct a base tree...\n>>>>> M src/jvm/clojure/lang/PersistentUnrolledVector.java\n>>>>> <stdin>:13: tab in indent.\n>>>>>    IPersistentVector v = (IPersistentVector) asTransient().conj(val)\n>>>>> <stdin>:14: tab in indent.\n>>>>>    .persistent();\n>>>>> <stdin>:15: tab in indent.\n>>>>>    return (IPersistentVector) ((IObj) v).withMeta(meta);\n>>>>> <stdin>:25: tab in indent.\n>>>>> ITransientCollection coll = PersistentVector.EMPTY\n>>>>> <stdin>:27: tab in indent.\n>>>>> return (ITransientVector) coll.conj(e0).conj(e1).conj(e2)\n>>>>> warning: squelched 1 whitespace error\n>>>>> warning: 6 lines applied after fixing whitespace errors.\n>>>>> Falling back to patching base and 3-way merge...\n>>>>> fatal: Unable to create\n>>>>> '/Users/michael.blume/workspace/clojure/.git/index.lock': File exists.\n>>>>>\n>>>>> If no other git process is currently running, this probably means a\n>>>>> git process crashed in this repository earlier. Make sure no other git\n>>>>> process is running and remove the file manually to continue.\n>>>>> Failed to merge in the changes.\n>>>>> Patch failed at 0041 regenerate\n>>>>> The copy of the patch that failed is found in:\n>>>>>    /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch\n>>>>>\n>>>>> When you have resolved this problem, run \"git rebase --continue\".\n>>>>> If you prefer to skip this patch, run \"git rebase --skip\" instead.\n>>>>> To check out the original branch and stop rebasing, run \"git rebase --abort\".\n>>>>\n>>>> Same problem, exists on master, checking 2.2.2\n>>> Exists in 2.2.2, checking 2.0.0\n>> Ok, problem exists in 2.0.0 but not in 1.8.0, bisecting...\n> Hmm, sorry, no, this is strange, problem actually does exist in 1.8.0\n> but waits until a later commit and has somewhat different output but\n> still looks like a crash in git-apply...\n>\n> First, rewinding head to replay your work on top of it...\n> Applying: CLJ-1603 - add reducible cycle, iterate, repeat\n> Applying: CLJ-1515 Reify range\n> Applying: CLJ-1499 Direct iterators for PersistentHashMap,\n> APersistentSet, PersistentQueue, and PersistentStructMap, and records.\n> Added new IMapIterable interface for key and val iterators.\n> Applying: CLJ-1602 Make keys and vals return Iterable result\n> Applying: fix AOT bug preventing overriding of clojure.core functions\n> Applying: catch multiple rest forms\n> Applying: zipmap using iterators and transient maps\n> Applying: Define merge/merge-with after reduce has loaded\n> Applying: very simple test of the merge function\n> Applying: Support get on arbitrary java.util.List instances\n> Applying: CLJ-1451 add take-until\n> Applying: CLJ-1606 - complete eduction's xform without completing outer rfn\n> Applying: add unrolled vector implementation\n> Applying: add transient? predicate\n> Applying: fix emitted line numbers\n> Using index info to reconstruct a base tree...\n> M src/jvm/clojure/lang/Compiler.java\n> Falling back to patching base and 3-way merge...\n> Auto-merging src/jvm/clojure/lang/Compiler.java\n> Applying: just use a not\n> Applying: trailing whitespace\n> Applying: don't mix tabs/spaces in clojure.xml/emit-element\n> Applying: avoid mixing tabs with spaces in clojure core code\n> Applying: don't optimize for defrecord lookup if keyword is namespaced\n> Applying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity\n> Applying: unrolled impls for maps\n> Applying: CLJ-703: Remove flush and sync calls when writing class files.\n> Applying: CLJ-1078: Add queue and queue? to clojure.core\n> Applying: make RT.boundedLength lazier\n> Applying: first try for adding compare\n> Applying: Fix for #CLJ-1565\n> Applying: CLJ-1074: Read +/- Infinity and NaN\n> Applying: Fix CLJ-1074 for EdnReader too, see\n> eaeda2e7bf2697e565decdf14a8a99fbf8588c57\n> Applying: add get-and-set! to expose AtomicReference.getAndSet() for atoms\n> Applying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit\n> Applying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string\n> Applying: if test expr of an if statement is a literal, don't emit the\n> runtime test\n> Applying: evaluate def symbol metadata only once\n> Applying: CLJ-1295: Speed up dissoc on array-maps\n> Applying: some throwing\n> Applying: don't pass offset to ArrayChunk\n> Applying: make EMPTY accessible\n> Applying: add handy create methods\n> Applying: regenerate\n> Applying: regenerate\n> Applying: fix handling of key meta in assoc\n> Applying: don't check mapequivalence\n> Applying: add editablemap\n> Applying: use an arraymap in persistenthashset\n> Applying: no, use an unrolledmap\n> Applying: use the new stuff\n> Applying: CLJ-1613: evaluate :or defaults in enclosing scope in map\n> destructuring\n> Applying: CLJ-1615 ensure transient set \"keys\" and \"values\" have\n> consistent metadata\n> Applying: fix the unrolledmap transient entryat thing\n> /Users/michael.blume/libexec/git-core/git-am: line 811: 59793 Abort\n> trap: 6           git apply --index \"$dotest/patch\" > /dev/null 2>&1\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:10: tab\n> in indent.\n> IMapEntry doEntryAt(Object key) {\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:11: tab\n> in indent.\n>    int h = Util.hasheq(key);\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:12: tab\n> in indent.\n>    int idx = indexOf(h, key);\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:13: tab\n> in indent.\n>    switch (idx) {\n> /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch:14: tab\n> in indent.\n>    case 0:\n> warning: squelched 15 whitespace errors\n> warning: 20 lines add whitespace errors.\n> Using index info to reconstruct a base tree...\n> M src/jvm/clojure/lang/PersistentUnrolledMap.java\n> <stdin>:10: tab in indent.\n> IMapEntry doEntryAt(Object key) {\n> <stdin>:11: tab in indent.\n>    int h = Util.hasheq(key);\n> <stdin>:12: tab in indent.\n>    int idx = indexOf(h, key);\n> <stdin>:13: tab in indent.\n>    switch (idx) {\n> <stdin>:14: tab in indent.\n>    case 0:\n> warning: squelched 15 whitespace errors\n> warning: 20 lines applied after fixing whitespace errors.\n> Falling back to patching base and 3-way merge...\n> fatal: Unable to create\n> '/Users/michael.blume/workspace/clojure/.git/index.lock': File exists.\n>\n> If no other git process is currently running, this probably means a\n> git process crashed in this repository earlier. Make sure no other git\n> process is running and remove the file manually to continue.\n> Failed to merge in the changes.\n> Patch failed at 0050 fix the unrolledmap transient entryat thing\n> The copy of the patch that failed is found in:\n>    /Users/michael.blume/workspace/clojure/.git/rebase-apply/patch\n>\n> When you have resolved this problem, run \"git rebase --continue\".\n> If you prefer to skip this patch, run \"git rebase --skip\" instead.\n> To check out the original branch and stop rebasing, run \"git rebase --abort\".\nOk, looks like this is not purely a mac bug, that's good I guess:\n\n[11:08][ubuntu@saucy-server:~/dev/clojure((f70fdba...))]$ git rebase\norigin/rebase-base\n src/jvm/clojure/lang/Compiler.java                          |  26\n+++++++++++++++++---------\n test/clojure/test_clojure/compilation.clj                   |  33\n++++++++++++++++++++++++++++++++-\n test/clojure/test_clojure/compilation/examples_clj_1561.clj | 121\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 170 insertions(+), 10 deletions(-)\n create mode 100644 test/clojure/test_clojure/compilation/examples_clj_1561.clj\nFirst, rewinding head to replay your work on top of it...\nApplying: CLJ-1603 - add reducible cycle, iterate, repeat\nApplying: CLJ-1515 Reify range\nApplying: CLJ-1499 Direct iterators for PersistentHashMap,\nAPersistentSet, PersistentQueue, and PersistentStructMap, and records.\nAdded new IMapIterable interface for key and val iterators.\nApplying: CLJ-1602 Make keys and vals return Iterable result\nApplying: fix AOT bug preventing overriding of clojure.core functions\nApplying: catch multiple rest forms\nApplying: zipmap using iterators and transient maps\nApplying: Define merge/merge-with after reduce has loaded\nApplying: very simple test of the merge function\nApplying: Support get on arbitrary java.util.List instances\nApplying: CLJ-1451 add take-until\nApplying: CLJ-1606 - complete eduction's xform without completing outer rfn\nApplying: add unrolled vector implementation\nApplying: add transient? predicate\nApplying: fix emitted line numbers\nUsing index info to reconstruct a base tree...\nM src/jvm/clojure/lang/Compiler.java\nFalling back to patching base and 3-way merge...\nAuto-merging src/jvm/clojure/lang/Compiler.java\nApplying: just use a not\nApplying: trailing whitespace\nApplying: don't mix tabs/spaces in clojure.xml/emit-element\nApplying: avoid mixing tabs with spaces in clojure core code\nApplying: don't optimize for defrecord lookup if keyword is namespaced\nApplying: CLJ-1572 - Extend CollReduce to IReduceInit for supported arity\nApplying: unrolled impls for maps\nApplying: CLJ-703: Remove flush and sync calls when writing class files.\nApplying: CLJ-1078: Add queue and queue? to clojure.core\nApplying: make RT.boundedLength lazier\nApplying: first try for adding compare\nApplying: Fix for #CLJ-1565\nApplying: CLJ-1074: Read +/- Infinity and NaN\nApplying: Fix CLJ-1074 for EdnReader too, see\neaeda2e7bf2697e565decdf14a8a99fbf8588c57\nApplying: add get-and-set! to expose AtomicReference.getAndSet() for atoms\nApplying: CLJ-1472 Locking macro without explicit monitor-enter, monitor-exit\nApplying: CLJ-1449: Add starts-with? ends-with? contains? to clojure.string\nApplying: if test expr of an if statement is a literal, don't emit the\nruntime test\nApplying: evaluate def symbol metadata only once\nApplying: CLJ-1295: Speed up dissoc on array-maps\nApplying: some throwing\nApplying: don't pass offset to ArrayChunk\nApplying: make EMPTY accessible\nApplying: add handy create methods\nApplying: regenerate\nApplying: regenerate\n*** Error in `git': malloc(): memory corruption: 0x0000000001d690a0 ***\n"},{"id":"254733","messageId":"99579252-EF8A-4DAF-A49D-2AC5627ED9E3@gmail.com","threadId":"38362","inReplyTo":"CAO2U3Qi4TWZiNoOQVSW=Ycvp3bpBySZrCGmRLCbRJJes_n2Wkw@mail.gmail.com","subject":"Re: Segmentation fault in git apply","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2015-01-15T08:26:11Z","receivedAt":"2015-01-15T08:26:11Z","isPatch":false,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"On Jan 14, 2015, at 11:09, Michael Blume wrote:\n> On Wed, Jan 14, 2015 at 10:58 AM, Michael Blume  \n> <blume.mike@gmail.com> wrote:\n>> On Wed, Jan 14, 2015 at 10:48 AM, Michael Blume  \n>> <blume.mike@gmail.com> wrote:\n>>> On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume <blume.mike@gmail.com \n>>> > wrote:\n>>>> On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume <blume.mike@gmail.com \n>>>> > wrote:\n>>>>> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume <blume.mike@gmail.com \n>>>>> > wrote:\n>>>>>> This is a mac with a fresh build of git from pu branch, commit  \n>>>>>> 53b80d0.\n>>>>>>\n>>>>>> With my gitconfig looking like\n>>>>>>\n>>>>>> [user]\n>>>>>>    email = blume.mike@gmail.com\n>>>>>>    name = Michael Blume\n>>>>>> [apply]\n>>>>>>    whitespace = fix\n>>>>>> [core]\n>>>>>>    whitespace = fix,trailing-space,space-before-tab, tab-in- \n>>>>>> indent, tabwidth=4\n>>>>>>\n>>>>>> If I run\n>>>>>> git clone git@github.com:MichaelBlume/clojure.git\n>>>>>> cd clojure\n>>>>>> git checkout origin/rebase-start\n>>>>>> git rebase origin/rebase-base\n>>>>>>\n>>>>>> I get\n[...]\n>>>>>> Applying: CLJ-1295: Speed up dissoc on array-maps\n>>>>>> Applying: some throwing\n>>>>>> Applying: don't pass offset to ArrayChunk\n>>>>>> Applying: make EMPTY accessible\n>>>>>> Applying: add handy create methods\n>>>>>> Applying: regenerate\n>>>>>> Applying: regenerate\n>>>>>> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059\n>>>>>> Segmentation fault: 11  git apply --index \"$dotest/patch\" > / \n>>>>>> dev/null\n>>>>>> 2>&1\n\nI can reproduce in a 64-bit v2.1.4 as well, but not in a 32-bit v2.1.4  \nbuild.\n\nMy recipe is slightly different to facilitate automation:\n\ncd /tmp\ngit clone git://github.com/MichaelBlume/clojure.git\ncd clojure\ngit config user.email \"blume.mike@gmail.com\"\ngit config user.name \"Michael Blume\"\ngit config apply.whitespace fix\ngit config core.whitespace \\\n   \"fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4\"\ngit checkout origin/rebase-start\ngit rebase origin/rebase-base\n\nLooks like v1.7.6.6 64-bit works okay.\n\nRunning git bisect run...\n\n5782..2890..1445..722..361..179..91..44..23..13..7..3..1..0\n\nAnd the winner is (first appearing in v1.8.2.2):\n\ncommit 250b3c6c992b3cb04e756eb33bed99442fc55193\nAuthor: Junio C Hamano <gitster@pobox.com>\nDate:   Fri Mar 22 11:10:03 2013 -0700\n\n     apply --whitespace=fix: avoid running over the postimage buffer\n\n     Originally update-pre-post-images could assume that any whitespace\n     fixing will make the result only shorter by unexpanding runs of\n     leading SPs into HTs and removing trailing whitespaces at the end  \nof\n     lines.  Updating the post-image we read from the patch to match the\n     actual result can be performed in-place under this assumption.\n     These days, however, we have tab-in-indent (aka Python) rule whose\n     result can be longer than the original, and we do need to allocate\n     a larger buffer than the input and replace the result.\n\n     Fortunately the support for lengthening rewrite was already added\n     when we began supporting \"match while ignoring whitespace\n     differences\" mode in 86c91f91794c (git apply: option to ignore\n     whitespace differences, 2009-08-04).  We only need to correctly\n     count the number of bytes necessary to hold the updated result and\n     tell the function to allocate a new buffer.\n\n     Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\nAnd just to confirm, building with 250b3c6c^ (which also happens to be  \nv1.8.0.3) does not fail.\n\nAnd the stack trace from the crash dump of a debug build of 250b3c6c is:\n\nThread 0 Crashed:\n0   libSystem.B.dylib  0x00007fff8290242a szone_free + 1222\n1   git                0x0000000100009fe9 apply_one_fragment + 2164  \n(apply.c:2816)\n2   git                0x000000010000a760 apply_fragments + 195  \n(apply.c:2959)\n3   git                0x000000010000b62d apply_data + 96 (apply.c:3340)\n4   git                0x000000010000c0b1 check_patch + 869 (apply.c: \n3559)\n5   git                0x000000010000c157 check_patch_list + 83  \n(apply.c:3574)\n6   git                0x000000010000dc70 apply_patch + 646 (apply.c: \n4189)\n7   git                0x000000010000ea3a cmd_apply + 2700 (apply.c: \n4418)\n8   git                0x0000000100001ae8 run_builtin + 402 (git.c:306)\n9   git                0x0000000100001c9a handle_internal_command +  \n181 (git.c:467)\n10  git                0x0000000100001dab run_argv + 41 (git.c:516)\n11  git                0x0000000100001ede main + 258 (git.c:588)\n12  git                0x0000000100000ee8 start + 52\n\nAnd the gdb backtrace from the core file:\n\n#0  0x00007fff8290242a at szone_free + 1222\n#1  0x0000000100009fe9 in apply_one_fragment (img=0x7fff5fbfe640,  \nfrag=0x100400a60, inaccurate_eof=0, ws_rule=3268, nth_fragment=1) at  \nbuiltin/apply.c:2815\n#2  0x000000010000a760 in apply_fragments (img=0x7fff5fbfe640,  \npatch=0x1004005e0) at builtin/apply.c:2959\n#3  0x000000010000b62d in apply_data (patch=0x1004005e0,  \nst=0x7fff5fbfe6b0, ce=0x1004072e0) at builtin/apply.c:3340\n#4  0x000000010000c0b1 in check_patch (patch=0x1004005e0) at builtin/ \napply.c:3559\n#5  0x000000010000c157 in check_patch_list (patch=0x1004005e0) at  \nbuiltin/apply.c:3574\n#6  0x000000010000dc70 in apply_patch (fd=3, filename=0x7fff5fbff33a \"/ \nprivate/tmp/clojure/.git/rebase-apply/patch\", options=0) at builtin/ \napply.c:4189\n#7  0x000000010000ea3a in cmd_apply (argc=1, argv=0x7fff5fbff178,  \nprefix_=0x0) at builtin/apply.c:4418\n#8  0x0000000100001ae8 in run_builtin (p=0x1001a7070, argc=3,  \nargv=0x7fff5fbff178) at git.c:306\n#9  0x0000000100001c9a in handle_internal_command (argc=3,  \nargv=0x7fff5fbff178) at git.c:467\n#10 0x0000000100001dab in run_argv (argcp=0x7fff5fbff13c,  \nargv=0x7fff5fbff130) at git.c:513\n#11 0x0000000100001ede in main (argc=3, argv=0x7fff5fbff178) at git.c: \n588\n\nThe crashing line at apply.c:2815 is:\n\n   free(oldlines);\n\nAnd oldlines appears to be valid (it has normal program text in it).\n\nRunning with various MallocCheckHeap and MallocErrorAbort settings  \nleads to:\n\ngit(12926) malloc: *** error for object 0x10040be80: incorrect  \nchecksum for freed object - object was probably modified after being  \nfreed.\n\nAnd a new backtrace from the core file:\n\n#0  0x00007fff82962da6 at __kill + 10\n#1  0x00007fff829c5af8 at szone_error + 476\n#2  0x00007fff829c7218 at szone_check + 637\n#3  0x00007fff829caaf8 at malloc_zone_check + 42\n#4  0x00007fff829cb11d at internal_check + 14\n#5  0x00007fff828fc939 at malloc_zone_malloc + 60\n#6  0x00007fff828fc8e0 at malloc + 44\n#7  0x0000000100131ae4 in xmalloc (size=47378) at wrapper.c:50\n#8  0x000000010000950b in update_image (img=0x7fff5fbfe4a0,  \napplied_pos=1569, preimage=0x7fff5fbfe340, postimage=0x7fff5fbfe310)  \nat builtin/apply.c:2533\n#9  0x0000000100009fa7 in apply_one_fragment (img=0x7fff5fbfe4a0,  \nfrag=0x100400a60, inaccurate_eof=0, ws_rule=3268, nth_fragment=1) at  \nbuiltin/apply.c:2808\n#10 0x000000010000a760 in apply_fragments (img=0x7fff5fbfe4a0,  \npatch=0x1004005e0) at builtin/apply.c:2959\n#11 0x000000010000b62d in apply_data (patch=0x1004005e0,  \nst=0x7fff5fbfe510, ce=0x1004072e0) at builtin/apply.c:3340\n#12 0x000000010000c0b1 in check_patch (patch=0x1004005e0) at builtin/ \napply.c:3559\n#13 0x000000010000c157 in check_patch_list (patch=0x1004005e0) at  \nbuiltin/apply.c:3574\n#14 0x000000010000dc70 in apply_patch (fd=9, filename=0x7fff5fbff1e2 \"/ \nprivate/tmp/clojure/.git/rebase-apply/patch\", options=0) at builtin/ \napply.c:4189\n#15 0x000000010000ea3a in cmd_apply (argc=1, argv=0x7fff5fbfefe0,  \nprefix_=0x0) at builtin/apply.c:4418\n#16 0x0000000100001ae8 in run_builtin (p=0x1001a7070, argc=3,  \nargv=0x7fff5fbfefe0) at git.c:306\n#17 0x0000000100001c9a in handle_internal_command (argc=3,  \nargv=0x7fff5fbfefe0) at git.c:467\n#18 0x0000000100001dab in run_argv (argcp=0x7fff5fbfef9c,  \nargv=0x7fff5fbfef90) at git.c:513\n#19 0x0000000100001ede in main (argc=3, argv=0x7fff5fbfefe0) at git.c: \n588\n\nI looked at the code a bit, but a fix does not just jump out at me.   \n From the debug info it seems pretty clear that some memory's being  \nstepped on.\n\n-Kyle\n"},{"id":"254736","messageId":"4157F6B0-DDF4-4F71-A09B-EE216537CA89@gmail.com","threadId":"38362","inReplyTo":"99579252-EF8A-4DAF-A49D-2AC5627ED9E3@gmail.com","subject":"Re: Segmentation fault in git apply","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2015-01-15T09:10:20Z","receivedAt":"2015-01-15T09:10:20Z","isPatch":false,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"On Jan 15, 2015, at 00:26, Kyle J. McKay wrote:\n\n> On Jan 14, 2015, at 11:09, Michael Blume wrote:\n>> On Wed, Jan 14, 2015 at 10:58 AM, Michael Blume  \n>> <blume.mike@gmail.com> wrote:\n>>> On Wed, Jan 14, 2015 at 10:48 AM, Michael Blume <blume.mike@gmail.com \n>>> > wrote:\n>>>> On Wed, Jan 14, 2015 at 10:44 AM, Michael Blume <blume.mike@gmail.com \n>>>> > wrote:\n>>>>> On Wed, Jan 14, 2015 at 10:40 AM, Michael Blume <blume.mike@gmail.com \n>>>>> > wrote:\n>>>>>> On Wed, Jan 14, 2015 at 10:20 AM, Michael Blume <blume.mike@gmail.com \n>>>>>> > wrote:\n>>>>>>> This is a mac with a fresh build of git from pu branch, commit  \n>>>>>>> 53b80d0.\n>>>>>>>\n>>>>>>> With my gitconfig looking like\n>>>>>>>\n>>>>>>> [user]\n>>>>>>>   email = blume.mike@gmail.com\n>>>>>>>   name = Michael Blume\n>>>>>>> [apply]\n>>>>>>>   whitespace = fix\n>>>>>>> [core]\n>>>>>>>   whitespace = fix,trailing-space,space-before-tab, tab-in- \n>>>>>>> indent, tabwidth=4\n>>>>>>>\n>>>>>>> If I run\n>>>>>>> git clone git@github.com:MichaelBlume/clojure.git\n>>>>>>> cd clojure\n>>>>>>> git checkout origin/rebase-start\n>>>>>>> git rebase origin/rebase-base\n>>>>>>>\n>>>>>>> I get\n> [...]\n>>>>>>> Applying: CLJ-1295: Speed up dissoc on array-maps\n>>>>>>> Applying: some throwing\n>>>>>>> Applying: don't pass offset to ArrayChunk\n>>>>>>> Applying: make EMPTY accessible\n>>>>>>> Applying: add handy create methods\n>>>>>>> Applying: regenerate\n>>>>>>> Applying: regenerate\n>>>>>>> /Users/michael.blume/libexec/git-core/git-am: line 854: 92059\n>>>>>>> Segmentation fault: 11  git apply --index \"$dotest/patch\" > / \n>>>>>>> dev/null\n>>>>>>> 2>&1\n>\n> I can reproduce in a 64-bit v2.1.4 as well, but not in a 32-bit  \n> v2.1.4 build.\n>\n> My recipe is slightly different to facilitate automation:\n>\n> cd /tmp\n> git clone git://github.com/MichaelBlume/clojure.git\n> cd clojure\n> git config user.email \"blume.mike@gmail.com\"\n> git config user.name \"Michael Blume\"\n> git config apply.whitespace fix\n> git config core.whitespace \\\n>  \"fix,trailing-space,space-before-tab, tab-in-indent, tabwidth=4\"\n> git checkout origin/rebase-start\n> git rebase origin/rebase-base\n>\n> Looks like v1.7.6.6 64-bit works okay.\n>\n> Running git bisect run...\n>\n> 5782..2890..1445..722..361..179..91..44..23..13..7..3..1..0\n>\n> And the winner is (first appearing in v1.8.2.2):\n>\n> commit 250b3c6c992b3cb04e756eb33bed99442fc55193\n> Author: Junio C Hamano <gitster@pobox.com>\n> Date:   Fri Mar 22 11:10:03 2013 -0700\n>\n>    apply --whitespace=fix: avoid running over the postimage buffer\n[...]\n> And just to confirm, building with 250b3c6c^ (which also happens to  \n> be v1.8.0.3) does not fail.\n[...]\n> Running with various MallocCheckHeap and MallocErrorAbort settings  \n> leads to:\n>\n> git(12926) malloc: *** error for object 0x10040be80: incorrect  \n> checksum for freed object - object was probably modified after being  \n> freed.\n>\n> And a new backtrace from the core file:\n>\n> #0  0x00007fff82962da6 at __kill + 10\n> #1  0x00007fff829c5af8 at szone_error + 476\n> #2  0x00007fff829c7218 at szone_check + 637\n> #3  0x00007fff829caaf8 at malloc_zone_check + 42\n> #4  0x00007fff829cb11d at internal_check + 14\n> #5  0x00007fff828fc939 at malloc_zone_malloc + 60\n> #6  0x00007fff828fc8e0 at malloc + 44\n> #7  0x0000000100131ae4 in xmalloc (size=47378) at wrapper.c:50\n> #8  0x000000010000950b in update_image (img=0x7fff5fbfe4a0,  \n> applied_pos=1569, preimage=0x7fff5fbfe340, postimage=0x7fff5fbfe310)  \n> at builtin/apply.c:2533\n> #9  0x0000000100009fa7 in apply_one_fragment (img=0x7fff5fbfe4a0,  \n> frag=0x100400a60, inaccurate_eof=0, ws_rule=3268, nth_fragment=1) at  \n> builtin/apply.c:2808\n> #10 0x000000010000a760 in apply_fragments (img=0x7fff5fbfe4a0,  \n> patch=0x1004005e0) at builtin/apply.c:2959\n> #11 0x000000010000b62d in apply_data (patch=0x1004005e0,  \n> st=0x7fff5fbfe510, ce=0x1004072e0) at builtin/apply.c:3340\n> #12 0x000000010000c0b1 in check_patch (patch=0x1004005e0) at builtin/ \n> apply.c:3559\n> #13 0x000000010000c157 in check_patch_list (patch=0x1004005e0) at  \n> builtin/apply.c:3574\n> #14 0x000000010000dc70 in apply_patch (fd=9, filename=0x7fff5fbff1e2  \n> \"/private/tmp/clojure/.git/rebase-apply/patch\", options=0) at  \n> builtin/apply.c:4189\n> #15 0x000000010000ea3a in cmd_apply (argc=1, argv=0x7fff5fbfefe0,  \n> prefix_=0x0) at builtin/apply.c:4418\n> #16 0x0000000100001ae8 in run_builtin (p=0x1001a7070, argc=3,  \n> argv=0x7fff5fbfefe0) at git.c:306\n> #17 0x0000000100001c9a in handle_internal_command (argc=3,  \n> argv=0x7fff5fbfefe0) at git.c:467\n> #18 0x0000000100001dab in run_argv (argcp=0x7fff5fbfef9c,  \n> argv=0x7fff5fbfef90) at git.c:513\n> #19 0x0000000100001ede in main (argc=3, argv=0x7fff5fbfefe0) at  \n> git.c:588\n>\n> I looked at the code a bit, but a fix does not just jump out at me.   \n> From the debug info it seems pretty clear that some memory's being  \n> stepped on.\n\nIf I make this change on top of 250b3c6c:\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex df773c75..8795e830 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -2390,6 +2390,8 @@ static int match_fragment(struct image *img,\n  \tfixed_buf = strbuf_detach(&fixed, &fixed_len);\n  \tif (postlen < postimage->len)\n  \t\tpostlen = 0;\n+\tif (postlen)\n+\t\tpostlen = 2 * postimage->len;\n  \tupdate_pre_post_images(preimage, postimage,\n  \t\t\t       fixed_buf, fixed_len, postlen);\n  \treturn 1;\n\nThen the problem goes away.  That seems to suggest that postlen is  \nbeing computed incorrectly, but someone more familiar with bulitin/ \napply.c is going to need to look at it.\n\n-Kyle\n"},{"id":"254836","messageId":"xmqqbnly1oqo.fsf@gitster.dls.corp.google.com","threadId":"38362","inReplyTo":"4157F6B0-DDF4-4F71-A09B-EE216537CA89@gmail.com","subject":"Re: Segmentation fault in git apply","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-16T19:58:55Z","receivedAt":"2015-01-16T19:58:55Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kyle J. McKay\" <mackyle@gmail.com> writes:\n\n> If I make this change on top of 250b3c6c:\n>\n> diff --git a/builtin/apply.c b/builtin/apply.c\n> index df773c75..8795e830 100644\n> --- a/builtin/apply.c\n> +++ b/builtin/apply.c\n> @@ -2390,6 +2390,8 @@ static int match_fragment(struct image *img,\n>  \tfixed_buf = strbuf_detach(&fixed, &fixed_len);\n>  \tif (postlen < postimage->len)\n>  \t\tpostlen = 0;\n> +\tif (postlen)\n> +\t\tpostlen = 2 * postimage->len;\n>  \tupdate_pre_post_images(preimage, postimage,\n>  \t\t\t       fixed_buf, fixed_len, postlen);\n>  \treturn 1;\n>\n> Then the problem goes away.  That seems to suggest that postlen is\n> being computed incorrectly, but someone more familiar with\n> bulitin/apply.c is going to need to look at it.\n\nIndeed, with this, the test case detects under-counting in the\ncaller (the caller counts 262 bytes but the expansion consumes 273\nbytes).\n\n-- >8 --\nSubject: apply: make update_pre_post_images() sanity check the given postlen\n\n---\n builtin/apply.c | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 622ee16..18b7997 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -2174,6 +2174,10 @@ static void update_pre_post_images(struct image *preimage,\n \t/* Fix the length of the whole thing */\n \tpostimage->len = new - postimage->buf;\n \tpostimage->nr -= reduced;\n+\n+\tif (postlen && postlen < (new - postimage->buf))\n+\t\tdie(\"BUG: postlen = %d, used = %d\",\n+\t\t    (int)postlen, (int)(new - postimage->buf));\n }\n \n static int match_fragment(struct image *img,\n-- \n2.3.0-rc0-149-g0286818\n"},{"id":"254845","messageId":"xmqqzj9iz3gu.fsf_-_@gitster.dls.corp.google.com","threadId":"38362","inReplyTo":"xmqqbnly1oqo.fsf@gitster.dls.corp.google.com","subject":"[PATCH] apply: count the size of postimage correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-16T23:54:25Z","receivedAt":"2015-01-16T23:54:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Under --whitespace=fix option, match_fragment() function examines\nthe preimage (the common context and the removed lines in the patch)\nand the file being patched and checks if they match after correcting\nall whitespace errors.  When they are found to match, the common\ncontext lines in the preimage is replaced with the fixed copy,\nbecause these lines will then be copied to the corresponding place\nin the postimage by a later call to update_pre_post_images().  Lines\nthat are added in the postimage, under --whitespace=fix, have their\nwhitespace errors already fixed when apply_one_fragment() prepares\nthe preimage and the postimage, so in the end, application of the\npatch can be done by replacing the block of text in the file being\npatched that matched the preimage with what is in the postimage that\nwas updated by update_pre_post_images().\n\nIn the earlier days, fixing whitespace errors always resulted in\nreduction of size, either collapsing runs of spaces in the indent to\na tab or removing the trailing whitespaces.  These days, however,\nsome whitespace error fix results in extending the size.\n\n250b3c6c (apply --whitespace=fix: avoid running over the postimage\nbuffer, 2013-03-22) tried to compute the final postimage size but\nits math was flawed.  It counted the size of the block of text in\nthe original being patched after fixing the whitespace errors on its\nlines that correspond to the preimage.  That number does not have\nmuch to do with how big the final postimage would be.\n\nInstead count (1) the added lines in the postimage, whose size is\nthe same as in the final patch result because their whitespace\nerrors have already been corrected, and (2) the fixed size of the\nlines that are common.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * This seems to fix the clojure test case without breaking existing\n   tests.  We would need a test case for this, though.\n\n builtin/apply.c | 23 +++++++++++++++++++++--\n 1 file changed, 21 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 622ee16..8e79510 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -2330,6 +2330,23 @@ static int match_fragment(struct image *img,\n \t * ignore whitespace, we were asked to correct whitespace\n \t * errors, so let's try matching after whitespace correction.\n \t *\n+\t * While checking the preimage against the target, whitespace\n+\t * errors in both fixed, we count how large the corresponding\n+\t * postimage needs to be.  The postimage prepared by\n+\t * apply_one_fragment() has whitespace errors fixed on added\n+\t * lines already, but the common lines were propagated as-is,\n+\t * which may become longer when their whitespace errors are\n+\t * fixed.\n+\t */\n+\n+\t/* First count added lines in postimage */\n+\tpostlen = 0;\n+\tfor (i = 0; i < postimage->nr; i++) {\n+\t\tif (!(postimage->line[i].flag & LINE_COMMON))\n+\t\t\tpostlen += postimage->line[i].len;\n+\t}\n+\n+\t/*\n \t * The preimage may extend beyond the end of the file,\n \t * but in this loop we will only handle the part of the\n \t * preimage that falls within the file.\n@@ -2337,7 +2354,6 @@ static int match_fragment(struct image *img,\n \tstrbuf_init(&fixed, preimage->len + 1);\n \torig = preimage->buf;\n \ttarget = img->buf + try;\n-\tpostlen = 0;\n \tfor (i = 0; i < preimage_limit; i++) {\n \t\tsize_t oldlen = preimage->line[i].len;\n \t\tsize_t tgtlen = img->line[try_lno + i].len;\n@@ -2365,7 +2381,10 @@ static int match_fragment(struct image *img,\n \t\tmatch = (tgtfix.len == fixed.len - fixstart &&\n \t\t\t !memcmp(tgtfix.buf, fixed.buf + fixstart,\n \t\t\t\t\t     fixed.len - fixstart));\n-\t\tpostlen += tgtfix.len;\n+\n+\t\t/* Add the length if this is common with the postimage */\n+\t\tif (preimage->line[i].flag & LINE_COMMON)\n+\t\t\tpostlen += tgtfix.len;\n \n \t\tstrbuf_release(&tgtfix);\n \t\tif (!match)\n-- \n2.3.0-rc0-157-g96da9ba\n"},{"id":"254860","messageId":"102e322e68e78e39a7c227f3f3e102c@74d39fa044aa309eaea14b9f57fe79c","threadId":"38362","inReplyTo":"xmqqzj9iz3gu.fsf_-_@gitster.dls.corp.google.com","subject":"[PATCH] test: add git apply whitespace expansion tests","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2015-01-18T10:49:45Z","receivedAt":"2015-01-18T10:49:45Z","isPatch":true,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"When git apply fixes whitespace, the result can end up being\nlonger than the initial text if whitespace ends up being expanded\n(such as with the tab-in-indent option).\n\nSince 250b3c6c (apply --whitespace=fix: avoid running over the\npostimage buffer, 2013-03-22) an attempt has been made to compute\nthe correct final length in such a case.\n\nThese tests all stress the whitespace-expansion-during-apply\ncondition and can result in core dump failures when the final\nlength is not computed correctly.\n\nSigned-off-by: Kyle J. McKay <mackyle@gmail.com>\n---\n\n* Here's some tests.  With \"apply: make update_pre_post_images() sanity\n  check the given postlen\" but not \"apply: count the size of postimage\n  correctly\" test 1/4 and 4/4 trigger the 'die(\"BUG: postlen...' but\n  test 2/4 and 3/4 do not although they fail because git apply generates\n  garbage.\n\n* After applying \"apply: count the size of postimage correctly\" all 4\n  tests pass whereas they all fail without that.  It's interesting that\n  the \"BUG: postlen\" check does not trigger for 2/4 or 3/4 but the output\n  is garbage in those cases without the fix.\n\n* Theses tests can easily trigger core dumps.  It seems to depend on how\n  the git binary was built and what exactly ends up getting stepped on as\n  I have several different Git builds and some of them core dump on tests\n  that others pass or just produce garbage for, but none of them passes\n  2/4 or 3/4 without the \"count postimage size correctly\" fix.\n\n t/t4138-apply-ws-expansion.sh | 121 ++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 121 insertions(+)\n create mode 100755 t/t4138-apply-ws-expansion.sh\n\ndiff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh\nnew file mode 100755\nindex 00000000..140ed9ac\n--- /dev/null\n+++ b/t/t4138-apply-ws-expansion.sh\n@@ -0,0 +1,121 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2015 Kyle J. McKay\n+#\n+\n+# NOTE: To facilitate separate testing, this script can be run\n+# standalone to just create the test files and do nothing else\n+# by first setting the environment variable MAKE_PATCHES=1.\n+\n+test_description='git apply test patches with whitespace expansion.'\n+\n+[ -n \"$MAKE_PATCHES\" ] || \\\n+. ./test-lib.sh\n+\n+#\n+## create test-N, patchN.patch, expect-N files\n+#\n+\n+# test 1\n+printf '\\t%s\\n' 1 2 3 4 5 6 > before\n+printf '\\t%s\\n' 1 2 3 > after\n+printf '%64s\\n' a b c $x >> after\n+printf '\\t%s\\n' 4 5 6 >> after\n+git diff --no-index before after | \\\n+sed -e 's/before/test-1/' -e 's/after/test-1/' > patch1.patch\n+printf '%64s\\n' 1 2 3 4 5 6 > test-1\n+printf '%64s\\n' 1 2 3 a b c 4 5 6 > expect-1\n+\n+# test 2\n+printf '\\t%s\\n' a b c d e f > before\n+printf '\\t%s\\n' a b c > after\n+n=10\n+x=1\n+while [ $x -lt $n ]; do\n+\tprintf '%63s%d\\n' '' $x >> after\n+\tx=$(( $x + 1 ))\n+done\n+printf '\\t%s\\n' d e f >> after\n+git diff --no-index before after | \\\n+sed -e 's/before/test-2/' -e 's/after/test-2/' > patch2.patch\n+printf '%64s\\n' a b c d e f > test-2\n+printf '%64s\\n' a b c > expect-2\n+x=1\n+while [ $x -lt $n ]; do\n+\tprintf '%63s%d\\n' '' $x >> expect-2\n+\tx=$(( $x + 1 ))\n+done\n+printf '%64s\\n' d e f >> expect-2\n+\n+# test 3\n+printf '\\t%s\\n' a b c d e f > before\n+printf '\\t%s\\n' a b c > after\n+n=100\n+x=0\n+while [ $x -lt $n ]; do\n+\tprintf '%63s%02d\\n' '' $x >> after\n+\tx=$(( $x + 1 ))\n+done\n+printf '\\t%s\\n' d e f >> after\n+git diff --no-index before after | \\\n+sed -e 's/before/test-3/' -e 's/after/test-3/' > patch3.patch\n+printf '%64s\\n' a b c d e f > test-3\n+printf '%64s\\n' a b c > expect-3\n+x=0\n+while [ $x -lt $n ]; do\n+\tprintf '%63s%02d\\n' '' $x >> expect-3\n+\tx=$(( $x + 1 ))\n+done\n+printf '%64s\\n' d e f >> expect-3\n+\n+# test 4\n+> before\n+x=0\n+while [ $x -lt 50 ]; do\n+\tprintf '\\t%02d\\n' $x >> before\n+\tx=$(( $x + 1 ))\n+done\n+cat before > after\n+printf '%64s\\n' a b c >> after\n+while [ $x -lt 100 ]; do\n+\tprintf '\\t%02d\\n' $x >> before\n+\tprintf '\\t%02d\\n' $x >> after\n+\tx=$(( $x + 1 ))\n+done\n+git diff --no-index before after | \\\n+sed -e 's/before/test-4/' -e 's/after/test-4/' > patch4.patch\n+> test-4\n+x=0\n+while [ $x -lt 50 ]; do\n+\tprintf '%63s%02d\\n' '' $x >> test-4\n+\tx=$(( $x + 1 ))\n+done\n+cat test-4 > expect-4\n+printf '%64s\\n' a b c >> expect-4\n+while [ $x -lt 100 ]; do\n+\tprintf '%63s%02d\\n' '' $x >> test-4\n+\tprintf '%63s%02d\\n' '' $x >> expect-4\n+\tx=$(( $x + 1 ))\n+done\n+\n+# cleanup\n+rm before after\n+\n+[ -z \"$MAKE_PATCHES\" ] || exit 0\n+\n+#\n+## Run the tests\n+#\n+\n+# Note that `patch` can successfully apply all patches when run\n+# with the --ignore-whitespace option.\n+\n+for t in 1 2 3 4; do\n+\ttest_expect_success \"apply with ws expansion (t=$t)\" '\n+\t\tgit -c core.whitespace=tab-in-indent,tabwidth=63 \\\n+\t\t\tapply --whitespace=fix patch$t.patch &&\n+\t\ttest_cmp test-$t expect-$t\n+\t'\n+done\n+\n+test_done\n--\n"},{"id":"254870","messageId":"CAPc5daXVk_ROUy7rmzS0aosWvE2wqw8tHZgomHHkay9CZjhbiw@mail.gmail.com","threadId":"38362","inReplyTo":"102e322e68e78e39a7c227f3f3e102c@74d39fa044aa309eaea14b9f57fe79c","subject":"Re: [PATCH] test: add git apply whitespace expansion tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-18T22:11:45Z","receivedAt":"2015-01-18T22:11:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"On Sun, Jan 18, 2015 at 2:49 AM, Kyle J. McKay <mackyle@gmail.com> wrote:\n> * Here's some tests.  With \"apply: make update_pre_post_images() sanity\n>   check the given postlen\" but not \"apply: count the size of postimage\n>   correctly\" test 1/4 and 4/4 trigger the 'die(\"BUG: postlen...' but\n>   test 2/4 and 3/4 do not although they fail because git apply generates\n>   garbage.\n\nDo the failing cases that do not trigger the new postlen check fail\nbecause the original (mis)counting thinks (incorrectly) that the\nrewritten result _should_ fit within the original postlen (hence we\nallow an in-place rewrite by passing postlen=0 to the helper), but\nin fact after rewriting postimage->len ends up being longer due to\nthe miscounting?\n"},{"id":"254875","messageId":"AB9246EB-D720-4A4A-9AB7-4307613C19A3@gmail.com","threadId":"38362","inReplyTo":"CAPc5daXVk_ROUy7rmzS0aosWvE2wqw8tHZgomHHkay9CZjhbiw@mail.gmail.com","subject":"Re: [PATCH] test: add git apply whitespace expansion tests","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2015-01-19T03:54:45Z","receivedAt":"2015-01-19T03:54:45Z","isPatch":true,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"On Jan 18, 2015, at 14:11, Junio C Hamano wrote:\n\n> On Sun, Jan 18, 2015 at 2:49 AM, Kyle J. McKay <mackyle@gmail.com>  \n> wrote:\n>> * Here's some tests.  With \"apply: make update_pre_post_images()  \n>> sanity\n>>  check the given postlen\" but not \"apply: count the size of postimage\n>>  correctly\" test 1/4 and 4/4 trigger the 'die(\"BUG: postlen...' but\n>>  test 2/4 and 3/4 do not although they fail because git apply  \n>> generates\n>>  garbage.\n>\n> Do the failing cases that do not trigger the new postlen check fail\n> because the original (mis)counting thinks (incorrectly) that the\n> rewritten result _should_ fit within the original postlen (hence we\n> allow an in-place rewrite by passing postlen=0 to the helper), but\n> in fact after rewriting postimage->len ends up being longer due to\n> the miscounting?\n\nI'm not 100%, but I think so because:\n\nBefore 250b3c6c (apply --whitespace=fix: avoid running over the  \npostimage buffer, 2013-03-22), tests 1 and 4 tend to easily cause seg  \nfaults whereas 2 and 3 just give garbage.\n\nAfter 250b3c6c (apply --whitespace=fix: avoid running over the  \npostimage buffer, 2013-03-22), tests 1 and 4 may pass without seg  \nfaulting although clearly there's some memory corruption going on  \nbecause after \"apply: make update_pre_post_images() sanity check the  \ngiven postlen\" they always die with the BUG message.\n\nI created the tests after reading your description in \"apply: count  \nthe size of postimage correctly\".  I made a guess about what would  \ntrigger the problem -- I do not have a deep understanding of the  \nbuiltin/apply.c code though.  Tests 2 and 3 were attempts to make the  \ndiscrepancy between counted and needed (assuming the \"apply: count the  \nsize of postimage correctly\" fix has not been applied) progressively  \nworse and instead I ended up with a different kind of failure.  Test 4  \nwas then an alternate attempt to create a very large discrepancy and  \nit ended up with BUG: values not that dissimilar from test 1.\n\nFYI, without the counting fix, test 1 causes \"BUG: postlen = 390, used  \n= 585\" and test 4 causes \"BUG: postlen = 396, used = 591\".  So while I  \ndid manage to increase the discrepancy a bit from the values you  \nreported for clojure (postlen = 262, used = 273), I was actually  \naiming for a difference big enough to pretty much always guarantee a  \ncore dump.\n\nThe garbage tests 2 and 3 produce without the counting fix is  \nreminiscent of what you get when you use memcpy instead of memmove for  \nan overlapping memory copy operation.\n\nA slightly modified version of these 4 tests can be run as far back a  \nv1.7.4 (when apply --whitespace=fix started fixing tab-in-indent  \nerrors) and you get core dumps or garbage there too for all 4.\n\nSo since I've not been able to get test 2 or 3 to core dump (even  \nbefore 250b3c6c) I tend to believe you are correct in that the code  \nthinks (incorrectly) that the result should fit within the buffer.  I  \nsay buffer because the test 3 patch inserts 100 lines into a 6 line  \nfile and yet it never seems to cause a core dump (even in v1.7.4), so  \nthe buffer size must be based on the patch, not the original -- I'm  \nsure that would make sense if I understood what's going on in the  \napply code.\n\nI did manage to create a test 5 that causes \"BUG: postlen = 3036, used  \n= 3542\", but its verbose output has unfriendly long lines and it's  \nfixed by the same counting fix as the others so it doesn't seem  \nworthwhile to include it.\n\n-Kyle\n"},{"id":"255037","messageId":"xmqq1tmnwypp.fsf@gitster.dls.corp.google.com","threadId":"38362","inReplyTo":"AB9246EB-D720-4A4A-9AB7-4307613C19A3@gmail.com","subject":"Re: [PATCH] test: add git apply whitespace expansion tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-21T22:33:38Z","receivedAt":"2015-01-21T22:33:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kyle J. McKay\" <mackyle@gmail.com> writes:\n\n> So since I've not been able to get test 2 or 3 to core dump (even\n> before 250b3c6c) I tend to believe you are correct in that the code\n> thinks (incorrectly) that the result should fit within the buffer.\n\nThanks; let me steal your tests when I reroll.\n"},{"id":"255061","messageId":"21FC5344-64BF-46B1-ADA9-DDE3B1FEC8C4@gmail.com","threadId":"38362","inReplyTo":"xmqq1tmnwypp.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] test: add git apply whitespace expansion tests","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2015-01-22T06:55:05Z","receivedAt":"2015-01-22T06:55:05Z","isPatch":true,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"On Jan 21, 2015, at 14:33, Junio C Hamano wrote:\n\n> \"Kyle J. McKay\" <mackyle@gmail.com> writes:\n>\n>> So since I've not been able to get test 2 or 3 to core dump (even\n>> before 250b3c6c) I tend to believe you are correct in that the code\n>> thinks (incorrectly) that the result should fit within the buffer.\n>\n> Thanks; let me steal your tests when I reroll.\n\nAwesome. :)\n\nBut please squash in this tiny change if using the tests verbatim:\n\nOn Jan 18, 2015, at 02:49, Kyle J. McKay wrote:\n\n> +#\n> +## create test-N, patchN.patch, expect-N files\n> +#\n> +\n> +# test 1\n> +printf '\\t%s\\n' 1 2 3 4 5 6 > before\n> +printf '\\t%s\\n' 1 2 3 > after\n> +printf '%64s\\n' a b c $x >> after\n\nThis line ^ in test 1 should not have a '$x' in it.  It should just be:\n\n> +printf '%64s\\n' a b c >> after\n\nThe test runs fine currently, but if somehow x should get defined  \nbefore running the tests, test 1 would fail.  All the other '$x' in  \nthe other tests are correct.\n\n> +printf '\\t%s\\n' 4 5 6 >> after\n> +git diff --no-index before after | \\\n> +sed -e 's/before/test-1/' -e 's/after/test-1/' > patch1.patch\n> +printf '%64s\\n' 1 2 3 4 5 6 > test-1\n> +printf '%64s\\n' 1 2 3 a b c 4 5 6 > expect-1\n> +\n> +# test 2\n\n-Kyle\n"},{"id":"255119","messageId":"xmqq7fwetya3.fsf@gitster.dls.corp.google.com","threadId":"38362","inReplyTo":"21FC5344-64BF-46B1-ADA9-DDE3B1FEC8C4@gmail.com","subject":"Re: [PATCH] test: add git apply whitespace expansion tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-22T19:23:32Z","receivedAt":"2015-01-22T19:23:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kyle J. McKay\" <mackyle@gmail.com> writes:\n\n> On Jan 21, 2015, at 14:33, Junio C Hamano wrote:\n>\n>> \"Kyle J. McKay\" <mackyle@gmail.com> writes:\n>>\n>>> So since I've not been able to get test 2 or 3 to core dump (even\n>>> before 250b3c6c) I tend to believe you are correct in that the code\n>>> thinks (incorrectly) that the result should fit within the buffer.\n>>\n>> Thanks; let me steal your tests when I reroll.\n>\n> Awesome. :)\n>\n> But please squash in this tiny change if using the tests verbatim:\n\nThanks.  I actually have a question wrt the need for $MAKE_PATCHES.\n\nIt would have been more natural to do something like:\n\ntest_expect_success 'setup' '\n\tprintf \"\\t%s\\n\" 1 2 3 4 5 6 >before &&\n\tprintf \"\\t%s\\n\" 1 2 3 >after &&\n\tprintf \"%64s\\n\" a b c >>after &&\n\tprintf \"\\t%s\\n\" 4 5 6 >>after &&\n\tgit diff --no-index before after |\n\tsed -e \"s/before/test-1/\" -e \"s/after/test-1/\" >patch1.patch &&\n\tprintf \"%64s\\n\" 1 2 3 4 5 6 >test-1 &&\n\tprintf \"%64s\\n\" 1 2 3 a b c 4 5 6 >expect-1 &&\n\n\tprintf \"\\t%s\\n\" a b c d e f >before &&\n\tprintf \"\\t%s\\n\" a b c >after &&\n        ...\n\tcat test-4 >expect-4 &&\n\tprintf \"%64s\\n\" a b c >>expect-4 &&\n\twhile test $x -lt 100\n\tdo\n\t\tprintf \"%63s%02d\\n\" \"\" $x >>test-4\n\t\tprintf \"%63s%02d\\n\" \"\" $x >>expect-4\n\t\tx=$(( $x + 1 ))\n\tdone &&\n\n\tgit config core.whitespace tab-in-indent,tabwidth=63 &&\n        git config apply.whitespace fix\n'\n\ntest_expect_success 'apply with ws expansion (1)' '\n\tgit apply patch1.patch &&\n        test_cmp test-1 expect-1\n'\n\nand if you want test files you can just skip tests #2 and later,\nwithout introducing an ad-hoc mechanism like you did.\n\nWas there something more than that that you wanted from\n$MAKE_PATCHES?\n\nIn any case, here is an update to that sanity check patch to catch\nthe two cases the BUG did not trigger.\n\nSometimes the caller under-counted the size of the result but\nthought that it would still fit within the original (hence allowing\nus to update in-place by passing postlen==0) but the actual result\nwas larger than the space we have allocated in the postimage,\nclobbering the piece of memory after the postimage->buf.\n\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 31f8733..3b7ba63 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -2171,6 +2171,12 @@ static void update_pre_post_images(struct image *preimage,\n \t\tctx++;\n \t}\n \n+\tif (postlen\n+\t    ? postlen < new - postimage->buf\n+\t    : postimage->len < new - postimage->buf)\n+\t\tdie(\"BUG: caller miscounted postlen: asked %d, orig = %d, used = %d\",\n+\t\t    (int)postlen, (int) postimage->len, (int)(new - postimage->buf));\n+\n \t/* Fix the length of the whole thing */\n \tpostimage->len = new - postimage->buf;\n \tpostimage->nr -= reduced;\n"},{"id":"255143","messageId":"1421967505-16879-1-git-send-email-gitster@pobox.com","threadId":"38362","inReplyTo":"xmqq1tmnwypp.fsf@gitster.dls.corp.google.com","subject":"[PATCH v2 0/4] apply --whitespace=fix buffer corruption fix","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-22T22:58:21Z","receivedAt":"2015-01-22T22:58:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git apply --whitespace=fix\" used to be able to assume that fixing\nerrors will always reduce the size by e.g. stripping whitespaces at\nthe end of lines or collapsing runs of spaces into tabs at the\nbeginning of lines.  An update to accomodate fixes that lengthens\nthe result by e.g. expanding leading tabs into spaces were made long\ntime ago but the logic miscounted the necessary space after such\nwhitespace fixes, leading to either under-allocation or over-usage\nof already allocated space.\n\nThe second patch in this series is to illustrate this with a runtime\nsanity-check to protect us from future breakage (this is a reroll of\na \"how about this\" weatherbaloon patch $gmane/262579, with Kyle's\ntest script).\n\nThe third patch corrects the under-counting and makes the new test\npass.\n\nThe fourth patch makes us report the fact that we corrected\nwhitespace errors in the common-context part.  When asked to correct\nwhitespace errors, and given a patch that has whitespace errors in\nthe common context (i.e. the lines prefixed with \" \") either in the\npatch itself or the corresponding part in the file we are patching,\nwe have been correcting the whitespace errors \"while at it\" since\naround c1beba5b (git-apply --whitespace=fix: fix whitespace fuzz\nintroduced by previous run, 2008-01-30), but we were not reporting\nthat we saw a need to fix them.\n\nThis is not about the \"buffer corruption fix\", which is the primary\nfocus of this series, but it is here because it is related to\nwhitespace fix.\n\n\nJunio C Hamano (4):\n  typofix\n  apply: make update_pre_post_images() sanity check the given postlen\n  apply: count the size of postimage correctly\n  apply: detect and mark whitespace errors in context lines when fixing\n\n builtin/apply.c               |  34 ++++++++++--\n t/t4138-apply-ws-expansion.sh | 121 ++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 152 insertions(+), 3 deletions(-)\n create mode 100755 t/t4138-apply-ws-expansion.sh\n\n-- \n2.3.0-rc1-116-g84c5016\n"},{"id":"255146","messageId":"1421967505-16879-2-git-send-email-gitster@pobox.com","threadId":"38362","inReplyTo":"1421967505-16879-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 1/4] apply.c: typofix","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-22T22:58:22Z","receivedAt":"2015-01-22T22:58:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Signed-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/apply.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 622ee16..31f8733 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -2326,7 +2326,7 @@ static int match_fragment(struct image *img,\n \n \t/*\n \t * The hunk does not apply byte-by-byte, but the hash says\n-\t * it might with whitespace fuzz. We haven't been asked to\n+\t * it might with whitespace fuzz. We weren't asked to\n \t * ignore whitespace, we were asked to correct whitespace\n \t * errors, so let's try matching after whitespace correction.\n \t *\n-- \n2.3.0-rc1-116-g84c5016\n"},{"id":"255145","messageId":"1421967505-16879-3-git-send-email-gitster@pobox.com","threadId":"38362","inReplyTo":"1421967505-16879-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 2/4] apply: make update_pre_post_images() sanity check the given postlen","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-22T22:58:23Z","receivedAt":"2015-01-22T22:58:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git apply --whitespace=fix\" used to be able to assume that fixing\nerrors will always reduce the size by e.g. stripping whitespaces at\nthe end of lines or collapsing runs of spaces into tabs at the\nbeginning of lines.  An update to accomodate fixes that lengthens\nthe result by e.g. expanding leading tabs into spaces were made long\ntime ago but the logic miscounted the necessary space after such\nwhitespace fixes, leading to either under-allocation or over-usage\nof already allocated space.\n\nIllustrate this with a runtime sanity-check to protect us from\nfuture breakage.  The test was stolen from Kyle McKay who helped\nto identify the problem.\n\nHelped-by: \"Kyle J. McKay\" <mackyle@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/apply.c               |   6 +++\n t/t4138-apply-ws-expansion.sh | 121 ++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 127 insertions(+)\n create mode 100755 t/t4138-apply-ws-expansion.sh\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 31f8733..da6fb35 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -2171,6 +2171,12 @@ static void update_pre_post_images(struct image *preimage,\n \t\tctx++;\n \t}\n \n+\tif (postlen\n+\t    ? postlen < new - postimage->buf\n+\t    : postimage->len < new - postimage->buf)\n+\t\tdie(\"BUG: caller miscounted postlen: asked %d, orig = %d, used = %d\",\n+\t\t    (int)postlen, (int) postimage->len, (int)(new - postimage->buf));\n+\n \t/* Fix the length of the whole thing */\n \tpostimage->len = new - postimage->buf;\n \tpostimage->nr -= reduced;\ndiff --git a/t/t4138-apply-ws-expansion.sh b/t/t4138-apply-ws-expansion.sh\nnew file mode 100755\nindex 0000000..0ffe33f\n--- /dev/null\n+++ b/t/t4138-apply-ws-expansion.sh\n@@ -0,0 +1,121 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2015 Kyle J. McKay\n+#\n+\n+test_description='git apply test patches with whitespace expansion.'\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\t#\n+\t## create test-N, patchN.patch, expect-N files\n+\t#\n+\n+\t# test 1\n+\tprintf \"\\t%s\\n\" 1 2 3 4 5 6 >before &&\n+\tprintf \"\\t%s\\n\" 1 2 3 >after &&\n+\tprintf \"%64s\\n\" a b c >>after &&\n+\tprintf \"\\t%s\\n\" 4 5 6 >>after &&\n+\tgit diff --no-index before after |\n+\t\tsed -e \"s/before/test-1/\" -e \"s/after/test-1/\" >patch1.patch &&\n+\tprintf \"%64s\\n\" 1 2 3 4 5 6 >test-1 &&\n+\tprintf \"%64s\\n\" 1 2 3 a b c 4 5 6 >expect-1 &&\n+\n+\t# test 2\n+\tprintf \"\\t%s\\n\" a b c d e f >before &&\n+\tprintf \"\\t%s\\n\" a b c >after &&\n+\tn=10 &&\n+\tx=1 &&\n+\twhile test $x -lt $n\n+\tdo\n+\t\tprintf \"%63s%d\\n\" \"\" $x >>after\n+\t\tx=$(( $x + 1 ))\n+\tdone &&\n+\tprintf \"\\t%s\\n\" d e f >>after &&\n+\tgit diff --no-index before after |\n+\t\tsed -e \"s/before/test-2/\" -e \"s/after/test-2/\" >patch2.patch &&\n+\tprintf \"%64s\\n\" a b c d e f >test-2 &&\n+\tprintf \"%64s\\n\" a b c >expect-2 &&\n+\tx=1 &&\n+\twhile test $x -lt $n\n+\tdo\n+\t\tprintf \"%63s%d\\n\" \"\" $x >>expect-2\n+\t\tx=$(( $x + 1 ))\n+\tdone &&\n+\tprintf \"%64s\\n\" d e f >>expect-2 &&\n+\n+\t# test 3\n+\tprintf \"\\t%s\\n\" a b c d e f >before &&\n+\tprintf \"\\t%s\\n\" a b c >after &&\n+\tn=100 &&\n+\tx=0 &&\n+\twhile test $x -lt $n\n+\tdo\n+\t\tprintf \"%63s%02d\\n\" \"\" $x >>after\n+\t\tx=$(( $x + 1 ))\n+\tdone &&\n+\tprintf \"\\t%s\\n\" d e f >>after &&\n+\tgit diff --no-index before after |\n+\tsed -e \"s/before/test-3/\" -e \"s/after/test-3/\" >patch3.patch &&\n+\tprintf \"%64s\\n\" a b c d e f >test-3 &&\n+\tprintf \"%64s\\n\" a b c >expect-3 &&\n+\tx=0 &&\n+\twhile test $x -lt $n\n+\tdo\n+\t\tprintf \"%63s%02d\\n\" \"\" $x >>expect-3\n+\t\tx=$(( $x + 1 ))\n+\tdone &&\n+\tprintf \"%64s\\n\" d e f >>expect-3 &&\n+\n+\t# test 4\n+\t>before &&\n+\tx=0 &&\n+\twhile test $x -lt 50\n+\tdo\n+\t\tprintf \"\\t%02d\\n\" $x >>before\n+\t\tx=$(( $x + 1 ))\n+\tdone &&\n+\tcat before >after &&\n+\tprintf \"%64s\\n\" a b c >>after &&\n+\twhile test $x -lt 100\n+\tdo\n+\t\tprintf \"\\t%02d\\n\" $x >>before\n+\t\tprintf \"\\t%02d\\n\" $x >>after\n+\t\tx=$(( $x + 1 ))\n+\tdone &&\n+\tgit diff --no-index before after |\n+\tsed -e \"s/before/test-4/\" -e \"s/after/test-4/\" >patch4.patch &&\n+\t>test-4 &&\n+\tx=0 &&\n+\twhile test $x -lt 50\n+\tdo\n+\t\tprintf \"%63s%02d\\n\" \"\" $x >>test-4\n+\t\tx=$(( $x + 1 ))\n+\tdone &&\n+\tcat test-4 >expect-4 &&\n+\tprintf \"%64s\\n\" a b c >>expect-4 &&\n+\twhile test $x -lt 100\n+\tdo\n+\t\tprintf \"%63s%02d\\n\" \"\" $x >>test-4\n+\t\tprintf \"%63s%02d\\n\" \"\" $x >>expect-4\n+\t\tx=$(( $x + 1 ))\n+\tdone &&\n+\n+\tgit config core.whitespace tab-in-indent,tabwidth=63 &&\n+\tgit config apply.whitespace fix\n+\n+'\n+\n+# Note that `patch` can successfully apply all patches when run\n+# with the --ignore-whitespace option.\n+\n+for t in 1 2 3 4\n+do\n+\ttest_expect_success 'apply with ws expansion (t=$t)' '\n+\t\tgit apply patch$t.patch &&\n+\t\ttest_cmp test-$t expect-$t\n+\t'\n+done\n+\n+test_done\n-- \n2.3.0-rc1-116-g84c5016\n"},{"id":"255144","messageId":"1421967505-16879-4-git-send-email-gitster@pobox.com","threadId":"38362","inReplyTo":"1421967505-16879-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 3/4] apply: count the size of postimage correctly","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-22T22:58:24Z","receivedAt":"2015-01-22T22:58:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Under --whitespace=fix option, match_fragment() function examines\nthe preimage (the common context and the removed lines in the patch)\nand the file being patched and checks if they match after correcting\nall whitespace errors.  When they are found to match, the common\ncontext lines in the preimage is replaced with the fixed copy,\nbecause these lines will then be copied to the corresponding place\nin the postimage by a later call to update_pre_post_images().  Lines\nthat are added in the postimage, under --whitespace=fix, have their\nwhitespace errors already fixed when apply_one_fragment() prepares\nthe preimage and the postimage, so in the end, application of the\npatch can be done by replacing the block of text in the file being\npatched that matched the preimage with what is in the postimage that\nwas updated by update_pre_post_images().\n\nIn the earlier days, fixing whitespace errors always resulted in\nreduction of size, either collapsing runs of spaces in the indent to\na tab or removing the trailing whitespaces.  These days, however,\nsome whitespace error fix results in extending the size.\n\n250b3c6c (apply --whitespace=fix: avoid running over the postimage\nbuffer, 2013-03-22) tried to compute the final postimage size but\nits math was flawed.  It counted the size of the block of text in\nthe original being patched after fixing the whitespace errors on its\nlines that correspond to the preimage.  That number does not have\nmuch to do with how big the final postimage would be.\n\nInstead count (1) the added lines in the postimage, whose size is\nthe same as in the final patch result because their whitespace\nerrors have already been corrected, and (2) the fixed size of the\nlines that are common.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/apply.c | 23 +++++++++++++++++++++--\n 1 file changed, 21 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex da6fb35..e895340 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -2336,6 +2336,23 @@ static int match_fragment(struct image *img,\n \t * ignore whitespace, we were asked to correct whitespace\n \t * errors, so let's try matching after whitespace correction.\n \t *\n+\t * While checking the preimage against the target, whitespace\n+\t * errors in both fixed, we count how large the corresponding\n+\t * postimage needs to be.  The postimage prepared by\n+\t * apply_one_fragment() has whitespace errors fixed on added\n+\t * lines already, but the common lines were propagated as-is,\n+\t * which may become longer when their whitespace errors are\n+\t * fixed.\n+\t */\n+\n+\t/* First count added lines in postimage */\n+\tpostlen = 0;\n+\tfor (i = 0; i < postimage->nr; i++) {\n+\t\tif (!(postimage->line[i].flag & LINE_COMMON))\n+\t\t\tpostlen += postimage->line[i].len;\n+\t}\n+\n+\t/*\n \t * The preimage may extend beyond the end of the file,\n \t * but in this loop we will only handle the part of the\n \t * preimage that falls within the file.\n@@ -2343,7 +2360,6 @@ static int match_fragment(struct image *img,\n \tstrbuf_init(&fixed, preimage->len + 1);\n \torig = preimage->buf;\n \ttarget = img->buf + try;\n-\tpostlen = 0;\n \tfor (i = 0; i < preimage_limit; i++) {\n \t\tsize_t oldlen = preimage->line[i].len;\n \t\tsize_t tgtlen = img->line[try_lno + i].len;\n@@ -2371,7 +2387,10 @@ static int match_fragment(struct image *img,\n \t\tmatch = (tgtfix.len == fixed.len - fixstart &&\n \t\t\t !memcmp(tgtfix.buf, fixed.buf + fixstart,\n \t\t\t\t\t     fixed.len - fixstart));\n-\t\tpostlen += tgtfix.len;\n+\n+\t\t/* Add the length if this is common with the postimage */\n+\t\tif (preimage->line[i].flag & LINE_COMMON)\n+\t\t\tpostlen += tgtfix.len;\n \n \t\tstrbuf_release(&tgtfix);\n \t\tif (!match)\n-- \n2.3.0-rc1-116-g84c5016\n"},{"id":"255147","messageId":"1421967505-16879-5-git-send-email-gitster@pobox.com","threadId":"38362","inReplyTo":"1421967505-16879-1-git-send-email-gitster@pobox.com","subject":"[PATCH v2 4/4] apply: detect and mark whitespace errors in context lines when fixing","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-22T22:58:25Z","receivedAt":"2015-01-22T22:58:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When the incoming patch has whitespace errors in a common context\nline (i.e. a line that is expected to be found and is not modified\nby the patch), \"apply --whitespace=fix\" corrects the whitespace\nerrors the line has, in addition to the whitespace error on a line\nthat is updated by the patch.  However, we did not count and report\nthat we fixed whitespace errors on such lines.\n\n[jc: This is iffy.  What if the whitespace error has been fixed in\nthe target since the patch was written?  A common context line we\nsee in the patch has errors, and it matches a line in the target\nthat has the errors already corrected, resulting in no change, which\nwe may not want to count after all.  On the other hand, we are\nreporting whitespace errors _in_ the incoming patch, so...]\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n builtin/apply.c | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex e895340..a51a1b0 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -1606,6 +1606,9 @@ static int parse_fragment(const char *line, unsigned long size,\n \t\t\tif (!deleted && !added)\n \t\t\t\tleading++;\n \t\t\ttrailing++;\n+\t\t\tif (!apply_in_reverse &&\n+\t\t\t    ws_error_action == correct_ws_error)\n+\t\t\t\tcheck_whitespace(line, len, patch->ws_rule);\n \t\t\tbreak;\n \t\tcase '-':\n \t\t\tif (apply_in_reverse &&\n-- \n2.3.0-rc1-116-g84c5016\n"},{"id":"255154","messageId":"CAGZ79kYR7AcgTghwLoTejvaB=BRW+YxJdHZtjteXVbcrNqh8LQ@mail.gmail.com","threadId":"38362","inReplyTo":"1421967505-16879-2-git-send-email-gitster@pobox.com","subject":"Re: [PATCH v2 1/4] apply.c: typofix","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-01-22T23:17:42Z","receivedAt":"2015-01-22T23:17:42Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Jan 22, 2015 at 2:58 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  builtin/apply.c | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/builtin/apply.c b/builtin/apply.c\n> index 622ee16..31f8733 100644\n> --- a/builtin/apply.c\n> +++ b/builtin/apply.c\n> @@ -2326,7 +2326,7 @@ static int match_fragment(struct image *img,\n>\n>         /*\n>          * The hunk does not apply byte-by-byte, but the hash says\n> -        * it might with whitespace fuzz. We haven't been asked to\n> +        * it might with whitespace fuzz. We weren't asked to\n\n(not a native speaker):\nA quick websearch reveals \"We haven't been asked to ...\"\nis quite commonly used in the web. So it's more of a grammar fix or a\nrewording of a comment instead of a typofix(which I assume are miss\nspellings)\n\n>          * ignore whitespace, we were asked to correct whitespace\n>          * errors, so let's try matching after whitespace correction.\n>          *\n> --\n> 2.3.0-rc1-116-g84c5016\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"255156","messageId":"xmqqd266s7qa.fsf@gitster.dls.corp.google.com","threadId":"38362","inReplyTo":"CAGZ79kYR7AcgTghwLoTejvaB=BRW+YxJdHZtjteXVbcrNqh8LQ@mail.gmail.com","subject":"Re: [PATCH v2 1/4] apply.c: typofix","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-01-22T23:42:21Z","receivedAt":"2015-01-22T23:42:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n>> -        * it might with whitespace fuzz. We haven't been asked to\n>> +        * it might with whitespace fuzz. We weren't asked to\n>\n> (not a native speaker):\n> A quick websearch reveals \"We haven't been asked to ...\"\n> is quite commonly used in the web. So it's more of a grammar fix or a\n> rewording of a comment instead of a typofix(which I assume are miss\n> spellings)\n\nCorrect; it is not grammo or typo fix, but is a rephrasing to match\nthe tense with what follows (i.e. we weren't asked to ignore; we\nwere asked to fix).\n\n>\n>>          * ignore whitespace, we were asked to correct whitespace\n>>          * errors, so let's try matching after whitespace correction.\n>>          *\n>> --\n>> 2.3.0-rc1-116-g84c5016\n>>\n>> --\n>> To unsubscribe from this list: send the line \"unsubscribe git\" in\n>> the body of a message to majordomo@vger.kernel.org\n>> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"255157","messageId":"CAGZ79kYpaDs10J8WxdWwW1ojeeddQ+squUXYg1yuYVxOhzK__w@mail.gmail.com","threadId":"38362","inReplyTo":"xmqqd266s7qa.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH v2 1/4] apply.c: typofix","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-01-22T23:48:30Z","receivedAt":"2015-01-22T23:48:30Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Thu, Jan 22, 2015 at 3:42 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>>> -        * it might with whitespace fuzz. We haven't been asked to\n>>> +        * it might with whitespace fuzz. We weren't asked to\n>>\n>> (not a native speaker):\n>> A quick websearch reveals \"We haven't been asked to ...\"\n>> is quite commonly used in the web. So it's more of a grammar fix or a\n>> rewording of a comment instead of a typofix(which I assume are miss\n>> spellings)\n>\n> Correct; it is not grammo or typo fix, but is a rephrasing to match\n> the tense with what follows (i.e. we weren't asked to ignore; we\n> were asked to fix).\n>\n\nOk, I realized I missed my conclusion in the first mail: The commit message\nand what the patch actually does, do not match.\n"},{"id":"255158","messageId":"7D660CE3-AC55-4A0A-B5D9-D76853F6817C@gmail.com","threadId":"38362","inReplyTo":"xmqq7fwetya3.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] test: add git apply whitespace expansion tests","fromName":"Kyle J. McKay","fromEmail":"mackyle@gmail.com","sentAt":"2015-01-23T00:12:48Z","receivedAt":"2015-01-23T00:12:48Z","isPatch":true,"sender":{"key":"mackyle@gmail.com","avatar":"https://avatars.githubusercontent.com/u/813346?v=4"},"body":"On Jan 22, 2015, at 11:23, Junio C Hamano wrote:\n> \"Kyle J. McKay\" <mackyle@gmail.com> writes:\n>\n>> On Jan 21, 2015, at 14:33, Junio C Hamano wrote:\n>>\n>>> \"Kyle J. McKay\" <mackyle@gmail.com> writes:\n>>>\n>>>> So since I've not been able to get test 2 or 3 to core dump (even\n>>>> before 250b3c6c) I tend to believe you are correct in that the code\n>>>> thinks (incorrectly) that the result should fit within the buffer.\n>>>\n>>> Thanks; let me steal your tests when I reroll.\n>>\n>> Awesome. :)\n>>\n>> But please squash in this tiny change if using the tests verbatim:\n>\n> Thanks.  I actually have a question wrt the need for $MAKE_PATCHES.\n>\n> It would have been more natural to do something like:\n>\n> test_expect_success 'setup' '\n> \tprintf \"\\t%s\\n\" 1 2 3 4 5 6 >before &&\n> \tprintf \"\\t%s\\n\" 1 2 3 >after &&\n> \tprintf \"%64s\\n\" a b c >>after &&\n> \tprintf \"\\t%s\\n\" 4 5 6 >>after &&\n> \tgit diff --no-index before after |\n> \tsed -e \"s/before/test-1/\" -e \"s/after/test-1/\" >patch1.patch &&\n> \tprintf \"%64s\\n\" 1 2 3 4 5 6 >test-1 &&\n> \tprintf \"%64s\\n\" 1 2 3 a b c 4 5 6 >expect-1 &&\n>\n> \tprintf \"\\t%s\\n\" a b c d e f >before &&\n> \tprintf \"\\t%s\\n\" a b c >after &&\n>        ...\n> \tcat test-4 >expect-4 &&\n> \tprintf \"%64s\\n\" a b c >>expect-4 &&\n> \twhile test $x -lt 100\n> \tdo\n> \t\tprintf \"%63s%02d\\n\" \"\" $x >>test-4\n> \t\tprintf \"%63s%02d\\n\" \"\" $x >>expect-4\n> \t\tx=$(( $x + 1 ))\n> \tdone &&\n>\n> \tgit config core.whitespace tab-in-indent,tabwidth=63 &&\n>        git config apply.whitespace fix\n> '\n>\n> test_expect_success 'apply with ws expansion (1)' '\n> \tgit apply patch1.patch &&\n>        test_cmp test-1 expect-1\n> '\n>\n> and if you want test files you can just skip tests #2 and later,\n> without introducing an ad-hoc mechanism like you did.\n>\n> Was there something more than that that you wanted from\n> $MAKE_PATCHES?\n\nWell, see I found t/t4135/make-patches that makes patches for use by  \nt4135-apply-weird-filenames.sh and thought perhaps that was the  \napproved way to do things.\n\nBut then it seemed overkill since making the patches takes so little  \ntime it didn't seem to warrant a separate directory.  But the ability  \nto just make the patch files without requiring any external scripts or  \ntest framework seemed nice so I added those two extra lines to make it  \npossible.\n\nI don't have any strong feelings about it.  The setup test plus 4  \nexplicit tests looks fine.\n\n> In any case, here is an update to that sanity check patch to catch\n> the two cases the BUG did not trigger.\n>\n> Sometimes the caller under-counted the size of the result but\n> thought that it would still fit within the original (hence allowing\n> us to update in-place by passing postlen==0) but the actual result\n> was larger than the space we have allocated in the postimage,\n> clobbering the piece of memory after the postimage->buf.\n>\n>\n> diff --git a/builtin/apply.c b/builtin/apply.c\n> index 31f8733..3b7ba63 100644\n> --- a/builtin/apply.c\n> +++ b/builtin/apply.c\n> @@ -2171,6 +2171,12 @@ static void update_pre_post_images(struct  \n> image *preimage,\n> \t\tctx++;\n> \t}\n>\n> +\tif (postlen\n> +\t    ? postlen < new - postimage->buf\n> +\t    : postimage->len < new - postimage->buf)\n> +\t\tdie(\"BUG: caller miscounted postlen: asked %d, orig = %d, used =  \n> %d\",\n> +\t\t    (int)postlen, (int) postimage->len, (int)(new - postimage- \n> >buf));\n> +\n> \t/* Fix the length of the whole thing */\n> \tpostimage->len = new - postimage->buf;\n> \tpostimage->nr -= reduced;\n\nNice.  No more of those bogus results can slip through that somehow  \nevade evoking a core dump.\n\n-Kyle\n"}]}