simon-git: spigot (master): spigot.git
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Sat Nov 5 14:18:15 GMT 2016
TL;DR:
c1a9a5d baseout: uninitialised variable in special-case formatter.
85764ad Rework powbegin.py to remove the exactness hazards.
c9927af test.sh: add a --valgrind option.
640e198 Fix an uninitialised variable in PrintfFormatter.
b49398f Fix a new/malloc mismatch in bigint_decstring.
Repository: https://git.tartarus.org/simon/spigot.git
On the web: https://git.tartarus.org/?p=simon/spigot.git
Branch updated: master
Committer: spigot.git
Date: 2016-11-05 14:18:15
commit c1a9a5dc02d13814b07d932e018979074f10107e
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=c1a9a5dc02d13814b07d932e018979074f10107e;hp=f44a66ffbf4415468bb2ca46f072e80c29c46c7d
Author: Simon Tatham <anakin at pobox.com>
Date: Sat Nov 5 08:21:28 2016 +0000
baseout: uninitialised variable in special-case formatter.
Thanks, valgrind.
baseout.cpp | 1 +
1 file changed, 1 insertion(+)
commit 85764adf1180dd3723a21236384f4d869dea55c1
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=85764adf1180dd3723a21236384f4d869dea55c1;hp=c1a9a5dc02d13814b07d932e018979074f10107e
Author: Simon Tatham <anakin at pobox.com>
Date: Sat Nov 5 12:15:35 2016 +0000
Rework powbegin.py to remove the exactness hazards.
I *think* I've caught all of them - and I've added a largish soak-test
suite to try to prove it, and a small list of directed tests into
which I can drop any further hangs that might come to my attention
later on.
I had to fix a lot of separate instances of similar bugs, which I
won't describe all of in detail here. But general techniques included:
- use of the new dyadic log in the spigot core, of course. That was
what inspired this sudden bout of bug-fixing in powbegin - I now
had an extra tool that I thought might make the problem tractable.
- a subroutine to compute floor(x) clamped to within some bounded
range, so that if the input were to evaluate to an exact integer
_outside_ that range then we could find that out in time to avoid
an exactness hazard. On several occasions I also use this to avoid
an exactness hazard _inside_ the range of answers I need to
distinguish, by breaking up the evaluation into two sub-ranges
above and below the known-dangerous value.
- some number theory to identify when a power of a is exactly equal
to b *up to powers of base*. The 'Euclid's Logarithm' technique I
use in the spigot core can tell me if b = a^i for some i, but not
if b = a^i 10^j (for arbitrary values of 10) - and you need to
answer problems of that type that in order to know (for example)
whether any power of 0xC starts with 0x3CC in hex.
Perhaps one disadvantage of this reworked version is that the program
is now considerably more complicated and makes less straightforward
_example code_ using the spigot Python bindings. But I think that's OK
- pythangle is perfectly good as a simple demo program, and this one
constitutes tips on how to do something fiendishly complicated!
python/powbegin.py | 496 +++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 448 insertions(+), 48 deletions(-)
commit c9927af85cd8be530c9b3e876e3dc5d4cc76f820
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=c9927af85cd8be530c9b3e876e3dc5d4cc76f820;hp=85764adf1180dd3723a21236384f4d869dea55c1
Author: Simon Tatham <anakin at pobox.com>
Date: Sat Nov 5 13:23:53 2016 +0000
test.sh: add a --valgrind option.
Having spotted that one valgrind-detectable error in the course of
debugging powbegin.py, I thought it would be worth running the whole
spigot test suite under valgrind to see what else it turned up.
Since test.sh hides the output of each run of spigot, this isn't
completely trivial - I have to arrange an fd pointing at a log file,
and give valgrind the option to output to that fd. So it's worth
making it a special --valgrind option, rather than just setting the
program under test to 'valgrind spigot' instead of 'spigot'.
This commit also adds the start of a reasonably general option-parsing
system in general, just so it gives me a handy place to drop any
further arguments later on.
test.sh | 42 ++++++++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
commit 640e19828690e56f610c44c85b085d4cc744941a
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=640e19828690e56f610c44c85b085d4cc744941a;hp=c9927af85cd8be530c9b3e876e3dc5d4cc76f820
Author: Simon Tatham <anakin at pobox.com>
Date: Sat Nov 5 13:24:23 2016 +0000
Fix an uninitialised variable in PrintfFormatter.
Spotted by running test.sh with the new valgrind option.
baseout.cpp | 5 +++++
1 file changed, 5 insertions(+)
commit b49398f50a47c72487012c889cdcb6b14233f5e3
web diff https://git.tartarus.org/?p=simon/spigot.git;a=commitdiff;h=b49398f50a47c72487012c889cdcb6b14233f5e3;hp=640e19828690e56f610c44c85b085d4cc744941a
Author: Simon Tatham <anakin at pobox.com>
Date: Sat Nov 5 13:24:31 2016 +0000
Fix a new/malloc mismatch in bigint_decstring.
Spotted by valgrind: between bi_gmp.h and bi_internal.h, there was
inconsistency about whether the dynamically allocated strings returned
from bigint_decstring and bigint_hexstring had been allocated by
malloc or by new char[], and hence whether they should be freed by
free() or delete[].
Since not all the allocations are under my control (bi_gmp.h does them
inside GMP), it was easiest to standardise on malloc, which seems to
be how GMP does it. So now both implementations of both functions
should consistently return a malloced rather than new()ed string, and
every call site should free() rather than delete[] the result.
bi_internal.h | 6 ++++--
cfracout.cpp | 12 ++++++------
2 files changed, 10 insertions(+), 8 deletions(-)
More information about the tartarus-commits
mailing list