Skip to content

Tests: Free the dummy Node in the BTForEach and BTSetVar tests - #476

Merged
limbonaut merged 1 commit into
limbonaut:masterfrom
Th3D0c0:fix-test-node-leaks
Sep 4, 2026
Merged

limbonaut merged 1 commit into
limbonaut:masterfrom
Th3D0c0:fix-test-node-leaks

Conversation

@Th3D0c0

@Th3D0c0 Th3D0c0 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

tests/test_for_each.h and tests/test_set_var.h each memnew a Node and never free it. Every other test in the suite that creates one pairs it with a memdelete — for example test_check_var.h, test_check_trigger.h and test_call_method.h — so these two look like oversights rather than intent.

doctest re-enters a TEST_CASE body once per leaf SUBCASE, so the cost is one leaked Node per leaf: 4 from BTForEach and 18 from BTSetVar.

Running the suite in a tests=yes build reports:

WARNING: 22 ObjectDB instances were leaked at exit (run with `--verbose` for details).

and on a build with use_asan=yes, LeakSanitizer fails the run outright:

Direct leak of 14400 byte(s) in 18 object(s) allocated from:
    #3 TestSetVar::DOCTEST_ANON_FUNC_523() modules/limboai/tests/test_set_var.h:30
Direct leak of 3200 byte(s) in 4 object(s) allocated from:
    #3 TestForEach::DOCTEST_ANON_FUNC_364() modules/limboai/tests/test_for_each.h:24
SUMMARY: AddressSanitizer: 17600 byte(s) leaked in 22 allocation(s).

With both memdeletes added, the full Godot test suite reports 0 leaked instances and the same number of passing cases as before.

🤖 Generated with Claude Code

Both test cases memnew a Node and never free it. Every other test in the
suite that creates one pairs it with a memdelete; these two are the
outliers.

doctest re-enters a TEST_CASE body once per leaf SUBCASE, so the cost is
one Node per leaf: 4 from BTForEach and 18 from BTSetVar. Godot reports
them as "22 ObjectDB instances were leaked at exit", and on a build with
use_asan=yes LeakSanitizer fails the run outright:

  Direct leak of 14400 byte(s) in 18 object(s)   test_set_var.h:30
  Direct leak of  3200 byte(s) in  4 object(s)   test_for_each.h:24
  SUMMARY: AddressSanitizer: 17600 byte(s) leaked in 22 allocation(s).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01A4XimeYTjpo3crzdyNFrcn
@limbonaut limbonaut changed the title Free the dummy Node in the BTForEach and BTSetVar tests Tests: Free the dummy Node in the BTForEach and BTSetVar tests Sep 4, 2026
@limbonaut
limbonaut merged commit 3f14ea4 into limbonaut:master Sep 4, 2026
35 of 36 checks passed
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.

2 participants