Skip to content

Issue #449 - Fix a memory leak in pretty, and also#450

Merged
yoavnir merged 1 commit into
dev-1.0.0from
dev-1.0.0-issue449
Jun 23, 2026
Merged

Issue #449 - Fix a memory leak in pretty, and also#450
yoavnir merged 1 commit into
dev-1.0.0from
dev-1.0.0-issue449

Conversation

@yoavnir

@yoavnir yoavnir commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Fix unit tests (ALUUnitTest and ProcessingTest) so that all tests pass when run one-by-one.

Also, fix valgrind_unit_test so that the only acceptable failures are those caused by valgrind issue with long double.

Fix unit tests (ALUUnitTest and ProcessingTest) so that all
tests pass when run one-by-one. Also, fix valgrind_unit_test
so that the only acceptable failures are those caused by valgrind
issue with long double.
@yoavnir yoavnir added this to the 1.0.0 milestone Jun 22, 2026
@yoavnir

yoavnir commented Jun 23, 2026

Copy link
Copy Markdown
Owner Author

Trying to prove that all unit tests pass when run one-by-one with Valgrind, except those affected by Valgrind's well-documented issue with long double computations:

$ python3.12 setup.py -v PROF
Platform=POSIX; Compiler=GCC; Variation=PROF; Cached Dependencies=False
Testing compiler exists...Yes.
Getting compiler version...9.2.1
Testing C++17 support.....Yes.
Testing linkage without the -lstdc++fs flag....Success
Figuring out code version...Found git branch <dev-1.0.0-issue449>...Yes, going with that.
Testing std::put_time()...Supported.
Testing std::regex_search()...Compiled...Supported
Testing Spanish locale (for unit tests)...Compiled...Supported
Testing German locale (for unit tests)...Compiled...Uses thousands separator in German locale
Testing if the CommonCrypto library is available...No.
Testing if the wincrypt library is available...No.
Testing if the rand48 extension to stdlib is available...Yes.
Testing if Python support is available...Yes - found version 3.12.1.
Setting SPECS_BUILD_COMMIT to "37eb6ec"
Setting SPECS_BUILD_BRANCH to "dev-1.0.0-issue449"
Setting SPECS_BUILD_SOURCE to "local"
Setting SPECS_BUILD_NUMBER to ""
Setting SPECS_BUILD_RUNID to ""
Setting SPECS_BUILD_URL to ""
Setting SPECS_BUILD_TIME to "2026-06-23T10:06:48"
Generated utils/build_info.h
Makefile created.

Then I ran make clean all, and then:

