[PATCH] xdiff: fix a hard crash on Windows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] xdiff: fix a hard crash on Windows

Matt Harbison-2
# HG changeset patch
# User Matt Harbison <[hidden email]>
# Date 1520905818 14400
#      Mon Mar 12 21:50:18 2018 -0400
# Node ID 60bb2f7dd9ba313f96374470e8419bf1a20454a1
# Parent  aed445748c7885482cd90e56e81f57a13d4ac95c
xdiff: fix a hard crash on Windows

The xdiff case of test-diff-antipatience.t started crashing in the C extension
with 882657a9f768 (with 6a71a5ba666b backported so it compiles).  There are a
few more instances of 'long', but this resolves the crashing.

diff --git a/mercurial/thirdparty/xdiff/xdiffi.c b/mercurial/thirdparty/xdiff/xdiffi.c
--- a/mercurial/thirdparty/xdiff/xdiffi.c
+++ b/mercurial/thirdparty/xdiff/xdiffi.c
@@ -342,7 +342,7 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t
  * One is to store the forward path and one to store the backward path.
  */
  ndiags = xe->xdf1.nreff + xe->xdf2.nreff + 3;
- if (!(kvd = (int64_t *) xdl_malloc((2 * ndiags + 2) * sizeof(long)))) {
+ if (!(kvd = (int64_t *) xdl_malloc((2 * ndiags + 2) * sizeof(int64_t)))) {
 
  xdl_free_env(xe);
  return -1;
diff --git a/mercurial/thirdparty/xdiff/xprepare.c b/mercurial/thirdparty/xdiff/xprepare.c
--- a/mercurial/thirdparty/xdiff/xprepare.c
+++ b/mercurial/thirdparty/xdiff/xprepare.c
@@ -296,9 +296,9 @@ static int xdl_prepare_ctx(unsigned int
  goto abort;
  memset(rchg, 0, (nrec + 2) * sizeof(char));
 
- if (!(rindex = (int64_t *) xdl_malloc((nrec + 1) * sizeof(long))))
+ if (!(rindex = (int64_t *) xdl_malloc((nrec + 1) * sizeof(int64_t))))
  goto abort;
- if (!(ha = (uint64_t *) xdl_malloc((nrec + 1) * sizeof(unsigned long))))
+ if (!(ha = (uint64_t *) xdl_malloc((nrec + 1) * sizeof(uint64_t))))
  goto abort;
 
  xdf->nrec = nrec;
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] xdiff: fix a hard crash on Windows

Jun Wu
Looks good. Thanks for fixing this!

Excerpts from Matt Harbison's message of 2018-03-12 21:53:12 -0400:

> # HG changeset patch
> # User Matt Harbison <[hidden email]>
> # Date 1520905818 14400
> #      Mon Mar 12 21:50:18 2018 -0400
> # Node ID 60bb2f7dd9ba313f96374470e8419bf1a20454a1
> # Parent  aed445748c7885482cd90e56e81f57a13d4ac95c
> xdiff: fix a hard crash on Windows
>
> The xdiff case of test-diff-antipatience.t started crashing in the C extension
> with 882657a9f768 (with 6a71a5ba666b backported so it compiles).  There are a
> few more instances of 'long', but this resolves the crashing.
>
> diff --git a/mercurial/thirdparty/xdiff/xdiffi.c b/mercurial/thirdparty/xdiff/xdiffi.c
> --- a/mercurial/thirdparty/xdiff/xdiffi.c
> +++ b/mercurial/thirdparty/xdiff/xdiffi.c
> @@ -342,7 +342,7 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t
>       * One is to store the forward path and one to store the backward path.
>       */
>      ndiags = xe->xdf1.nreff + xe->xdf2.nreff + 3;
> -    if (!(kvd = (int64_t *) xdl_malloc((2 * ndiags + 2) * sizeof(long)))) {
> +    if (!(kvd = (int64_t *) xdl_malloc((2 * ndiags + 2) * sizeof(int64_t)))) {
>  
>          xdl_free_env(xe);
>          return -1;
> diff --git a/mercurial/thirdparty/xdiff/xprepare.c b/mercurial/thirdparty/xdiff/xprepare.c
> --- a/mercurial/thirdparty/xdiff/xprepare.c
> +++ b/mercurial/thirdparty/xdiff/xprepare.c
> @@ -296,9 +296,9 @@ static int xdl_prepare_ctx(unsigned int
>          goto abort;
>      memset(rchg, 0, (nrec + 2) * sizeof(char));
>  
> -    if (!(rindex = (int64_t *) xdl_malloc((nrec + 1) * sizeof(long))))
> +    if (!(rindex = (int64_t *) xdl_malloc((nrec + 1) * sizeof(int64_t))))
>          goto abort;
> -    if (!(ha = (uint64_t *) xdl_malloc((nrec + 1) * sizeof(unsigned long))))
> +    if (!(ha = (uint64_t *) xdl_malloc((nrec + 1) * sizeof(uint64_t))))
>          goto abort;
>  
>      xdf->nrec = nrec;
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] xdiff: fix a hard crash on Windows

Matt Harbison-2
On Mon, 12 Mar 2018 21:55:26 -0400, Jun Wu <[hidden email]> wrote:

> Looks good. Thanks for fixing this!

Do you think it's worth changing the few other instances of long over to  
uint64?  If nothing else, it will be unconditionally 64 bit ops.  But I'm  
not sure what else you have pending.  (I think I saw you mention the  
hashing specifically, which looks like a lot of the rest of these.)

> Excerpts from Matt Harbison's message of 2018-03-12 21:53:12 -0400:
>> # HG changeset patch
>> # User Matt Harbison <[hidden email]>
>> # Date 1520905818 14400
>> #      Mon Mar 12 21:50:18 2018 -0400
>> # Node ID 60bb2f7dd9ba313f96374470e8419bf1a20454a1
>> # Parent  aed445748c7885482cd90e56e81f57a13d4ac95c
>> xdiff: fix a hard crash on Windows
>>
>> The xdiff case of test-diff-antipatience.t started crashing in the C  
>> extension
>> with 882657a9f768 (with 6a71a5ba666b backported so it compiles).  There  
>> are a
>> few more instances of 'long', but this resolves the crashing.
>>
>> diff --git a/mercurial/thirdparty/xdiff/xdiffi.c  
>> b/mercurial/thirdparty/xdiff/xdiffi.c
>> --- a/mercurial/thirdparty/xdiff/xdiffi.c
>> +++ b/mercurial/thirdparty/xdiff/xdiffi.c
>> @@ -342,7 +342,7 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t
>>       * One is to store the forward path and one to store the backward  
>> path.
>>       */
>>      ndiags = xe->xdf1.nreff + xe->xdf2.nreff + 3;
>> -    if (!(kvd = (int64_t *) xdl_malloc((2 * ndiags + 2) *  
>> sizeof(long)))) {
>> +    if (!(kvd = (int64_t *) xdl_malloc((2 * ndiags + 2) *  
>> sizeof(int64_t)))) {
>>
>>          xdl_free_env(xe);
>>          return -1;
>> diff --git a/mercurial/thirdparty/xdiff/xprepare.c  
>> b/mercurial/thirdparty/xdiff/xprepare.c
>> --- a/mercurial/thirdparty/xdiff/xprepare.c
>> +++ b/mercurial/thirdparty/xdiff/xprepare.c
>> @@ -296,9 +296,9 @@ static int xdl_prepare_ctx(unsigned int
>>          goto abort;
>>      memset(rchg, 0, (nrec + 2) * sizeof(char));
>>
>> -    if (!(rindex = (int64_t *) xdl_malloc((nrec + 1) * sizeof(long))))
>> +    if (!(rindex = (int64_t *) xdl_malloc((nrec + 1) *  
>> sizeof(int64_t))))
>>          goto abort;
>> -    if (!(ha = (uint64_t *) xdl_malloc((nrec + 1) * sizeof(unsigned  
>> long))))
>> +    if (!(ha = (uint64_t *) xdl_malloc((nrec + 1) * sizeof(uint64_t))))
>>          goto abort;
>>
>>      xdf->nrec = nrec;
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] xdiff: fix a hard crash on Windows

Yuya Nishihara
In reply to this post by Jun Wu
On Mon, 12 Mar 2018 18:55:26 -0700, Jun Wu wrote:

> Looks good. Thanks for fixing this!
>
> Excerpts from Matt Harbison's message of 2018-03-12 21:53:12 -0400:
> > # HG changeset patch
> > # User Matt Harbison <[hidden email]>
> > # Date 1520905818 14400
> > #      Mon Mar 12 21:50:18 2018 -0400
> > # Node ID 60bb2f7dd9ba313f96374470e8419bf1a20454a1
> > # Parent  aed445748c7885482cd90e56e81f57a13d4ac95c
> > xdiff: fix a hard crash on Windows

Queued, thanks.
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel