Skip to content

Conversation

@cxzhong
Copy link
Contributor

@cxzhong cxzhong commented Dec 5, 2025

Fix #41249 Use the safe method instead of get_unsafe and set_unsafe

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Refactor get and set methods to use indexing directly.
@cxzhong cxzhong reopened this Dec 5, 2025
@cxzhong cxzhong changed the title Add a bound check and Avoid segfault Use the safe method to avoid segfault Dec 5, 2025
@cxzhong cxzhong marked this pull request as ready for review December 5, 2025 15:00
@cxzhong cxzhong requested a review from dimpase December 5, 2025 15:19
Copy link
Member

@dimpase dimpase left a comment

Choose a reason for hiding this comment

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

get() is an unsafe method, as documented. What's the point of this? Just use __getitem__, which (should be, although I didn't check) is safe

@dimpase
Copy link
Member

dimpase commented Dec 6, 2025

please see my comment in #41249 - the whole point of get is to be as quick as possible. One can wrap the call to get_unsafe in sig_on/sig_off, introducing some overhead, less than your PR. But I don't see much point in it.

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.

Segmentation Fault when trying to get out-of-bounds index of vector

2 participants