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

Re: [perl #126145] Problem with stack moving fix forPerl_load_module

Thread Previous | Thread Next
Dave Mitchell
October 6, 2015 13:31
Re: [perl #126145] Problem with stack moving fix forPerl_load_module
Message ID:
On Wed, Sep 23, 2015 at 11:21:00AM -0700, Michael Schout wrote:
> Since upgrading to 5.20, we started seeing our modperl process crash
> while pre-compiling a long list of modules in our code.  We have a chunk
> of code that uses File::Find and converts the filenames it finds into
> module names, then uses Class::Load to load each module in turn:
>   for my $mod (@modules) {
>       unless (is_class_loaded($mod)) {
>           eval "require $mod;";
>       }
>    }

It appears to be a bug in Sub::Attribute (note that this modules is at
v0.05 and was least released 5 years ago, so it might not be actively

At one point it does:

    PL_stack_sp -= call_sv(method, G_VOID | G_EVAL);

If the stack happens to to be grown and reallocated during the call to
call_sv(), then the new value of PL_stack_sp is overwritten with the
*old* value less whatever call_sv returns.

It probably needs to be rewritten as:

    I32 retcount;

    retcount = call_sv(method, G_VOID | G_EVAL);
    PL_stack_sp -= retcount;

or possibly

    retcount = call_sv(method, G_VOID | G_EVAL | G_DISCARD);

Music lesson: a symbiotic relationship whereby a pupil's embellishments
concerning the amount of practice performed since the last lesson are
rewarded with embellishments from the teacher concerning the pupil's
progress over the corresponding period.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About