Skip to content

BUG: fix Stringdtype reinitialization after nan - #25882

Closed
mhvk wants to merge 1 commit into
numpy:mainfrom
mhvk:stringdtype-reinitialize-after-nan
Closed

mhvk wants to merge 1 commit into
numpy:mainfrom
mhvk:stringdtype-reinitialize-after-nan

Conversation

@mhvk

@mhvk mhvk commented Feb 25, 2024

Copy link
Copy Markdown
Contributor

I've been looking at trying to make the flags a bit more logical for StringDType (see fourth item in #25693) and in the process noted that even though the code is meant to track when a string in the arena is freed for possible re-use later, it actually zeros the offset when an entry is set to undefined, making this impossible. Furthermore, it does not track when the offset is reused for either a short string or a string on the heap, after which the arena should not longer be an option. This PR fixes both problems, aiming to keep the changes minimally intrusive. (I still hope to have a follow-up PR that tries to make the flags a bit more logical).

The current code is meant to track when a string in the arena is freed
for possible re-use later, but actually zeros the offset when an entry
is set to undefined, making this impossible. Furthermore, it does not
track when the offset is reused for either a short string or a string
on the heap, after which the arena should not longer be an option.
This commit fixes both problems, aiming to keep the changes minimally
intrusive.
// No room, resort to a heap allocation. We also set the short
// flag to indicate we can no longer use the heap (because the
// offset into the arena will get lost; TODO: should this be decided
// in newemptysize?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting both NPY_STRING_ON_HEAP and NPY_STRING_SHORT is incorrect, they are mutually exclusive and should never be simultaneously set.

Would you mind terribly if I tried my hand at a fix for the issue you discovered? Since I have more familiarity with how this code "should" be working.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to change, but note that I just followed what was on line 461...

Also, I've got a more complete rework in progress, partially as I wanted to avoid using the short size also for a medium-size flag. I'll try to push that up shortly...

@charris

charris commented Feb 27, 2024

Copy link
Copy Markdown
Member

Close/reopen

@charris charris closed this Feb 27, 2024
@charris charris reopened this Feb 27, 2024
@charris

charris commented Feb 27, 2024

Copy link
Copy Markdown
Member

@mattip the openblas problems are probably due to yesterday's wheel uploads.

@ngoldbaum

Copy link
Copy Markdown
Member

Closing this in favor of #25890 which fixes this bug along with other issues.

@ngoldbaum ngoldbaum closed this Feb 29, 2024
@mhvk
mhvk deleted the stringdtype-reinitialize-after-nan branch March 22, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants