houseabsolute / HTML-Mason

High-performance, dynamic web site authoring system
https://metacpan.org/release/HTML-Mason/
Other
9 stars 18 forks source link

Change in Perl 5 blead triggers failures in t/13-errors.t #33

Closed jkeenan closed 1 year ago

jkeenan commented 2 years ago

A change in Perl 5 blead has begun to trigger test failures in HTML-Mason's test suite. These failures have been reported as a "Blead Breaks CPAN" issue to Perl's issue tracker as https://github.com/Perl/perl5/issues/20291. For a sample CPANtesters failure report, see http://www.cpantesters.org/cpan/report/a00f2282-32c1-11ed-bfe4-38c706b3d53a.

The test failures look like this:

$ uname -mrs
FreeBSD 12.3-RELEASE-p1 amd64
$ bleadperl -v | head -2 | tail -1
This is perl 5, version 37, subversion 4 (v5.37.4 (v5.37.3-297-g5d56ab3b35)) built for amd64-freebsd-thread-multi
$ bleadperl -V:config_args
config_args='-des -Dusedevel -Uversiononly -Dprefix=/home/jkeenan/testing/blead -Dman1dir=none -Dman3dir=none -Duseithreads -Doptimize=-O2 -pipe -fstack-protector -fno-strict-aliasing';
$ bleadprove -vb t/13-errors.t
...
ok 19 - content_comp_wrong_error
# Running top_level_compilation_error (#20): Make sure top-level compiler errors work in output mode
# Got ...
# -----
# Error during compilation of /usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/mason_tests/22823/comps/errors/top_level_compilation_error:
# syntax error at /usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/mason_tests/22823/comps/errors/top_level_compilation_error line 2, near ";"
# 
# Stack:
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/mason_tests/22823/comps/errors/top_level_compilation_error:2]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Interp.pm:817]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Interp.pm:445]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Request.pm:250]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Request.pm:212]
#   [/home/jkeenan/testing/blead/lib/perl5/site_perl/5.37.4/Class/Container.pm:275]
#   [/home/jkeenan/testing/blead/lib/perl5/site_perl/5.37.4/Class/Container.pm:353]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Interp.pm:348]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Interp.pm:342]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Tests.pm:528]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Tests.pm:515]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Tests.pm:456]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Tests.pm:263]
#   [t/13-errors.t:12]
# 
# 
# Stack:
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Interp.pm:450]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Request.pm:250]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Request.pm:212]
#   [/home/jkeenan/testing/blead/lib/perl5/site_perl/5.37.4/Class/Container.pm:275]
#   [/home/jkeenan/testing/blead/lib/perl5/site_perl/5.37.4/Class/Container.pm:353]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Interp.pm:348]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Interp.pm:342]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Tests.pm:528]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Tests.pm:515]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Tests.pm:456]
#   [/usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Tests.pm:263]
#   [t/13-errors.t:12]
# 
# -----
#    ... but expected ...
# -----
# (?^s:Error during compilation((?!Stack:).)*Stack:((?!Stack:).)*$)
# -----
not ok 20 - top_level_compilation_error

#   Failed test 'top_level_compilation_error'
#   at /usr/home/jkeenan/.cpan/build/HTML-Mason-1.59-0/blib/lib/HTML/Mason/Tests.pm line 593.
# Running component_error_handler_false (#21): Test error-handling with component_error_handler set to false
ok 21 - component_error_handler_false

I'm not familiar with this distribution's test suite, but this may be a case where a regression test has an overly rigid expectation of what error output the perl interpreter will produce. If so, then the test could be skipped or modified to be more lenient with respect to the output expects.

However, the plot thickens. The output that the test was expecting (and that up until now perl was presumably producing) may in itself have been buggy. This even newer ticket in the Perl 5 bug queue should be examined: https://github.com/Perl/perl5/issues/20296.

Thank you very much. Jim Keenan

demerphq commented 2 years ago

This is a sort of half-your-bug-half-our-bug kind of bug. :-)

The half our bug part is that in any existent perl eval STRING may fail to compile in such a way that it does or does not trigger the $SIG{__DIE__} handler in place when the eval started. If the way that the compilation fails tiggers a Perl_croak() internally then $SIG{__DIE__} is triggered, and only certain error types will trigger a Perl_croak at all, and sometimes only after there have been more than a certain threshold of errors. In some cases compilation "can run off the end of the source" without encountering enough errors to trigger the Perl_croak(), in which case $SIG{__DIE__} is not triggered. (I have a patch to fix this in https://github.com/Perl/perl5/pull/20357).

This means any code that uses $SIG{__DIE__} to upgrade errors into exception objects will not get triggered reliably by eval STRING, and $@ will not end up with an object inside of it consistently.

The code that fails with the stop on first error is testing evaling a snippet that does NOT trigger $SIG{__DIE__} in older perls, but which does trigger $SIG{__DIE__} in the latest perl. This is causing the code to end up with an object, which it isnt expecting and the code gets confused. But even without the latest perl slightly different code would produce the same result.

So the "half-your-bug" part is that the test is testing for only one possibly existing eval failure mode, and it does not test the other one, which happens to fail outright. Essentially you are only testing the first of the following two cases:

$ perl -le'$SIG{__DIE__}=sub { print "in __DIE__"; }; eval "1+;"; print $@'
syntax error at (eval 1) line 1, at EOF

$ perl -le'$SIG{__DIE__}=sub { print "in __DIE__"; }; eval "1+;" x 10; print $@'
in __DIE__
syntax error at (eval 1) line 1, at EOF
syntax error at (eval 1) line 1, at EOF
syntax error at (eval 1) line 1, at EOF
syntax error at (eval 1) line 1, at EOF
syntax error at (eval 1) line 1, at EOF
syntax error at (eval 1) line 1, at EOF
syntax error at (eval 1) line 1, at EOF
syntax error at (eval 1) line 1, at EOF
syntax error at (eval 1) line 1, at EOF
syntax error at (eval 1) line 1, at EOF
(eval 1) has too many errors.
demerphq commented 1 year ago

Ping?

autarch commented 1 year ago

Thanks for the reminder. This is fixed in 1.60.