Bug#317453: libdbd-sqlite2-perl seg faults Perl interpreter

Steve Madsen Steve Madsen <steve@moonglade.com>, 317453@bugs.debian.org
Fri, 08 Jul 2005 10:01:13 -0700


Package: libdbd-sqlite2-perl
Version: 2:0.33-3

Running two concurrent queries with DBD::SQLite2 crashes the Perl 
interpreter with a segmentation fault.  Here is a sample script and 
database that reproduces the problem:

#!/usr/bin/perl

use strict;
use warnings;
use DBI;

my($dbh,$q1,$q2);
$dbh = DBI->connect("dbi:SQLite2:test.db");

$q1 = $dbh->prepare("SELECT * FROM test WHERE col1 = ?");
$q1->execute(0);
$q2 = $dbh->prepare("SELECT * FROM test WHERE col1 = ?");
$q2->execute(1);

my (@row);
while (1) {
     if (@row = $q1->fetchrow()) {
         print "q1 fetch, id=$row[0], col1=$row[1], col2=$row[2]\n";
     } elsif (@row = $q2->fetchrow()) {
         print "q2 fetch, id=$row[0], col1=$row[1], col2=$row[2]\n";
     } else {
         last;
     }
}

$q1->finish();
$q2->finish();

$dbh->disconnect();

exit 0; 


Create "test.db" using the following SQL:

create table test (id INTEGER PRIMARY KEY, col1 INTEGER, col2 INTEGER);
insert into test (id, col1, col2) values (1, 0, 0);
insert into test (id, col1, col2) values (2, 0, 1);
insert into test (id, col1, col2) values (3, 1, 0);
insert into test (id, col1, col2) values (4, 1, 1); 


The output of the script with this database is:

q1 fetch, id=1, col1=0, col2=0
q1 fetch, id=2, col1=0, col2=1
q2 fetch, id=3, col1=1, col2=0
Segmentation fault

I expect that the final line should be "q2 fetch, id=4, col1=1, col2=1". 


Debian 3.1, kernel 2.4.30, libc 2.3.2.ds1-22, Perl 5.8.4.  All the 
expected dependencies are current with sarge and any released security 
updates.

-- 
Steve Madsen <steve@moonglade.com>