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

I just rolled some new functionality into our production server (which runs on mod_perl) and I'm receiving errors from my use base statement, in which I'm using multiple inheritance to utilize a mix-in class. Here's what I'm seeing:

Could not process that_module in that_method: Can't multiply inherit %FIELDS at /usr/local/perl5.8.6/lib/5.8.6/base.pm line 103

I don't have a problem with this in development and I can't reproduce it even when I run my development server in mod_perl with just one child process (I'm thinking this is a mod_perl issue). I dug into base.pm to figure out what's going on and it seems there's a conflict with the %FIELDS hashes of the base classes. But I'm not doing anything with %FIELDS or using the fields pragma.

I'm not sure what other specific context would be useful short of posting thousands of lines of code and I can't post a simple example, as I can't reproduce this in development. I'm hoping someone has some wisdom on what tends to trigger this error.

Any help appreciated.

Replies are listed 'Best First'.
Re: Problems with multiple inheritance
by Zaxo (Archbishop) on Feb 23, 2007 at 17:28 UTC

    perldoc base reveals that multiple inheritance of fields is not supported.

    That's ok, multiple inheritance requires detailed knowledge of the parent classes and great caution. So much that most perlers discourage its use.

    I say go for it, but you'll need to forget the convenience of base.pm and friends and work it up from scratch. You'll gain a sure knowledge of the properties of your new class.

    Update: From following my links above, it appears that recent perl now supports multiple inheritance with base.pm. The denial of that was from my perl 5.8.4, and I suspect you're using an older version as well. If you hit resistance to updating perl, my advice still stands.

    After Compline,
    Zaxo

Re: Problems with multiple inheritance
by perrin (Chancellor) on Feb 23, 2007 at 17:22 UTC
    If you can't reproduce it in development, figure out what's different about your production server. Is it running the same version of perl? Does it have the same version of base.pm? Did you restart the server, or was it something like Apache::Reload that loaded the module?

      I'm running the same versions of perl and base. The production server has had the modules Apache::Reload-ed (I don't have control over restarting the server) and I was actually wondering if it might have had something to do with the fact that Apache::Reload doesn't necessarily reload things in any particular order, right? But I haven't had problems using mixin-type multiple inheritance like this in the past, and I'm doing very similar things that are also working just fine along side this new functionality, literally using the same base and mixin class, just extending them slightly differently in the concrete implementation class.

      I haven't used Apache::Reload in development because I have control over that server and I need to actually figure out how to get that working. We reload via script in production so I'm not intimately familiar with the process. I'll let you know if I can reproduce it that way, although I'm not hopefully, as I Apache::Reload-ed the modules on our QA servers which are identical to production and failed to reproduce the problem.

        Apache::Reload sounds like a red flag to me. Perl doesn't actually have any way to reload modules, so all that Apache::Reload does is delete it from %INC and require it again. In my opinion, it's crazy to use Apache::Reload in production. It will cause strange problems and will bloat the memory usage because it ruins copy-on-write sharing. It's meant for development only.