Right shutdown for DBD::Oracle

Hi DBI Developers,

I spent some time to find the root cause of a segfault in DBD::Oracle (https://github.com/perl5-dbi/DBD-Oracle/issues/65).

During running the test suite a segfault is triggered by ressource "OCIHandleFree(OCI_HTYPE_ENV)" in dr::DESTROY if a database connaction still exists. The test runs fine if the database connection is close before ($dbh->disconnect). The segfault itself occurrs in db::DESTRY (dbd_db_destroy()) because of the earlier freed ressource. From my understanding of the Oracle interface freeing the ressource "OCIHandleFree(OCI_HTYPE_ENV)"  late in the destruction process is right.

Currently I'm not sure about the right DBI shutdown sequence. The documentation DBI::DBD doesn't state anything about this. I expect a top-down process, freeing open statements, shutdown the database and last shutdown the driver. In the sequence as shown with DBI_TRACE the driver is destroyed first and the database level in a later step.

Is there a way to change the shutdown sequence to destroy the database first and the driver last?

Another option would be calling dbd_db_disconnect() from dr::DESTROY but I don't have any dbh in this function.

Just for reference: DBI trace with a segfault
!   >> DESTROY     DISPATCH (DBI::dr=HASH(0x556494047aa0) rc1/1 @1 g2 ima10004 pid#28793) during global destruction
    >> DESTROY DBI::dr=HASH(0x556494047aa0) clearing 1 CachedKids
!   -> DESTROY for DBD::Oracle::dr (DBI::dr=HASH(0x556494047aa0)~INNER) thr#5564920f3010
!   <- DESTROY= ( undef ) [1 items] during global destruction
    DESTROY (dbih_clearcom) (drh 0x556494047a28, com 0x55649404b230, imp global destruction):
       FLAGS 0x102215: COMSET Active Warn PrintWarn ShowErrorStatement AutoCommit
       PARENT undef
       KIDS 1 (1 Active)
    dbih_clearcom 0x556494047a28 (com 0x55649404b230, type 1) done.
!   >> DESTROY     DISPATCH (DBIx::ContextualFetch::db=HASH(0x55649404e2c0) rc1/1 @1 g2 ima10004 pid#28793) during global destruction
!   -> DESTROY for DBD::Oracle::db (DBIx::ContextualFetch::db=HASH(0x55649404e2c0)~INNER) thr#5564920f3010
**Segmentation fault**

Do you have any ideas / hints how I can fix this shutdown sequence?

Thank you for your support,
3/28/2019 5:59:24 AM
perl.dbi.dev 1960 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 8
Get it on Google Play
Get it on Apple App Store