gh-149738: Fix segmentation fault bug in sqllite3#149754
Conversation
picnixz
left a comment
There was a problem hiding this comment.
We need tests and check what happens on the created connection after deletion (check that there is still a row factory on the newly created cursor)
|
Thanks for your comment and review, @picnixz! P.S. The Read the Docs build is failing, but the logs indicate it’s due to an external issue unrelated to my changes. |
vstinner
left a comment
There was a problem hiding this comment.
I would prefer using connection_getset instead of connection_members for row_factory and text_factory to raise an exception if the developer tries to delete the attribute (set it to NULL). Add get/set on these attributes.
|
Hi @vstinner! Thank you for your kind review. Sorry for the delay, GitHub access has been unreliable here recently. |
picnixz
left a comment
There was a problem hiding this comment.
Plesse correct undefined behaviors by changing the getset signatures. There should be no cast to getter/setter.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
| } | ||
|
|
||
| static PyObject * | ||
| connection_get_row_factory(pysqlite_Connection *self, void *closure) |
There was a problem hiding this comment.
Those getsets must be using a critical section as well.
|
Hi @picnixz, thank you for the review. I've updated the getter/setter signatures to match the expected Regarding the request to use a critical section: I searched Could you please point me to an example, or clarify which object/state should be protected here? I have made the requested changes; please review again. |
|
Thx. For now let's ignore races on attributes. If we can have many other attributes that can be mutated but none are protected, we can address it later. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I have minor concerns about the doc changes.
|
|
||
| .. versionchanged:: next | ||
| Deleting the ``row_factory`` attribute is no longer allowed and raises | ||
| :exc:`AttributeError`. |
There was a problem hiding this comment.
I'm not sure that it's worth it to document this minor behavior. I'm not sure that it's useful to mention the exact exception (AttributeError).
There was a problem hiding this comment.
Thanks for the feedback.
I've simplified the versionchanged note and removed the mention of the specific exception. I kept the note itself since this is a user-visible behavior change, but I'm open to removing it if you think it's not necessary.
|
@picnixz: Do you want to double check the change? |
picnixz
left a comment
There was a problem hiding this comment.
LGTM. Should we backport it as it's a fix of a crash with an interface change though? I asked for the .. versionchanged:: stuff, but if we backport it, it will render as "3.14" for the 3.14 branch instead of 3.14.6 I think. I'm ok for the 3.15 backport at least.
IMO it's acceptable to backport the change. There is no reason to remove these attributes. If you remove them, sqlite does crash...
I expect that "next" will be rendered as "3.14.6" in the 3.14 branch. |
|
Thanks @sepehr-rs for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
GH-150768 is a backport of this pull request to the 3.15 branch. |
|
Sorry, @sepehr-rs and @vstinner, I could not cleanly backport this to |
|
GH-150769 is a backport of this pull request to the 3.14 branch. |
|
GH-150770 is a backport of this pull request to the 3.13 branch. |
|
Merged, thanks for the fix @sepehr-rs. I prefer disallowing to remove attributes rather than checking if attributes are set to NULL. |
|
Thanks everyone for the reviews and feedback! |
Fixes #149738.