Macaulay2 / Macaulay2/M2

Nonlegacy ExponentList constructors use legacy length words

Open Beginner friendly
#4,711 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

`ExponentList` interprets its first word as the number of variable/exponent pairs: `length(m) = 2*m[0]+1`. However, `one` and `var` in `M2/Macaulay2/e/monomials/ExponentList.hpp` always write legacy total-length words.

```cpp
using Ops = ExponentList; // also occurs for int,false
Ops::Vector output;
Ops::one(output); // expected [0]; actual [1]
Ops::var(2, 3, output); // expected [1,2,3]; actual [3,2,3]
Ops::var(2, 0, output); // expected [0]; actual [1]
```
Readers consequently interpret these allocations as larger than their actual sizes, potentially reading beyond the end. The representations are aliased by f4/varpower-monomial.hpp and schreyer-resolutions/res-monomial-types.hpp.

Reproduced by checking output size and the first word, without dereferencing beyond its allocation, in direct typed engine tests at c156fdcba4 (Apple Clang 21). No production changes.

### Failing unit-test blocks

- `TYPED_TEST(ExponentListNonlegacy, DISABLED_constructorLengthConvention)` in `M2/Macaulay2/e/unit-tests/ExponentListTest.cpp`.

This typed block fails for both `ExponentList` and `ExponentList` (instances `/0` and `/1`).

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`:

```sh
./Macaulay2/e/M2-unit-tests \
--gtest_also_run_disabled_tests \
--gtest_filter='ExponentListNonlegacy/*.DISABLED_constructorLengthConvention'
```

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

Inspect one and var in M2/Macaulay2/e/monomials/ExponentList.hpp, then read the disabled typed test in M2/Macaulay2/e/unit-tests/ExponentListTest.cpp. Run the provided M2-unit-tests command for ExponentListNonlegacy/*.DISABLED_constructorLengthConvention; done means both int,false and long,false instances pass with the nonlegacy length convention.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.