GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Guard iAttachment.detach() against an already-released interface (1.x backport of #69) by aminghadersohi · Pull Request #78 · FirebirdSQL/python3-driver

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Sep 26, 2026

Copy link
Copy Markdown

Backport of the #69 fix (#72, merged to master on 2026-05-21) to release-1.x. Fixes #77.

On 1.x, the v5 iAttachment.detach() override calls the native detach without the if self._refcnt: guard that iAttachment_v4.detach() has. When the garbage collector finalizes a connection that was never closed, the interface can already be released, and Connection.__del__ then detaches freed memory, which segfaults the process.

The change restores the guard, the same code as on master.

Verification against Firebird 5.0.3, CPython 3.11.15, Linux x86_64, with firebird-base 1.8.0, using the reproduction script in #77 (100 abandoned connections, each followed by gc.collect()):

  • release-1.x (1.10.11): segfault in interfaces.py detach in 3 of 3 runs (exit 139)
  • with this change: completed in 3 of 3 runs (exit 0)

The master regression test (tests/test_issues.py::test_issue_69_gc_of_abandoned_connection) relies on the pytest layout, which release-1.x does not have, so it is not ported here. The standalone script in #77 reproduces the crash on this branch.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@aminghadersohi
Guard iAttachment.detach() against an already-released interface (1.x)
375055e
Backport of the FirebirdSQL#69 fix (FirebirdSQL#72) to release-1.x. During cyclic garbage
collection the iAttachment's own iReferenceCounted.__del__ may run release()
before Connection.__del__ calls detach(); the v5 detach() override then
dereferenced freed memory and segfaulted. Restore the if self._refcnt guard
that iAttachment_v4.detach() already has.

Fixes FirebirdSQL#77.
@aminghadersohi aminghadersohi mentioned this pull request Sep 26, 2026
1.10.x: segfault when garbage-collecting an unclosed connection (#69 not fixed on release-1.x) #77
Open
@pcisar
pcisar merged commit e091764 into FirebirdSQL:release-1.x Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@aminghadersohi @pcisar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.