-
-
Notifications
You must be signed in to change notification settings - Fork 730
add sig_on and sig_off to avoid segfault #41264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Refactor get and set methods to use indexing directly.
Removed illegal assignment example and related comments.
Added tests for vector assignment and index errors.
There was a problem hiding this 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
|
please see my comment in #41249 - the whole point of |
|
In some cases, it will not cause a segfault |
|
segfaults are triggered by hardware when you are trying to access memory not allocated for your process. So you can violate the boundaries of your array sometimes, without triggering it, it is normal. I still wonder whether it's not better just to leave this |
|
I think the method is strange. like |
|
the naming is unfortunate. perhaps it should be renamed to |
But we already have get_unsafe |
|
get_unsafe is Cython only |
|
Documentation preview for this PR (built with commit 50390f5; changes) is ready! 🎉 |
|
do the following
looks like nbruin agree. But if one want to be careful, better |
|
How do I change get and set to be safe method |
Actually, that's something that requires some testing. So, to be safe, I would advise against cpdeffing them. If you want a python wrapper as well, define it separately and deal with the name clash that would arise on cython level (as in: don't name the wrapper the same as the |
Just use |
I think maybe we could not expose these unsafe methods to users. it will lead segfault sometimes out of bound. |
|
in Python, anything that starts with Besides you always have other ways to break the system, e.g. you can |
I think you might be confusing single In python code, rather than using |
Yes, that's the conclusion we came to. On cython level, there's a benefit to That's also why we should NOT make Just deprecate |
|
we can rename get_unsafe, adding _ or __ in front |
What would we gain from that? The cython cdef This PR is about the python-level method |
|
As an illustration of the cost of With this code, instances of the original class are fine: However, if we subclass, the The |
Fix #41249 add sig_on and sig_off to the unsafe methods`
📝 Checklist
⌛ Dependencies