<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/libgit2.git/src/integer.h, branch ethomson/links</title>
<subtitle>github.com: libgit2/libgit2.git
</subtitle>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/'/>
<entry>
<title>Add tests for `git__multiply_int64_overflow`</title>
<updated>2020-12-19T18:23:15+00:00</updated>
<author>
<name>lhchavez</name>
<email>lhchavez@lhchavez.com</email>
</author>
<published>2020-12-19T17:30:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=5ab0736bef1a2e9ed15d6f5edbc81393bb7b63cf'/>
<id>5ab0736bef1a2e9ed15d6f5edbc81393bb7b63cf</id>
<content type='text'>
As it turns out, the implementation of `git__multiply_int64_overflow` is
full of edge cases and tricky arithmetic. That means that it should have
unit tests.

As a result, a bug in `git__strntol64` was found (and fixed!) in
clang+32-bit.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As it turns out, the implementation of `git__multiply_int64_overflow` is
full of edge cases and tricky arithmetic. That means that it should have
unit tests.

As a result, a bug in `git__strntol64` was found (and fixed!) in
clang+32-bit.
</pre>
</div>
</content>
</entry>
<entry>
<title>Third attempt to fix the 32-bit version of `git__multiply_int64_overflow`</title>
<updated>2020-12-19T03:44:26+00:00</updated>
<author>
<name>lhchavez</name>
<email>lhchavez@lhchavez.com</email>
</author>
<published>2020-12-19T03:43:13+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=e9b98cd53089077cb3c547b6f3870c51e3b128cc'/>
<id>e9b98cd53089077cb3c547b6f3870c51e3b128cc</id>
<content type='text'>
This change should now fix the issue for realsies.

`./libgit2_clar -score::strtol` passes on a 32-bit Docker.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change should now fix the issue for realsies.

`./libgit2_clar -score::strtol` passes on a 32-bit Docker.
</pre>
</div>
</content>
</entry>
<entry>
<title>Avoid using `__builtin_mul_overflow` with the clang+32-bit combo</title>
<updated>2020-12-18T15:07:56+00:00</updated>
<author>
<name>lhchavez</name>
<email>lhchavez@lhchavez.com</email>
</author>
<published>2020-12-18T15:03:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=7f8ae01913e408bf219ab41036bd68265596c917'/>
<id>7f8ae01913e408bf219ab41036bd68265596c917</id>
<content type='text'>
This causes clang to produce an undefined reference to `__mulodi4`. This
could be fixed by statically linking some compiler-rt libraries to
provide this symbol, but let's first stop the bleeding since doing the
correct long-term fix requires some non-trivial CMake knowledge which I
lack.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This causes clang to produce an undefined reference to `__mulodi4`. This
could be fixed by statically linking some compiler-rt libraries to
provide this symbol, but let's first stop the bleeding since doing the
correct long-term fix requires some non-trivial CMake knowledge which I
lack.
</pre>
</div>
</content>
</entry>
<entry>
<title>Make git__strntol64() ~70%* faster</title>
<updated>2020-12-13T01:50:58+00:00</updated>
<author>
<name>lhchavez</name>
<email>lhchavez@lhchavez.com</email>
</author>
<published>2020-12-13T00:51:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=e99e833f4808e027de8e984b9b99544ca41e28e2'/>
<id>e99e833f4808e027de8e984b9b99544ca41e28e2</id>
<content type='text'>
This change uses compiler intrinsics to detect overflows instead of
using divisions to detect potential overflow. This makes the code faster
and makes it easier to read as a bonus side-effect!

Some of the things this quickens:

* Config parsing.
* Tree parsing.
* Smart protocol negotiation.

\* Measured by running `libgit2_clar` with `-fno-optimize-sibling-calls
-fno-omit-frame-pointer` under `perf(1)`:

```shell
$ perf diff --symbols=git__strntol64 --compute=ratio \
  --percentage=absolute baseline.data perf.data
\# Event 'cycles'
\#
\# Baseline           Ratio  Shared Object
\# ........  ..............  .............
\#
     0.25%        0.321836  libgit2_clar
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This change uses compiler intrinsics to detect overflows instead of
using divisions to detect potential overflow. This makes the code faster
and makes it easier to read as a bonus side-effect!

Some of the things this quickens:

* Config parsing.
* Tree parsing.
* Smart protocol negotiation.

\* Measured by running `libgit2_clar` with `-fno-optimize-sibling-calls
-fno-omit-frame-pointer` under `perf(1)`:

```shell
$ perf diff --symbols=git__strntol64 --compute=ratio \
  --percentage=absolute baseline.data perf.data
\# Event 'cycles'
\#
\# Baseline           Ratio  Shared Object
\# ........  ..............  .............
\#
     0.25%        0.321836  libgit2_clar
