develooper Front page | perl.perl5.porters | Postings from January 2015

[perl #123683] Magical change in perl >= 5.21.7?

Thread Previous | Thread Next
From:
Steve Hay
Date:
January 27, 2015 14:16
Subject:
[perl #123683] Magical change in perl >= 5.21.7?
Message ID:
rt-4.0.18-14108-1422368156-291.123683-75-0@perl.org
# New Ticket Created by  Steve Hay 
# Please include the string:  [perl #123683]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123683 >


Testing modperl (svn trunk, not the current CPAN release) with httpd-2.4.10 and recent 5.21.x perls I find that things look ok up to and including 5.21.6, but the mod_perl-enabled server fails to start with 5.21.7 and 5.21.8.

This function in modperl_util.c is where things go wrong:

U16 *modperl_code_attrs(pTHX_ CV *cv) {
    MAGIC *mg;    

    if (!SvMAGICAL(cv)) {
       sv_magic((SV*)cv, (SV *)NULL, PERL_MAGIC_ext, NULL, -1); 
    }

    mg = mg_find((SV*)cv, PERL_MAGIC_ext);
    return &(mg->mg_private);
}

The cv passed in comes from cv = get_cv(name, FALSE) where name is "main::add_my_version".

SvMAGICAL(cv) is true so sv_magic() is not called, and then mg_find() returns NULL and things all go wrong from there.

The "main::add_my_version" in question is this in modperl_extra.pl:

sub test_add_version_component {
    Apache2::ServerUtil->server->push_handlers(
        PerlPostConfigHandler => \&add_my_version);

    sub add_my_version {
        my ($conf_pool, $log_pool, $temp_pool, $s) = @_;
        $s->add_version_component("world domination series/2.0");
        return Apache2::Const::OK;
    }
}

If I move sub add_my_version {} outside of sub test_add_version_component {} like this:

sub test_add_version_component {
    Apache2::ServerUtil->server->push_handlers(
        PerlPostConfigHandler => \&add_my_version);
}

sub add_my_version {
    my ($conf_pool, $log_pool, $temp_pool, $s) = @_;
    $s->add_version_component("world domination series/2.0");
    return Apache2::Const::OK;
}

then SvMAGICAL(cv) is now false so sv_magic() is called, and then mg_find() returns non-NULL and all is well.

Is this an expected change in behaviour between 5.21.6 and 5.21.7 that mod_perl needs to keep up with, or a bug in 5.21.7?

(I haven't tried the latest bleadperl yet, but I don't see anything since 5.21.8 that looks like it would affect this.)


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About