Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: Perl-8.4.1
-
Fix Version/s: Perl-Apricot
-
Component/s: Perl
-
Labels:None
Description
Test Build:CUBRID 2008 R4.1 (8.4.1.1018)
OS: Linux 64
Description:
At first using cubrid_lob_get to get value and getting value will fail.
And then using cubrid_lob_export() method to export value.
segment default will appear.d
Repro steps:
1. exectute:
gdb perl
run test2.pl demodb 33000 localhost
bt
statement in test2.pl
$db=$ARGV[0];
$port=$ARGV[1];
$hostname=$ARGV[2];
my $user="dba";
my $pass="";
my $dsn="dbi:cubrid:database=$db;host=$hostname;port=$port";
my $dbh;
$dbh=DBI->connect($dsn, $user, $pass,{RaiseError => 1}) or die "connect error: $dbh->errstr";
$dbh -> do("drop table if EXISTS image_t;") or die "drop error: $dbh->errstr";
$dbh->do("CREATE TABLE image_t (image_id VARCHAR(36) PRIMARY KEY, doc_id VARCHAR(64) NOT NULL, image BLOB);") or die "create error: $dbh->
errstr";
$dbh->do("INSERT INTO image_t VALUES ('image-0', 'doc-0', BIT_TO_BLOB(X'000001'));") or die "insert error: $dbh->errstr";
$dbh->do("INSERT INTO image_t VALUES ('image-1', 'doc-1', BIT_TO_BLOB(X'000010'));") or die "insert error: $dbh->errstr";
$dbh->do("INSERT INTO image_t VALUES ('image-2', 'doc-2', BIT_TO_BLOB(X'000100'));") or die "insert error: $dbh->errstr";
my $sth=$dbh->prepare(" select BLOB_TO_BIT (image) from image_t; ") or die "prepare error: $dbh->errstr";
$sth->execute() or die "execute error: $dbh->errstr";
$sth->cubrid_lob_get(1);
my $err=$dbh->errstr;
print $err ."\n";
$sth->cubrid_lob_export(1,"export1B.txt") or die "cubrid_lob_export error: $dbh->errstr";
$sth->cubrid_lob_export(2,"export2B.jpg") or die "cubrid_lob_export error: $dbh->errstr";
$sth->cubrid_lob_export(3,"~/export3B.jpg") or die "cubrid_lob_export error: $dbh->errstr";
Actual result
(gdb) run test2.pl demodb 33000 localhost Starting program: /home/perl/opt/perl5/bin/perl test2.pl demodb 33000 localhost ........................................................... [Thread debugging using libthread_db enabled] [New Thread 0x2b3d0f964e10 (LWP 21588)] ERROR: CLIENT, -2005, Not a lob type, can only support SQL_BLOB or SQL_CLOB Program received signal SIGSEGV, Segmentation fault. 0x00002b3d1336a174 in cubrid_st_lob_export () from /home/perl/opt/perl5/lib/site_perl/5.14.2/x86_64-linux/auto/DBD/cubrid/cubrid.so (gdb) bt #0 0x00002b3d1336a174 in cubrid_st_lob_export () from /home/perl/opt/perl5/lib/site_perl/5.14.2/x86_64-linux/auto/DBD/cubrid/cubrid.so #1 0x00002b3d13365f69 in XS_DBD__cubrid__st_cubrid_lob_export () from /home/perl/opt/perl5/lib/site_perl/5.14.2/x86_64-linux/auto/DBD/cubrid/cubrid.so #2 0x00002b3d12f552c0 in XS_DBI_dispatch () from /home/perl/opt/perl5/lib/site_perl/5.14.2/x86_64-linux/auto/DBI/DBI.so #3 0x000000000048c0cc in Perl_pp_entersub () #4 0x000000000048a863 in Perl_runops_standard () #5 0x000000000042fa36 in perl_run () #6 0x000000000041bfe5 in main ()
Expect result:
Maybe segment default doesn't appear
Reason:
lob_get() failed before allocating memory buffer, but lob_export() tried to access the unallocated memory buffer, so the segment fault occurred.
Modify dbdimp.c
Committed revision 906.
Fixed.