$ python3.12 ../tests/valgrind_unit_tests.py | grep -v "no leaks"
Test #009: #3==3.14159265: *** NOT OK *** (Got 3.14159265000000021)
Test #043: uPlus(Float) is "98.6": *** NOT OK *** (98.5999999999999943)
Test #048: uMinus(Float) is "-98.6": *** NOT OK *** (-98.5999999999999943)
Test #061: uAdd(Float) is "90.6": *** NOT OK *** (90.5999999999999943)
Test #062: uAdd(Float) is "3.14159265": *** NOT OK *** (3.14159265000000021)
Test #063: uAdd(Float) is "68.14159265": *** NOT OK *** (68.1415926500000069)
Test #068: uSub(Float) is "61.85840735": *** NOT OK *** (61.8584073500000002)
Test #069: uSub(Float) is "3.14159265": *** NOT OK *** (3.14159265000000021)
Test #070: uSub(Float) is "7.64159265": *** NOT OK *** (7.64159264999999976)
Test #071: uMult(Float) is "-788.8": *** NOT OK *** (-788.799999999999955)
Test #073: uMult(Float) is "204.20352225": *** NOT OK *** (204.20352225000002)
Test #074: uDiv(Float) is "1.89230769230769231": *** NOT OK *** (1.89230769230769225)
Test #083: uAppnd(Str) is "hello3.14159265": *** NOT OK *** (hello3.14159265000000021)
Test #151: uAssLet(Float) is "3.14159265": *** NOT OK *** (3.14159265000000021)
Test #152: uAssAdd(Float) is "6.2831853": *** NOT OK *** (6.28318530000000042)
Test #153: uAssSub(Float) is "3.14159265": *** NOT OK *** (3.14159265000000021)
Test #154: uAssAppnd(Str) is "3.141592653.14159265": *** NOT OK *** (3.141592650000000213.14159265000000021)
Test #188: #3 ==> 3.14159265: *** NOT OK *** - 3.14159265000000021
Test #197: #3+1 ==> 4.14159265: *** NOT OK *** - 4.14159264999999976
Test #198: 1.1*1.1 ==> 1.21: *** NOT OK *** - 1.21000000000000019
Test #199: pow(1.1,2) ==> 1.21: *** NOT OK *** - 1.21000000000000019
Test #211: 37/10 ==> 3.7: *** NOT OK *** - 3.70000000000000018
Test #403: round(3.14159265, 1) ==> 3.1: *** NOT OK *** - 3.10000000000000009
Test #404: round(3.14159265, 2) ==> 3.14: *** NOT OK *** - 3.14000000000000012
Test #405: round(3.14159265, 3) ==> 3.142: *** NOT OK *** - 3.1419999999999999
Test #406: round(3.14159265, 4) ==> 3.1416: *** NOT OK *** - 3.14159999999999995
Test #409: round(cos("0.523598775"),8) ==> 0.8660254: *** NOT OK *** - 0.866025399999999945
Test #411: round(tan("0.523598775"),8) ==> 0.57735027: *** NOT OK *** - 0.577350270000000054
Test #413: round(arcsin(0.5),8) ==> 0.52359878: *** NOT OK *** - 0.523598780000000041
Test #414: round(arcsin(-0.2),8) ==> -0.20135792: *** NOT OK *** - -0.201357919999999996
Test #415: round(arccos(0.5),8) ==> 1.04719755: *** NOT OK *** - 1.04719754999999992
Test #416: round(arccos(-0.2),8) ==> 1.77215425: *** NOT OK *** - 1.77215425000000004
Test #417: round(arctan(0.5),8) ==> 0.46364761: *** NOT OK *** - 0.463647609999999988
Test #418: round(arctan(-0.2),8) ==> -0.19739556: *** NOT OK *** - -0.197395559999999998
Test #421: round(dcos(30),8) ==> 0.8660254: *** NOT OK *** - 0.866025399999999945
Test #423: round(dtan(30),8) ==> 0.57735027: *** NOT OK *** - 0.577350270000000054
Test #426: round(arcdsin(-0.2),8) ==> -11.53695903: *** NOT OK *** - -11.5369590300000002
Test #428: round(arcdcos(-0.2),8) ==> 101.53695903: *** NOT OK *** - 101.536959030000006
Test #429: round(arcdtan(0.5),8) ==> 26.56505118: *** NOT OK *** - 26.5650511800000011
Test #430: round(arcdtan(-0.2),8) ==> -11.30993247: *** NOT OK *** - -11.3099324699999997
Test #483: c2f('אאאאAAAAAAAA') ==> 9.66814841595012435e+96: *** NOT OK *** - 9.66814841595012415e+96
Test #737: <#4:=#3+1> ==> "4.14159265": *** NOT OK *** - #4 == 4.14159264999999976
Test #817: <#7:=20/3> ==> "6.66666666666666667": *** NOT OK *** - #7 == 6.66666666666666696
ALUUnitTest: 43 tests failed: [9, 43, 48, 61, 62, 63, 68, 69, 70, 71, 73, 74, 83, 151, 152, 153, 154, 188, 197, 198, 199, 211, 403, 404, 405, 406, 409, 411, 413, 414, 415, 416, 417, 418, 421, 423, 426, 428, 429, 430, 483, 737, 817]
Test #073 *** NOT OK ***
        Got: <3.140000000000000122.140000000000000121.140000000000000120.140000000000000124>
        Expected: <3.142.141.140.14>
Test #102 *** NOT OK ***
        Got: <AVG:3 STD:1.41421360000000007 ERR:0.353553400000000018 VAR:2 SUM:15 MIN:1 MAX:5>
        Expected: <AVG:3 STD:1.4142136 ERR:0.3535534 VAR:2 SUM:15 MIN:1 MAX:5>
Test #103 *** NOT OK ***
        Got: <5 11 3 5 4 0.363599999999999979 36.3639999999999972%>
        Expected: <5 11 3 5 4 0.3636 36.364%>
Test #179 *** NOT OK ***
        Got: <100.218925476099997>
        Expected: <100.2189254761>
ProcessingTest: 4 tests failed: [73, 102, 103, 179]

Success! All failures are rounding errors.

Still need to check that in an ARM-based installation we get no leaks and no failing tests at all.

@yoavnir

yoavnir commented Jun 23, 2026

Copy link
Copy Markdown
Owner Author

Yes. Works fine on Linux on ARM. No unit tests fail.

@yoavnir yoavnir merged commit c75faf8 into dev-1.0.0 Jun 23, 2026
4 checks passed
@yoavnir yoavnir deleted the dev-1.0.0-issue449 branch June 23, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant