Skip to content

segfault in garbage collecting #69

@hmoffatt

Description

@hmoffatt

I'm migrating my code from fdb and SQLAlchemy v1 with sqlalchemy-firebird to firebird-driver and SQLAlchemy v2.

I have connections to the database both directly from my test code with firebird.driver, and using SQLAlchemy from the production code. When the SQLAlchemy connection is made and reflects the database schema, Python 3.13 is crashing:

Fatal Python error: Segmentation fault

Current thread 0x00007f299f438780 (most recent call first):
  Garbage-collecting
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/firebird/driver/interfaces.py", line 1264 in detach
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/firebird/driver/core.py", line 1803 in __del__
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/firebird/driver/interfaces.py", line 146 in status
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/firebird/driver/interfaces.py", line 525 in get_field
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/firebird/driver/core.py", line 323 in create_meta_descriptors
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/firebird/driver/core.py", line 3015 in __init__
  File "__init__", line ??? in __init__
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/firebird/driver/core.py", line 1855 in _prepare
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/firebird/driver/core.py", line 3939 in _execute
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/firebird/driver/core.py", line 4075 in execute
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/engine/default.py", line 952 in do_execute
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy_firebird/firebird.py", line 146 in do_execute
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1967 in _exec_single_context
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1846 in _execute_context
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/engine/base.py", line 1779 in exec_driver_sql
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy_firebird/base.py", line 835 in get_columns
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/engine/reflection.py", line 106 in cache
  File "<string>", line 2 in get_columns
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/engine/default.py", line 1136 in _default_multi_reflect
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/engine/reflection.py", line 931 in get_multi_columns
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/engine/reflection.py", line 2005 in run
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/engine/reflection.py", line 2019 in _get_reflection_info
  File "/home/hamish/dev/pyservices-sqlalchemy2/.venv/lib/python3.13/site-packages/sqlalchemy/sql/schema.py", line 5891 in reflect

This seems to happen with this sequence:

  1. firebird.driver.connect(), do something, forget the connection (without explcit close)
  2. Now connect from SQLAlchemy

If I retain the connection from step 1 then step 2 succeeds, though I have seem it crash later (maybe that connection was eventually forgotten).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions