Closed GoogleCodeExporter closed 9 years ago
Great analysis! We really need to improve our should_save() logic, looking at
%INC, and not if it's later used.
We cannot reliable catch such method calls, and the risc is too high missing
those. Only internally used packages might be skipped, never external packages.
Original comment by reini.urban
on 17 Jun 2014 at 9:50
I've attached a patch which resolves the issue in both the original, isolated
test case provided above, as well as an issue affecting cPanel production
systems.
Rationale:
Given the example packages Foo and Foo::Bar as illustrated in the body of my
original post, when calling should_save() when passing Foo, should_save()
should not prevent Foo from being stored in %dumped_package simply because it
is in a parent namespace to one of the modules it is considering optimizing
out, in this case Foo::Bar.
Ordinarily, Foo would have already been stored in %dumped_package, but its
first usage (as illustrated in foo.pl) was evaluated in a deferred way inside
an anonymous subroutine, leaving should_save() the first chance for Foo to
reached %dumped_package. This patch ensures Foo is stored in %dumped_package
by preventing Foo from being optimized out simply because Foo::Bar exists in
%include_package; when evaluating Foo::Bar, if Foo exists in %include_package
already, then Foo should be kept in %dumped_package.
This patch is ideal because:
1. It works regardless of how the package was introduced into Perl; either
inline or from an external file
2. If a program references code in Foo::Bar, which in turn use()s Foo, but no
code in Foo is ever touched, then Foo::Bar will remain, but Foo will still be
optimized out.
Original comment by erin.schoenhals
on 19 Jun 2014 at 10:12
Attachments:
Erin, don't want to come up with a testcase (t/issue348.t) and a git patch
also? foo.pl misses Foo::new still
Original comment by reini.urban
on 23 Jun 2014 at 1:56
I uploaded the incorrect test file when reporting my analysis. The correct
file is below. The main difference is that I forgot to declare the package Foo
at all, instead declaring a package called Cat. Changing the sample provides a
better illustration of the issue and the corresponding fix.
Original comment by erin.schoenhals
on 30 Jun 2014 at 8:56
Attachments:
348.patch in my earlier comment appears to function 100% of the time, when
compiling the newly-uploaded test case above.
Original comment by erin.schoenhals
on 30 Jun 2014 at 9:06
Original comment by todd.e.rinaldo
on 1 Jul 2014 at 6:46
A pretty good version if dumping all previously missed modules is now in the
branch `walkall`
Original comment by reini.urban
on 2 Jul 2014 at 2:25
Fails currently (walkall 2ca2bbf) only for threaded.
Considering Foo
...
And because Foo is not in %INC we don't dump it. Which is wrong.
Original comment by reini.urban
on 3 Jul 2014 at 3:32
Fixed in master with commit 0e09a80d18fd9487231f224dc78d54206d7ab418
Author: Reini Urban <rurban@cpanel.net>
Date: Mon Jun 23 11:03:48 2014 -0600
C 1.47_03: revised walkall, dump_rest at inc_cleanup
Original comment by reini.urban
on 3 Jul 2014 at 8:38
Original issue reported on code.google.com by
erin.schoenhals
on 17 Jun 2014 at 8:32Attachments: