Home » Perl » DBI » Perl DBD::Sybase and signal handling

Perl DBD::Sybase and signal handling

There appears to a bug with DBD::Sybase or perhaps Sybase OpenClient ctlib (threaded) that causes custom signal handlers to segfault.  This tripped up a monitoring script that I wrote.

I’ve asked the perl module maintainer, Michael Peppler, whether this is a DBD::Sybase bug or an Openclient bug.

Update:

looks like this is a DBD::Sybase bug not an OpenClient ctlib as the example $SYBASE/$SYBASE_OCS/sample/ctlibrary/multthrd.c with an added signal handler works fine:
$ diff multthrd.c $SYBASE/$SYBASE_OCS/sample/ctlibrary/multthrd.c

150,151d149
< #include <signal.h>
< 217,223d214
< void leave(int sig);
<
< void leave(int sig) {
<     printf("caught SIGINT\n");
<     exit(-1);
< }
<
258,259d248
<       (void) signal(SIGINT,leave);
<
344,348d332
<        for(;;) {
<         printf("Ready...\n");
<         (void)getchar();
<     }
<
.....
Thread_2:All done processing rows - total 116.
Ready...
caught SIGINT

Bug text:

#!/usr/local/bin/perl

use strict;
use DBI;
use DBD::Sybase;

$SIG{'INT'} = sub {print "hi there\n";exit();};

print "go\n";

while (1) {
  sleep(1);
}

If I run this and then type ^C I get a segmentation fault. If I comment out

the ‘use DBD::Sybase;’ line, it works fine

Workaround:

Build DBD::Sybase against the nonthreaded (libct.so not libct_r.so) openclient libraries.

Share Button

One thought on “Perl DBD::Sybase and signal handling

  1. adam says:

    Thankyou Thankyou Thankyou!

    We were having segfaults on our mod_perl servers which we fixed by pulling DBD::Sybase into the startup.pl phase (this segfaulted immediately until we upgraded the OCS from 12_5 to 15_0); however this meant we couldn’t kill apache – it appears that DBD::Sybase (or one of the underlying sybase libraries) grabs all the signal handlers. Looks like the underlying problem was the threaded DBD::Sybase – I rebuilt DBD::Sybase with the non-threaded libs and *bang*: I can stop apache nicely now.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Facebook login by WP-FB-AutoConnect