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();
<     }
<&#91;/perl&#93;

&#91;text gutter="false"&#93;
.....
Thread_2:All done processing rows - total 116.
Ready...
caught SIGINT&#91;/text&#93;
<h3>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