dotnet / dotnet/machinelearning

cloning is incorrectly implemented

Open
#7,381 1 comment 0 reactions 0 assignees View on GitHub
area-DataFrame
Dominant language
C#
Stars
9.4k
Forks
2k
Avg merge
2d 20h
Merged PRs (30d)
11

Description

The CloneAs* methods for PrimitiveDataFrameColumn are incorrect. They seem to assume 1 input buffer will become 1 output buffer. This can't be correct in the case where for example:
- The original buffer is at MaxCapacity elements => therefore has size in bytes of ArrayUtility.ArrayMaxSize
- The new buffer has a larger sizeof(T)

As an experiment I set the ArrayMaxSize to a smaller value (say 32768). In integer elements this will therefore be 8192 but in double elements only 4096. However the clone routine will still attempt to allocate a buffer of 8192 doubles = 65K bytes. Running an operation that would cause a clone I indeed see the expected exception:

![Image](https://github.com/user-attachments/assets/7f30fd2c-5741-48ca-9133-12b3f3dae294)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.