Closed Bug 292821 Opened 20 years ago Closed 20 years ago

"Attempt to free unreferenced scalar" running checksetup

Categories

(Bugzilla :: Installation & Upgrading, defect)

x86
Windows XP
defect
Not set
critical

Tracking

()

RESOLVED FIXED
Bugzilla 2.20

People

(Reporter: glob, Assigned: glob)

Details

Attachments

(1 file, 1 obsolete file)

since bug xxx was checked in, on windows running checksetup produces:

Building Schema object from database...
Attempt to free unreferenced scalar: SV 0x27e2eb8 at Bugzilla/DB/Mysql.pm line 605.

stack trace:

Building Schema object from database...
Attempt to free unreferenced scalar: SV 0x27ee4e0 at Bugzilla/DB/Mysql.pm line 605.
Not an ARRAY reference at d:/Perl/site/lib/DBD/mysql.pm line 313.
        DBD::mysql::db::column_info('DBI::db=HASH(0x276a884)', 'undef', 'undef',
'attachments', '%')
 called at Bugzilla/DB/Mysql.pm line 494
       
Bugzilla::DB::Mysql::bz_column_info_real('Bugzilla::DB::Mysql=HASH(0x1d50d14)',
'attachments
', 'thedata') called at Bugzilla/DB/Mysql.pm line 604
       
Bugzilla::DB::Mysql::_bz_build_schema_from_disk('Bugzilla::DB::Mysql=HASH(0x1d50d14)')
calle
d at Bugzilla/DB/Mysql.pm line 204
       
Bugzilla::DB::Mysql::_bz_get_initial_schema('Bugzilla::DB::Mysql=HASH(0x1d50d14)')
called at
 Bugzilla/DB.pm line 774
       
Bugzilla::DB::_bz_init_schema_storage('Bugzilla::DB::Mysql=HASH(0x1d50d14)')
called at Bugzi
lla/DB.pm line 309
        Bugzilla::DB::bz_setup_database('Bugzilla::DB::Mysql=HASH(0x1d50d14)')
called at Bugzilla/DB
/Mysql.pm line 381
       
Bugzilla::DB::Mysql::bz_setup_database('Bugzilla::DB::Mysql=HASH(0x1d50d14)')
called at chec
ksetup.pl line 1584
Attempt to free unreferenced scalar: SV 0x2810b90 at
d:/Perl/site/lib/DBD/mysql.pm line 313.


Checking for             DBI (v1.38)   ok: found v1.48
Checking for      DBD::mysql (v2.9003) ok: found v2.9006


this is most probably a DBI/DBD::mysql issue, however history has shown that
DBI/DBD bugs take a while to get fixed.

we should see if it's possible to work around this issue.
> since bug xxx was checked in, on windows running checksetup produces:

oops.  bug 290402
while writing a simple testcase i was unable to reproduce.

#!/usr/lib/perl
use strict;
use DBI;
use DBD::mysql;
my $attributes = {
  RaiseError => 0,
  AutoCommit => 1,
  PrintError => 0,
  ShowErrorStatement => 1,
  # HandleError => \&_handle_error,
  TaintIn => 1,
  FetchHashKeyName => 'NAME',  
};
my $dbi = DBI->connect(
  "DBI:mysql:host=localhost;database=bugs", 'bugs', '', $attributes
) or exit;
my $info_sth = $dbi->column_info(undef, undef, 'attachments', '%')
  or exit;
my $all_cols = $info_sth->fetchall_hashref("COLUMN_NAME");
my $col_data = $all_cols->{'thedata'};

weird.
however looping over some tables..

use strict;
use DBI;
use DBD::mysql;
use Carp;
$SIG{__DIE__} = \&Carp::confess;
my $attributes = {
  RaiseError => 1,
  AutoCommit => 1,
  PrintError => 1,
  ShowErrorStatement => 1,
  TaintIn => 1,
  FetchHashKeyName => 'NAME',  
};
my $dbi = DBI->connect(
  "DBI:mysql:host=localhost;database=bugs", 'bugs', '', $attributes
)
  or exit;
foreach my $table (qw(attachments bugs profiles boboTheClown)) {
  my $info_sth = $dbi->column_info(undef, undef, $table, '%')
    or exit;
  my $all_cols = $info_sth->fetchall_hashref("COLUMN_NAME");
  my $col_data = $all_cols->{'thedata'};
}
print "ok\n";


Not an ARRAY reference at D:/Perl/site/lib/DBD/mysql.pm line 313.
        DBD::mysql::db::column_info('DBI::db=HASH(0x182be70)', 'undef', 'undef',
'profiles', '%') called at dbi.pl line 19
Attached patch work around v1 (obsolete) — Splinter Review
the problem here is fetchall_hashref; replacing it with code that does the same
task fixes this problem.

i suspect this is related to bug 253696, where selectall_hashref was causing
problems.
Attachment #182592 - Flags: review?(mkanat)
Comment on attachment 182592 [details] [diff] [review]
work around v1

>+    # Don't use fetchall_hashref as there's a Win32 DBI bug (292821)
>+    my $col_data;
>+    while (my $rh = $info_sth->fetchrow_hashref) {
>+        if ($$rh{'COLUMN_NAME'} eq $column) {
>+            $col_data = $rh;
>+            last;
>+        }
>+    }

  I think it'd be easier to just do while ($col_data = ) and skip the $rh
entirely. And then we can just have one "last if" line in the loop.

  Also, I tend to prefer the $rh->{'COLUMN_NAME'} syntax; I think we use that
standardly elsewhere. That's just a nit, though.

  But *man*, thanks for tracking down this bug. :-D I was getting worried there
for a second that we would have to do some much more serious hacks on Win32 to
get this to work.
Attachment #182592 - Flags: review?(mkanat) → review-
Comment on attachment 182592 [details] [diff] [review]
work around v1

Looks great to me.
Attachment #182592 - Flags: review+
r=vladd
Status: NEW → ASSIGNED
> I think it'd be easier to just do while ($col_data = ) and skip the $rh
> entirely. And then we can just have one "last if" line in the loop.

if i do it that way and the column doesn't exist, won't the function return the
data for the last column instead of undef?
(In reply to comment #8)
> if i do it that way and the column doesn't exist, won't the function return the
> data for the last column instead of undef?

  No, the while fails because $col_data is undef. :-)
Attached patch work around v2Splinter Review
Attachment #182592 - Attachment is obsolete: true
Attachment #182642 - Flags: review?(mkanat)
Comment on attachment 182642 [details] [diff] [review]
work around v2

Looks good to me! :-)
Attachment #182642 - Flags: review?(mkanat) → review+
Flags: approval?
Comment on attachment 182642 [details] [diff] [review]
work around v2

I prefer the first version, but this works as well.
Attachment #182642 - Flags: review+
Flags: approval? → approval+
Target Milestone: --- → Bugzilla 2.20
Checking in Bugzilla/DB/Mysql.pm;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/DB/Mysql.pm,v  <--  Mysql.pm
new revision: 1.19; previous revision: 1.18
done
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: