随机看到 'Stub found while resolving method "???" overloading """" in package "XXX" '

randomly seeing 'Stub found while resolving method "???" overloading """" in package "XXX" '

我们在过去几周内重新定位了我们的服务器并且随机(但经常)收到跟随错误。

dbix 版本现在是 0.082820,之前是 0.08250,没有发生这个错误。

"Stub found while resolving method "???" 在 /home/perlbrew/.perlbrew/libs/perl-5.16.3@latest-20160209/lib/perl5/DBIx/Class/Row.pm 行的包 "XXX" 中重载“” 1250.

包裹 XXX

有哪些可能相关

use Class::Trait qw( TPrintable  );

sub inflate_result {
    my $self = shift;
    my $ret = $self->next::method(@_);
    my $typeCd = $ret->typeCd;
    given ($typeCd) {
        when( $specialTypeCd ) {
            $self->ensure_class_loaded( $specialSubClass );
            bless ($ret, $specialSubClass);
        }
        default {
            bless ($ret, $self);
        }
    }
    return $ret;
}

引入包 XXX 的代码有一个辅助方法:

my $theY = $c->model('DB::Y')->find( $yID,
    {
        prefetch => [ { 'xxxs' => 'typecd' } , 'zid' ]
    });

return $theY;

思考问题是什么;如何使提交错误报告保持一致。

我们已经知道 Abstract.pm 中的潜在解决方法 共 SQLA_ISVALUE_IGNORE_AUTOGENERATED_STRINGIFICATION=1

选择保持匿名的人提出的修复建议 (这对我们的 perl 5.16.3 来说还不够)

我们最终切换到 perl 5.26,问题消失了。 (我们被告知 "You are very unlikely to: 5.18 overhauled a lot of the overload internals.")

diff --git a/lib/SQL/Abstract.pm b/lib/SQL/Abstract.pm
index 264b0b1..b4d8fb4 100644
--- a/lib/SQL/Abstract.pm
+++ b/lib/SQL/Abstract.pm
@@ -104,7 +104,11 @@ sub is_plain_value ($) {
         # "%s"> and the source of overload::mycan())
         #
         # either has stringification which DBI SHOULD prefer out of the box
-        grep { *{ (qq[${_}::(""]) }{CODE} } @{ $_[2] = mro::get_linear_isa( $_[1] ) }
+        grep {
+          *{ (qq[${_}::()]) }{CODE}
+            and
+          *{ (qq[${_}::(""]) }{CODE}
+        } @{ $_[2] = mro::get_linear_isa( $_[1] ) }
           or
         # has nummification or boolification, AND fallback is *not* disabled
         (

为了让您放心:这是实际发生的事情:

perl -e '

    use warnings;
    use strict;

    require Scalar::Util;

    {
      package Some::Overload;
      use overload
        q{""}       => "named_stringifier",
        fallback => 1,
      ;

      sub named_stringifier { $_[0] . "" }
    }

    {
      package Some::Subclass;
      use base "Some::Overload";
    }


    my $thing = bless {}, "Some::Subclass"; 


    {
      no strict "refs";
      grep { *{ (qq[${_}::(""]) }{CODE} } qw( Some::Subclass Some::Overload );
    }


    for (1, 2) {


      # simulates runtime require of some *UNRELATED* class
      eval sprintf <<EOS, $_;
      {
        package Some::UnrelatedThing%s;
        use overload
          q{""} => sub { $_[0] . "" },
          fallback => 1,
        ;
      }
EOS

      my $some_object = bless {}, "Some::Subclass";
    }

    warn "got here, all is well\n";
    exit 0;
'