Skip to content

segfault(shutdown): two FBIRD_CONNECT_FORCE_NEW links to same DB corrupt IAttachment at close #580

Description

@satwareAG-ironMike

Symptom

With two live physical connections to the same database created via FBIRD_CONNECT_FORCE_NEW, PHP request shutdown SIGSEGVs while closing the links:

#0 Firebird::IAttachment::getInfo<CheckStatusWrapper> (this=0x556adeae2bb9, ...)   <- garbage pointer
#1 fb::Connection::pingAttachment  src/cpp/fb_connection.hpp:451
#3 fb::Connection::detachNoThrow   src/cpp/fb_connection.hpp:491
#4 fbc_disconnect                  firebird_utils.cpp:607
#5 _php_fbird_close_link           fbird_connection.c:216
... zend_shutdown_executor_values -> php_request_shutdown

Connection* this=0x556f88569910 vs IAttachment*=0x556adeae2bb9 - the attachment pointer inside one wrapper points into a foreign/freed heap region.

Minimal repro (tests/ddl_default_tx_commit_001.phpt on branch fix/issue-572-578-ddl-execute-commit, pre-fix build reproduces identically - verified via stash control):

$c1 = fbird_connect($test_base);
$c2 = fbird_connect($test_base, '', '', '', 0, 3, '', FBIRD_CONNECT_FORCE_NEW);
// ... any work ...
// script ends WITHOUT explicit fbird_close() -> shutdown closes both links -> SIGSEGV

Explicitly fbird_close()-ing the second link before script end avoids it.

Notes

Acceptance criteria

  1. phpt with two FORCE_NEW connections surviving request shutdown without segfault
  2. gdb/ASAN clean on that repro

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions