GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — BUG: avoid segfaults when legacy copyswap slot is not defined by ngoldbaum · Pull Request #32151 · numpy/numpy Conversation
Member
PR summaryTowards addressing #24859 (see also #30795 ping @SwayamInSync). This avoids segfaults in many operations if AI DisclosureI used an AI model to search the codebase and debug/test the fixes.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
SwayamInSync
suggested changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe need to tight some areas, specially around introducing an error-producing recursive
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The recursive structured-dtype paths are fixed here, but the top-level SF = _get_sfloat_dtype() np.array([1., 2.]).view(SF(1.)).byteswap() I see that #32150 handles this case. Since this PR is marked as a backport candidate while #32150 is a separate enhancement, should they be treated as dependent for release/backport purposes? Otherwise, should the title or summary clarify that this PR covers the structured/recursive call paths rather than all missing-copyswap[n] cases?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can do a second backport-only version that doesn't change any behavior and unconditionally raises an error. But that can land directly on the 2.5 branch.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually on second thought, to make the backport easier, I'll add just the null-check and TypeError on this branch.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
ngoldbaum
commented
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I addressed three of @SwayamInSync's comments and left a comment about how to handle backporting the fix in #32150
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can do a second backport-only version that doesn't change any behavior and unconditionally raises an error. But that can land directly on the 2.5 branch.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
SwayamInSync
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
SwayamInSync
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some nits, would be quick to resolve.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could the existing in-place writeability check remain before this missing-slot check? A read-only new-style array previously returned from arr = np.zeros(2, dtype=SF(1.)) arr.flags.writeable = False arr.byteswap(inplace=True) Previously this raised
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take a look at this suggestion
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this branch is being retained for the later relaxation in #32150, I think scalar reconstruction will need different handling when For a normal new-style scalar, this branch reaches: PyArray_Scalar(newmem, descr, NULL) That dispatches through The current always-error policy does not reach this code, so this is not a blocker for the backportable fix. But #32150 should either handle the immutable scalar as a direct no-op or reconstruct it through the new-style getitem slot rather than activating this path unchanged.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll just delete this dead branch in this PR and deal with this issue in #32150, thanks for pointing it out.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One non-blocking behavior question: with the new always-error policy, an in-place structured byteswap can modify supported fields encountered before an unsupported field and then raise For example: arr = np.zeros( 2, dtype=[("before", "i4"), ("v", SF(1.)), ("after", "i4")] ) arr["before"] = [1, 2] arr["after"] = [3, 4] arr.byteswap(inplace=True) After the Is partial mutation acceptable for this in-place API, or should the fields be preflighted for missing
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I can live this it... Would be nicer if we just checked things ahead of time, but that seems tedious. (The point of the PR is in the end to avoid a segfault, so...)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll take a look at whether checking first makes the diff complicated, if it does I'll defer this to the followup PR.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
seberg
reviewed
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, generally seems fine and should also be fine to backport. Part of me wonders if we should abuse the I would be tempted to delete at least the setitem fast-path, but for the "just get this fixed" part, probably not worth it, even if the I guess my only real request is to rename
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we rename this or actually make it check?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The check is coming in a followup (#32150). I'm setting up the internal API just to make the diff of the followup smaller. But I will change the name to
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, late and not blocking - but if this checks in #32150, would we always keep chaining with Since we're restructuring all the call sites, we could just output
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsUh oh!
There was an error while loading. Please reload this page.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I almost wonder if we should just hope that TRIVIALLY_COPYABLE s now typically set (on the destination I guess), add a fast-path that makes use of that, and just delete this whole fast-path... (In part, because this try/except style s annoying as well, but also because the fast-path should be hit often and actually be fast as promised.) But yeah, looks OK here.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I'll think about folding this into #32150.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I can live this it... Would be nicer if we just checked things ahead of time, but that seems tedious. (The point of the PR is in the end to avoid a segfault, so...)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
ngoldbaum
added a commit
to ngoldbaum/numpy
that referenced
this pull request
[2.4.x backport: rebased onto the numpy#32151 backport — replaces the strict check_missing_copyswap() guard in PyArray_Byteswap with the no-op fallback, and removes test_byteswap_raises, whose TypeError expectation for byteorder-less dtypes this commit deliberately changes to a no-op; the read-only inplace ValueError path stays covered by the StringDType test_byteswap.] (cherry picked from commit 18f6dfa)
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
charris
pushed a commit
that referenced
this pull request
charris
added a commit
that referenced
this pull request
BUG: avoid segfaults when legacy copyswap slot is not defined (#32151)
ngoldbaum
added a commit
to ngoldbaum/numpy
that referenced
this pull request
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewers+1 more reviewerUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabelsProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |