Skip to Content.
Sympa Menu

freetds - [freetds] core dump w/ perl, DBlib & freetds

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Louis Cardali" <lcardali AT verio.net>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] core dump w/ perl, DBlib & freetds
  • Date: Wed, 24 Mar 2004 15:17:50 -0500

Having the mindset, of no matter how bad the data, a program should never
core dump. In the evaluation of FreeTDS with Perl on FreeBSD, created a case
where the program core dumps. Same program does not core dump w/ openclient.
Nor does it dump core when using tsql. The problem stems from dbresults
called consecutively. While it may not be the preferred coding; give me an
error, call me stupid; but don't dump core. :-)

#!/usr/local/bin/perl

use Sybase::DBlib;
$dbh = new Sybase::DBlib 'user','password','server';
if (! defined ($dbh))
{
print qq{FAILED, could not get new Sybase::DBlib object!\n};
exit;
}

$status = $dbh->dbuse('db_systest');
print qq{Use DB, status [$status]\n};

$q = qq{
SET ROWCOUNT 3
select abs(-1) union select abs(-2) union select abs(0) union select abs(5)
union select abs(10)
SET ROWCOUNT 0
SELECT pi()
};

$status = $dbh->dbcmd($q);
print __LINE__ . "dbcmd status $status \n";
$status = $dbh->dbsqlexec;
print __LINE__ . "dbsqlexec status $status \n";

$status = $dbh->dbresults;
print __LINE__ . "dbresults status $status \n";
while ( $status != NO_MORE_RESULTS and $status != FAIL ) {
$status = $dbh->dbresults;
print __LINE__ . "dbresults status $status \n";
while ( %rec = $dbh->dbnextrow(1) ) {
foreach $k ( keys %rec ) { print "$k => $rec{$k}," };
print "\n";
}
}
print __LINE__ . "dbresults status $status \n";

The output is:
Server 'Server',
Changed database context to 'master'.

Msg 5701, Level 10, State 1
Server 'Sever', Line 1
Changed database context to 'db_systest'.

Use DB, status [1]
23dbcmd status 1
25dbsqlexec status 1
28dbresults status 1
DB-Library error:
Attempt to initiate a new SQL Server operation with results pending.
31dbresults status 0
Memory fault (core dumped)

Here's the latter part of the freetds log file:
17:43:36.943014 dbsqlok() marker is fd
17:43:36.943045 processing result tokens. marker is fd(DONE)
17:43:36.943076 tds_process_end: more_results = 1
was_cancelled = 0
error = 0
done_count_valid = 0
17:43:36.943123 dbsqlok() end status was success
17:43:36.943359 dbresults()
17:43:36.943397 dbresults_r()
17:43:36.943423 processing result tokens. marker is ee(RESULT)
17:43:36.943489 processing result. type = 38(integer-null), varint_size 1
17:43:36.943562 processing result. column_size 4
17:43:36.943608 dbresults_r() result_type = 4049 retcode = 1
17:43:36.943640 processing result tokens. marker is ae(CONTROL)
17:43:36.943777 tds_process_default_tokens() marker is ae(CONTROL)
17:43:36.943833 token.c:212: Eating CONTROL token
17:43:36.943864 processing result tokens. marker is d1(ROW)
17:43:36.943894 dbresults_r() result_type = 4040 retcode = 1
17:43:36.943922 leaving dbresults() returning 1
17:43:36.944665 dbresults()
17:43:36.944723 dbresults_r()
17:43:36.944751 processing result tokens. marker is d1(ROW)
17:43:36.944782 dbresults_r() result_type = 4040 retcode = 1
17:43:36.945026 tds_client_msg: #20019: "Attempt to initiate a new SQL
Server operation with results pending.". Connection state is now 1.
17:43:36.945095 leaving dbresults() returning 0
17:43:36.945305 dbnextrow()
17:43:36.945343 processing row tokens. marker is d1(ROW)
17:43:36.945375 processing row. column is 0 varint size = 1
17:43:36.945404 processing row. column size is 4
17:43:36.945438 clearing column 0 NULL bit

Please let me know if you need any more information to replicate the
problem.

Thanks.

Louis





Archive powered by MHonArc 2.6.24.

Top of Page