I've run into a strange error recently and wanted to see if anyone else had come across this.

Basically, I have have a set of database handles created as globals in the HTML::Mason::Commands namespace. To use these, we assign them to an object. i.e.:

my $obj = new Foo;
$obj->{my_dbh} = $my_dbh;
...

Sometimes a mason component will need to make use of more than one of these exported global database handles. To achieve this, I did the following...

for my $dbhname (qw(some other handles)) {
  eval "\$obj->{${dbhname}_dbh} = \$${dbhname}_dbh;";
}

In essence:
  $obj->{some_dbh} = $some_dbh;
  $obj->{other_dbh} = $other_dbh;
  $obj->{handles_dbh} = $handles_dbh;


Randomly this will throw a segfault.

Just for kicks, I tried:

for my $dbhname (qw(some other handles)) {
eval "\$obj->{${dbhname}_dbh} = \$HTML::Mason::Commands::${dbhname}_dbh;";
}

Magically, no more segfaults.

I'm sure that this issue has probably been fixed in later versions (ours is very old), but just wanted to give a heads up in case someone else ran into this issue.

Rob

Reply via email to