-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix crash when calling buffer.request multiple times #45
Conversation
buffer.request now creates a temporary Py_buffer instead of a pointer. This reduces the probability of misstakes, and stops a segfault when buffer.request was called twice. Also add build folder to gitignore.
Hi -- the issue with your change is that the buffer_info will return a pointer that may not be valid anymore after calling I think it will be better to use the previous approach and detect if |
What if the user calls with How about letting the |
That would be reasonable -- can you make it a private field in this case? buffer_info needs a new constructor in this case which requests a buffer view and fills all the necessary fields. And the current constructor should just set the buffer view pointer to |
I've been putting some thought into this and I wonder, where do we need The only other place we currently create a |
Aren't you forgetting about |
You are indeed correct, will need to think more about this. The ownership issue really should be settled properly however. |
This is now fixed, a buffer can only be requested once (second time is a NOP). |
buffer.request now creates a temporary Py_buffer instead of a pointer.
This reduces the probability of misstakes, and stops a segfault when
buffer.request was called twice.
I think the new design has no major drawbacks over the previous, it is possibly faster since the buffer is now stack-allocated. Also we got rid of the destructor which should not be needed in this case.
Also add build folder to gitignore.