Jobius has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on a fairly large database-driven HTML::Mason application, and seeing this error show up in the log files, seemingly at random:

Bizarre copy of HASH in aassign at /usr/local/lib/perl5/site_perl/5.8.0/Devel/StackTrace.pm line 67

That's StackTrace 1.03, and line 67 simply says "my @a = @DB::args". What's really weird is that I can't figure out where/how Devel::StackTrace is even getting pulled in.

The box is running RedHat 9, Apache/1.3.27, mod_perl/1.27.

I'd paste in some code, but there's really quite a lot of it, and it doesn't die in the same place consistently. Can anybody recognize what's going on, despite the skimpiness of the report?

Replies are listed 'Best First'.
Re: Mason app dies with "Bizarre copy of array in aassign"
by BrowserUk (Patriarch) on Sep 23, 2003 at 01:55 UTC

    Scant info to go on, but maybe this will help some.

    Devel::StackTrace is called from Exception::Class::Base which is a part of Exception::Class which is used by HTML::Mason.

    Working back from the other end, the actual error message you are seeing is being raised in sv.c (line 3734 in 5.8.1-rc4) in the function Perl_sv_setsv_flags(). The stated purpose of this function (although it can be called from the perl sources and/ or XS code under the guise of several macros) is to copy one scalar to another. The situation in which it raises this error is when it encounters a source scalar that is a reference to a HASH/ARRAY/CODE/IO. It doesn't explain why this is considered bizarre, but it's probably obvious to those (few) that understand it:).

    In the most generic sense, it would appear that an exception is being raised inside Mason and it is in the process of trying to generate a stack trace, and specifically, trying to get a copy of the arguments (DB::args) to the function (or probably method) that was called before the exception was raised, and it is during the process of copying these args from an array in the DB package to a local array that it encounters a scalar that is a reference which is considered an error, either because of the time when it is being copied, or because of the method being used to copy it.

    Beyond this purely circumstantial evidence, there's not much more that can be identified until you can identify the code at your end that is causing the exception to be raised. Looking at the sample you posted in your follow up, it looks some sort of linked list is being set up. The archetypical error with this sort of code is that somewhere, a node in the link list gets linked back to itself and the next time a search or insert occurs, it starts looping around forever. Total speculation, but I think that's about the best you hope for given the sparsity of the info.

    To try and debug this further, you either need to re-create the problem whilst running under the debugger, which is a PIA to do for a webapp, or you need to litter warn statements through your app. Starting at the highest level, isolate where the Bizzarre msg is coming from and track it in function by function, line by line until you find where your leaving your code, and with what parameters, prior to the msg.

    The fact that the exception reporting mechanism is itself riasing an exception is decidedly unhelpful:), and is probably something that the author of most of the modules I listed above, Dave Rolsky would be interested in. Of course, he'd prefer a 5 line script that demonstrated the problem along with your bug report, but it might be worth contacting him even without that as this miight be something he has encountered before.

    It would also be worth ensuring that you are running the latest version of Mason and its dependancies and that the error still exists, before you do make contact though, as that's almost certainly the first question you will be asked.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

Re: Mason app dies with "Bizarre copy of array in aassign"
by BrowserUk (Patriarch) on Sep 23, 2003 at 03:20 UTC

    An afterthought, but possibly a significant one. The error could be right there in Devel::StackTrace.

    The code in question is trying to get the arguments that were passed to a sub from DB::args, but it doesn't check to see if there were any args passed to the sub (frame) in question.

    Try modifying the line in the error message to read:

    my @a = $c[4] ? @DB::args : ();

    and see if the problem goes away.

    Logic: From Perlfunc:caller()

    ...$hasargs is true if a new instance of @_ was set up for the frame....

    Furthermore, when called from within the DB package, caller returns more detailed information: it sets the list variable @DB::args to be the arguments with which the subroutine was invoked.

    It doesn't say what the state of DB::args will be if $hasargs wasn't set. Making the attempt to get conditional upon $hasargs returned from caller ($c4) will exclude this possibility.

    In the unlikely chance that this does affect a cure, be sure to report the problem and fix to the author.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

Re: Mason app dies with "Bizarre copy of array in aassign"
by autarch (Hermit) on Sep 23, 2003 at 05:06 UTC
    Is this the version of RedHat that includes a version of Perl pulled directly from the repository, and not the real 5.8.0?

    If so, you're SOL because I've given up supporting RedHat's idiotic decisions to ship beta/dev software. Try installing a real 5.8.0 and see if the bug goes away.

    OTOH, if it is a real Perl 5.8.0, a recipe to reproduce this would be welcome. But please send it to me via email.

Re: Mason app dies with "Bizarre copy of array in aassign"
by Jobius (Acolyte) on Sep 23, 2003 at 00:53 UTC

    A bit more information: the errors always seem to happen when I make a method call (pump from IPC::Run, or some of our internal module methods). The data structures used in the vicinity of where I'm seeing frequent errors are extremely, um, baroque. A few representative lines:

    ${$children->[0]->{'harness'}}->{'next'} = $inUse; $children->[0]->{'harness'} = $inUse; $inUse = $$inUse->{'next'}; ${$children->[0]->{'harness'}}->{'next'} = undef;

    Please note that I didn't write this code, and would rather rewrite it than debug it, but that may not be an option right now.

Re: Mason app dies with "Bizarre copy of array in aassign"
by krisahoch (Deacon) on Sep 23, 2003 at 16:39 UTC
    Jobius,
        I get this and similiar messages whenever I try to do something silly like accessing the 5th element of a hash (which only happened once). Other times are when I try to use a variable that has gone out of scope or a typo'd variable name. Why don't you post the code and the full output (USE README TAGS) so that we can take a better look at it.
     
    Thanks,
    Kristofer.
Re: Mason app dies with "Bizarre copy of array in aassign"
by Anonymous Monk on Sep 23, 2003 at 16:42 UTC
    It seems the fellows using AxKit ran into a similar problem. See here about 1/4 way down the page. They have a link to a patch from the perl5-porters mailing list. I don't know if you are running perl 5.6.0 though, so this may not be very helpful.