Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-318

segfault appears on mariadb-connector 1.1.13

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • 1.1.13
    • 1.1.14
    • DBAPI 2.0
    • None
    • linux

    Description

      We observe a new segfault for mariadb-connector-python in SQLAlchemy's test suite as of version 1.1.13 which does not occur under 1.1.12.

      I've unfortunately not been able to create a single reproduction script, as the segfault occurs only when there's a fair number of unrelated modules loaded. The segfault is related to a test that intentionally causes errors on a connection where the backend database has been disconnected. All fairly abusive stuff for sure but the driver should never segfault.

      To reproduce the segfault you can run the particular suite in SQLAlchemy. The URI passed should be the username:password@host/dbname of an empty MariaDB database:

      git clone https://github.com/sqlalchemy/sqlalchemy
      cd sqlalchemy
      python -m venv .venv
      .venv/bin/pip install pytest typing-extensions mariadb==1.1.13
      .venv/bin/pytest test/engine/test_reconnect.py::InvalidateDuringResultTest --uri mariadb+mariadbconnector://scott:tiger@localhost/test

      The above test will pass but you'll see Segmentation Fault after that:

      test/engine/test_reconnect.py::InvalidateDuringResultTest_mariadb+mariadbconnector_10_11_11::test_invalidate_on_results PASSED [100%]

      ========================================================================================== 1 passed in 0.03s ==========================================================================================
      Segmentation fault (core dumped)

      Alternatively, run that whole suite and you'll see a big stack trace with a segfault

      $ .venv/bin/pytest test/engine/test_reconnect.py --dburi mariadb+mariadbconnector://scott:tiger@localhost/test
      ======================================================================================= sqlalchemy installation =======================================================================================
      SQLAlchemy 2.1.0b1 (user site loaded)
      Path: /home/classic/tmp/sqlalchemy/lib/sqlalchemy/_init_.py
      compiled extension not enabled; Modules sqlalchemy.util._collections_cy, sqlalchemy.util._immutabledict_cy, sqlalchemy.engine._processors_cy, sqlalchemy.engine._row_cy, sqlalchemy.engine._util_cy, sqlalchemy.sql._util_cy are not compiled
      ========================================================================================= test session starts =========================================================================================
      platform linux – Python 3.13.3, pytest-8.4.1, pluggy-1.6.0 – /home/classic/tmp/sqlalchemy/.venv/bin/python3.13
      cachedir: .pytest_cache
      rootdir: /home/classic/tmp/sqlalchemy
      configfile: pyproject.toml
      collected 56 items

      test/engine/test_reconnect.py::CursorErrTest::test_cursor_explode PASSED [ 1%]
      test/engine/test_reconnect.py::CursorErrTest::test_cursor_shutdown_in_initialize PASSED [ 3%]
      test/engine/test_reconnect.py::InvalidateDuringResultTest_mariadb+mariadbconnector_10_11_11::test_invalidate_on_results PASSED [ 5%]
      test/engine/test_reconnect.py::MockReconnectTest::test_check_disconnect_no_cursor Fatal Python error: Segmentation fault

      Current thread 0x00007f4be781ab80 (most recent call first):
      Garbage-collecting
      File "<frozen importlib._bootstrap_external>", line 784 in _compile_bytecode
      File "<frozen importlib._bootstrap_external>", line 1155 in get_code
      File "<frozen importlib._bootstrap_external>", line 1022 in exec_module
      File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
      File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
      File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1415 in _handle_fromlist
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/dialects/postgresql/base.py", line 1554 in <module>
      File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
      File "<frozen importlib._bootstrap_external>", line 1026 in exec_module
      File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
      File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/dialects/postgresql/asyncpg.py", line 198 in <module>
      File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
      File "<frozen importlib._bootstrap_external>", line 1026 in exec_module
      File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
      File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
      File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1415 in _handle_fromlist
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/dialects/postgresql/_init_.py", line 12 in <module>
      File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
      File "<frozen importlib._bootstrap_external>", line 1026 in exec_module
      File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
      File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/dialects/_init_.py", line 48 in _auto_fn
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/util/langhelpers.py", line 437 in load
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/engine/url.py", line 772 in _get_entrypoint
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/engine/create.py", line 536 in create_engine
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/util/deprecations.py", line 281 in warned
      File "<string>", line 2 in create_engine
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/testing/engines.py", line 344 in testing_engine
      File "/home/classic/tmp/sqlalchemy/test/engine/test_reconnect.py", line 388 in setup_test
      File "/home/classic/tmp/sqlalchemy/lib/sqlalchemy/testing/asyncio.py", line 92 in _maybe_async
      File "/home/classic/tmp/sqlalchemy/test/../lib/sqlalchemy/testing/plugin/pytestplugin.py", line 564 in setup_test_methods
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/fixtures.py", line 922 in call_fixture_func
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/fixtures.py", line 1195 in pytest_fixture_setup
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_callers.py", line 121 in _multicall
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/hooks.py", line 512 in __call_
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/fixtures.py", line 1127 in execute
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/fixtures.py", line 639 in _get_active_fixturedef
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/fixtures.py", line 548 in getfixturevalue
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/fixtures.py", line 719 in _fillfixtures
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/python.py", line 1674 in setup
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/runner.py", line 514 in setup
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/runner.py", line 164 in pytest_runtest_setup
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_callers.py", line 121 in _multicall
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/hooks.py", line 512 in __call_
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/runner.py", line 246 in <lambda>
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/runner.py", line 344 in from_call
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/runner.py", line 245 in call_and_report
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/runner.py", line 130 in runtestprotocol
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/runner.py", line 117 in pytest_runtest_protocol
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_callers.py", line 121 in _multicall
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/hooks.py", line 512 in __call_
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/main.py", line 367 in pytest_runtestloop
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_callers.py", line 121 in _multicall
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/hooks.py", line 512 in __call_
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/main.py", line 343 in _main
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/main.py", line 289 in wrap_session
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/_pytest/main.py", line 336 in pytest_cmdline_main
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_callers.py", line 121 in _multicall
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pluggy/hooks.py", line 512 in __call_
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pytest/config/init_.py", line 175 in main
      File "/home/classic/tmp/sqlalchemy/.venv/lib64/python3.13/site-packages/pytest/config/init_.py", line 201 in console_main
      File "/home/classic/tmp/sqlalchemy/.venv/bin/pytest", line 8 in <module>

      Extension modules: mariadb._mariadb (total: 1)
      Segmentation fault (core dumped)

      Attachments

        Issue Links

          Activity

            People

              georg Georg Richter
              zzzeek Mike Bayer
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.