```
</pre>
</div>
</content>
</entry>
<entry>
<title>integer: use int64_t's for checks</title>
<updated>2019-11-25T02:18:29+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2019-06-23T16:20:17+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=05237ee559486ae4416f3d12e4a422bd9183f7ea'/>
<id>05237ee559486ae4416f3d12e4a422bd9183f7ea</id>
<content type='text'>
Use int64_t internally for type visibility.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use int64_t internally for type visibility.
</pre>
</div>
</content>
</entry>
<entry>
<title>patch_parse: detect overflow when calculating old/new line position</title>
<updated>2019-10-21T18:07:42+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2019-10-21T16:56:59+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=37141ff7701e45ab0d97f311a4e0cc95cf527aa9'/>
<id>37141ff7701e45ab0d97f311a4e0cc95cf527aa9</id>
<content type='text'>
When the patch contains lines close to INT_MAX, then it may happen that
we end up with an integer overflow when calculating the line of the
current diff hunk. Reject such patches as unreasonable to avoid the
integer overflow.

As the calculation is performed on integers, we introduce two new
helpers `git__add_int_overflow` and `git__sub_int_overflow` that perform
the integer overflow check in a generic way.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When the patch contains lines close to INT_MAX, then it may happen that
we end up with an integer overflow when calculating the line of the
current diff hunk. Reject such patches as unreasonable to avoid the
integer overflow.

As the calculation is performed on integers, we introduce two new
helpers `git__add_int_overflow` and `git__sub_int_overflow` that perform
the integer overflow check in a generic way.
</pre>
</div>
</content>
</entry>
<entry>
<title>commit_list: store in/out-degrees as uint16_t</title>
<updated>2019-10-03T10:23:52+00:00</updated>
<author>
<name>Patrick Steinhardt</name>
<email>ps@pks.im</email>
</author>
<published>2019-10-03T07:39:42+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=5cf17e0f269387f8345201aef482a10c96490d95'/>
<id>5cf17e0f269387f8345201aef482a10c96490d95</id>
<content type='text'>
The commit list's in- and out-degrees are currently stored as `unsigned
short`. When assigning it the value of `git_array_size`, which returns
an `size_t`, this generates a warning on some Win32 platforms due to
loosing precision.

We could just cast the returned value of `git_array_size`, which would
work fine for 99.99% of all cases as commits typically have less than
2^16 parents. For crafted commits though we might end up with a wrong
value, and thus we should definitely check whether the array size
actually fits into the field.

To ease the check, let's convert the fields to store the degrees as
`uint16_t`. We shouldn't rely on such unspecific types anyway, as it may
lead to different behaviour across platforms. Furthermore, this commit
introduces a new `git__is_uint16` function to check whether it actually
fits -- if not, we return an error.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The commit list's in- and out-degrees are currently stored as `unsigned
short`. When assigning it the value of `git_array_size`, which returns
an `size_t`, this generates a warning on some Win32 platforms due to
loosing precision.

We could just cast the returned value of `git_array_size`, which would
work fine for 99.99% of all cases as commits typically have less than
2^16 parents. For crafted commits though we might end up with a wrong
value, and thus we should definitely check whether the array size
actually fits into the field.

To ease the check, let's convert the fields to store the degrees as
`uint16_t`. We shouldn't rely on such unspecific types anyway, as it may
lead to different behaviour across platforms. Furthermore, this commit
introduces a new `git__is_uint16` function to check whether it actually
fits -- if not, we return an error.
</pre>
</div>
</content>
</entry>
<entry>
<title>add with overflow: correct documentation</title>
<updated>2019-01-20T13:52:46+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2019-01-20T13:52:46+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=75444d97fd5bc13be922714f2977a483c5303286'/>
<id>75444d97fd5bc13be922714f2977a483c5303286</id>
<content type='text'>
Correct the documentation on the fallback add/multiply with overflow
functions.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Correct the documentation on the fallback add/multiply with overflow
functions.
</pre>
</div>
</content>
</entry>
<entry>
<title>add with overflow: use SizeTAdd on Windows</title>
<updated>2019-01-20T13:51:15+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2019-01-20T13:51:15+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=abbc07f12fdf1444c8aa0c161f3dfa8a494b7dff'/>
<id>abbc07f12fdf1444c8aa0c161f3dfa8a494b7dff</id>
<content type='text'>
Windows provides &lt;intsafe.h&gt; which provides "performant" add and
multiply with overflow operations.  Use them when possible.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Windows provides &lt;intsafe.h&gt; which provides "performant" add and
multiply with overflow operations.  Use them when possible.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove unused git__add_uint64_overflow</title>
<updated>2019-01-20T13:04:10+00:00</updated>
<author>
<name>Edward Thomson</name>
<email>ethomson@edwardthomson.com</email>
</author>
<published>2019-01-20T13:04:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.baserock.org/cgit/delta/libgit2.git/commit/?id=c6d47acfbfd514a12ac9fb14c87a247da7bfbf1d'/>
<id>c6d47acfbfd514a12ac9fb14c87a247da7bfbf1d</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
