[Toybox] Valgrind errors with toybox bc

Sasha Toltec sashatoltec1 at gmail.com
Mon Aug 27 23:45:17 PDT 2018


Here are the valgrind errors that were requested.

The problem seems to be that if you don't understand what types of
numbers put stress on a bignum library, then it is
difficult/impossible to force the memory errors.

If one of the senior programmers involved with toybox has time to take
a look at the bc bignum library and suggest some fixes and reading
material to its authors that would perhaps be the best course of
action. Toltec Enterprises generally charges for consultation ergo
cannot offer much more input.


sasha at sasha:~/toybox$ uname -a
Linux sasha 4.4.0-103-generic #126-Ubuntu SMP Mon Dec 4 16:23:28 UTC
2017 x86_64 x86_64 x86_64 GNU/Linux
sasha at sasha:~/toybox$ make bc
sasha at sasha:~/toybox$ echo "sqrt(.0000000000123)" | valgrind ./bc
==10636== Memcheck, a memory error detector
==10636== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==10636== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==10636== Command: ./bc -l
==10636==
==10636== Invalid read of size 1
==10636==    at 0x402D68: ??? (in /home/sasha/toybox/bc)
==10636==    by 0x403C3B: ??? (in /home/sasha/toybox/bc)
==10636==    by 0xFFEFFF84F: ???
==10636==    by 0x15: ???
==10636==    by 0x5945C9F: ???
==10636==    by 0x15: ???
==10636==    by 0x16: ???
==10636==    by 0x23: ???
==10636==  Address 0x5945aef is 1 bytes before a block of size 55 alloc'd
==10636==    at 0x4C2DB8F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10636==    by 0x402FFB: ??? (in /home/sasha/toybox/bc)
==10636==
==10636== Invalid read of size 1
==10636==    at 0x402D68: ??? (in /home/sasha/toybox/bc)
==10636==    by 0x402E5A: ??? (in /home/sasha/toybox/bc)
==10636==    by 0xFFEFFF977: ???
==10636==    by 0x403727: ??? (in /home/sasha/toybox/bc)
==10636==    by 0x4036B7: ??? (in /home/sasha/toybox/bc)
==10636==    by 0xFFEFFF977: ???
==10636==    by 0xFFEFFF84F: ???
==10636==    by 0x5938397: ???
==10636==    by 0xFFEFFF977: ???
==10636==    by 0x5938397: ???
==10636==    by 0x4036B7: ??? (in /home/sasha/toybox/bc)
==10636==    by 0x403142: ??? (in /home/sasha/toybox/bc)
==10636==  Address 0x59458ef is 1 bytes before a block of size 16 alloc'd
==10636==    at 0x4C2DB8F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10636==    by 0x402FFB: ??? (in /home/sasha/toybox/bc)
==10636==    by 0xE: ???
==10636==    by 0xFFEFFFCC7: ???
==10636==    by 0xFFEFFFA2F: ???
==10636==    by 0x405561: ??? (in /home/sasha/toybox/bc)
==10636==    by 0xFFEFFFBC7: ???
==10636==    by 0xD: ???
==10636==
==10636== Invalid read of size 1
==10636==    at 0x402D68: ??? (in /home/sasha/toybox/bc)
==10636==  Address 0x594633f is 1 bytes before a block of size 45 alloc'd
==10636==    at 0x4C2FD5F: realloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10636==    by 0x403030: ??? (in /home/sasha/toybox/bc)
==10636==    by 0xFFEFFF927: ???
==10636==    by 0xFFEFFF8FF: ???
==10636==    by 0xFFEFFF977: ???
==10636==    by 0x403181: ??? (in /home/sasha/toybox/bc)
==10636==    by 0x4048AF7: ???
==10636==
==10636== Invalid read of size 1
==10636==    at 0x402D6B: ??? (in /home/sasha/toybox/bc)
==10636==  Address 0x594601f is 1 bytes before a block of size 45 alloc'd
==10636==    at 0x4C2FD5F: realloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10636==    by 0x403030: ??? (in /home/sasha/toybox/bc)
==10636==    by 0xFFEFFF8FF: ???
==10636==    by 0xFFEFFF927: ???
==10636==    by 0xFFEFFF977: ???
==10636==    by 0x403181: ??? (in /home/sasha/toybox/bc)
==10636==    by 0x4048AF7: ???
==10636==
.00000350713558335195
==10636==
==10636== HEAP SUMMARY:
==10636==     in use at exit: 1,768 bytes in 15 blocks
==10636==   total heap usage: 588 allocs, 573 frees, 53,516 bytes allocated
==10636==
==10636== LEAK SUMMARY:
==10636==    definitely lost: 1,216 bytes in 5 blocks
==10636==    indirectly lost: 528 bytes in 9 blocks
==10636==      possibly lost: 0 bytes in 0 blocks
==10636==    still reachable: 24 bytes in 1 blocks
==10636==         suppressed: 0 bytes in 0 blocks
==10636== Rerun with --leak-check=full to see details of leaked memory
==10636==
==10636== For counts of detected and suppressed errors, rerun with: -v
==10636== ERROR SUMMARY: 7 errors from 4 contexts (suppressed: 0 from 0)

Sasha Toltec
Toltec Enterprises
sashatoltect1 at gmail.com


More information about the Toybox mailing list