bpphillips has asked for the wisdom of the Perl Monks concerning the following question:
Hello - We have a random, recurring bug here at $work that is boggling my mind. Occasionally, when a bit of code tries to delegate to its SUPER class, the package name is somehow off by one random letter. Here's an example of the error message we're getting:
Can't locate object method "new" via package "MyCompany::Oages::TemplateConstants::SUPER" at MyCompany::Pages::TemplateConstants::new
This error is triggered by the following (slightly abbreviated) code:
package MyCompany::Pages::TemplateConstants; use strict; use warnings; use base qw(MyCompany::Interfaces::Object); # don't ask, it's lega +cy code sub new { my $class = shift; my $self = $class->SUPER::new(); # <--- randomly fails ... return $self; }
At the line where SUPER::new is called, the error is triggered. This code is executed thousands of times per day successfully but about once per day, it fails with the error listed above. The error varies slightly but there is always one letter in the class name that is "decremented" by one letter. In the specific case I pasted above, the P is turned into an O but it could be any letter in the class name. For instance, I've seen the following failures as well (in different classes but the same symptom):
MyCompany::Pages::TemplateObjectWraoper::SUPER
vs.
MyCompany::Pages::TemplateObjectWrapper::SUPER
or
MyCompany::Pages::TemplateAbcount::SUPER
vs.
MyCompany::Pages::TemplateAccount::SUPER
I can't understand how the value of $class would allow code execution to get into the correct new method but then when calling $class->SUPER::new it no longer provides the correct class to allow the @ISA traversal to work. In some instances, the invocant is a class name (i.e. $class as shown above) but in other times, it's a blessed reference (i.e. $self). The same error pops up in either case.
I'm not sure it's related to an incorrect @ISA but we are not (knowingly) modifying the contents of any classes @ISA array. I've grep'd through all of the CPAN modules we're using and I can't find anything that fiddles with a packages @ISA at this level (although I don't really know what to grep for in compiled C extensions).
I have not had the opportunity yet to put debugging code in our production environment to try and track down more specifically the state of $class/$self or @ISA. Are there any other bits of data that might be helpful to log in troubleshooting this issue?
We are using Perl v5.12.2.
Can anyone think of any possibilities for what is causing this bug?
Thanks for any help you might offer!
|
|---|