You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on some test code that creates a psycopg2.extensions.Column object from Python code we discovered that creating this object is enough to trigger a segfault when the object is deleted. Admittedly the library only creates that object from C code when building the result of cursor.description() so the use case isn't entirely realistic.
Here's an example that demonstrates the crash. I've confirmed it behaves the same on Python 3.8 from Ubuntu 20.04 and Python 3.9 from Fedora 34.
Fixed, thank you for the test case to reproduce it.
FYI I looked at your solution, but the practice is first to incref, then to set the attribute in the C structure. Doing the opposite leaves a window for race conditions open (likely not in the constructor, but it's still better to err on the safe side).
While working on some test code that creates a
psycopg2.extensions.Column
object from Python code we discovered that creating this object is enough to trigger a segfault when the object is deleted. Admittedly the library only creates that object from C code when building the result ofcursor.description()
so the use case isn't entirely realistic.Here's an example that demonstrates the crash. I've confirmed it behaves the same on Python 3.8 from Ubuntu 20.04 and Python 3.9 from Fedora 34.
Here's the virtual environment for running the test:
The text was updated successfully, but these errors were encountered: