Macaulay2 / Macaulay2/M2

MonomialMemorySpace release-all methods leave the allocation count stale

Open Beginner friendly
#4,712 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Engine
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

Both freeAllAllocs and freeAllAllocsAndBackingMemory in M2/Macaulay2/e/monomials/monomial-sets.hpp release storage but do not reset mCount.

MonomialMemorySpace arena;
arena.allocate(3);
arena.allocate(5);
arena.freeAllAllocs(); // same result with freeAllAllocsAndBackingMemory()
// expected arena.size() == 0; actual 2
auto* next = arena.allocate(2);
// expected size 1; actual 3
arena.popLastAlloc(next);
// expected size 0; actual 2

The normal allocate/pop path uses this count as the live allocation count, and owning monomial collections use it as their size.

Reproduced for both release methods in direct Debug engine tests at c156fdcba4 (Apple Clang 21). No production changes.

Failing unit-test blocks
  • TEST(MonomialCollections, DISABLED_releaseAllResetsLiveCount) in M2/Macaulay2/e/unit-tests/MonomialCollectionsTest.cpp.

These regressions were explicitly run and confirmed to fail against the current implementation. They assert the intended corrected behavior and remain disabled in normal runs until the defect is fixed.

Run from the CMake build directory after building M2-unit-tests:

./Macaulay2/e/M2-unit-tests \
  --gtest_also_run_disabled_tests \
  --gtest_filter='MonomialCollections.DISABLED_releaseAllResetsLiveCount'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in M2/Macaulay2/e/monomials/monomial-sets.hpp and inspect freeAllAllocs and freeAllAllocsAndBackingMemory, then read the disabled test in M2/Macaulay2/e/unit-tests/MonomialCollectionsTest.cpp. Run the specified M2-unit-tests command from the CMake build directory. Done means both release methods leave size() at zero and the subsequent allocate/pop sequence reports the correct live count.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
86/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.