marioroy / mce-perl

Many-Core Engine for Perl
Other
45 stars 5 forks source link

(in cleanup) Can't call method "len" on an undefined value at .../MCE/Child.pm line 542 during global destruction. #22

Closed exodist closed 1 week ago

exodist commented 3 weeks ago

I am getting this in some of my processes:

(in cleanup) Can't call method "len" on an undefined value at .../MCE/Child.pm line 542 during global destruction.

Might make sense to change the line https://metacpan.org/dist/MCE/source/lib/MCE/Child.pm#L542 From: ( exists $_LIST->{$pkg} ) ? $_LIST->{$pkg}->len() : 0; To: ( defined $_LIST->{$pkg} ) ? $_LIST->{$pkg}->len() : 0;

Which should effectively do the same thing, but without the error.

It is also possible I am doing something wrong and need to call a method that clears these out before global destruction?

marioroy commented 3 weeks ago

I am unsure how to reproduce the error. In your code, calling MCE::Child->finish may resolve the issue.

Regardless, I like your suggestion and released MCE 1.898 including MCE::Shared 1.892.

exodist commented 3 weeks ago

I do call MCE::Child->finish() in my code, which is why I was surprised. I am also not usre how to make a reliable reproduction. For me it happens 1 in 100 runs of various tests, all of which are complicated and unfortunately proprietary.

Thanks for the quick release, I will try it out and see if it solves the issue.

marioroy commented 1 week ago

I released MCE 1.900 containing the final fix.