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

well, at least that's what perldiag tells me about this error:

panic: corrupt saved stack index (P) The savestack was requested to restore more localized values than there are in the savestack.
and i got the error from this code:
#!/usr/SD/perl/bin/perl use lib './testlib'; use strict; use ObjTest; use Internal::DBI; my $dbh = logon(); my $sth = $dbh->prepare('select hostname from host'); $sth->execute; my @hosts = map { $_ = $_->[0] } @{ $sth->fetchall_arrayref }[0..20]; foreach my $name ( @hosts ) { my $host = ObjTest->new( name => $name ); my $true = $host->is_router(); print "RETURNED: $name is a router\n\n" if ( $true ); undef $host; } $sth->finish; $dbh->disconnect;

where ObjTest is a new module that uses gethostbyname to get the IP addr of a host, and then creates a new SNMP::Session. the SNMP::Session is then used by the 'is_router' command to get 'whyReload' from the router. like so:

sub is_router { my $self = shift; my $session = $self->{SESSION}; my $varbind = SNMP::VarList->new( [ 'whyReload' , 0 ] ); my $result = $session->get( $varbind ); if ( $session->{ErrorStr} ) { return 0; }; if ( $result =~ /winnt/i ) { return 1; }; }

if the above test program is run for 2 hosts ( i've manually defined @hosts ), i don't see the error. but when i run it for 20 hosts, i get the error EVERY time. and I'm not supposed to see it. . . any ideas on how to make it go away?

Replies are listed 'Best First'.
(Ovid) Re: an internal error you should never see
by Ovid (Cardinal) on Nov 18, 2000 at 05:00 UTC
    This could be a system-dependant error. I can't tell you how to make the code go away, but here's how you start: identify exactly what is causing it. Strip that puppy to a minimal test case. What's the fewest lines code you can use to recreate the error?

    Also, you said you don't get the problem when you run it for 2 hosts, but you do for 20. What about 4 hosts? 5? Once you've nailed down the exact conditions under which the problem occurs, you may be able to find a way to avoid those conditions.

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      i've been able to track down a little.

      i realized that my $host object is NOT going to have the needed elements to continue if I can't instantiate the new SNMP::Session. so I'm putting in checks for that. i've gotten the stack failure on numbers as small as 7 iterations. . .

      i wish i knew for sure where/ what was making it bug out. i've never seen this error type before!

      so, wow! i crashed perl!