Entry tags:
S2 constant errors
With global warnings on, some permutation of these lines shows up in the log whenever I hit an S2 page:
Constant subroutine S2::PROPS redefined at /usr/share/perl/5.8/constant.pm line 103.
Constant subroutine S2::STATIC redefined at /usr/share/perl/5.8/constant.pm line 103.
Constant subroutine S2::VTABLE redefined at /usr/share/perl/5.8/constant.pm line 103.
Any ideas as to why this might be happening?
Constant subroutine S2::PROPS redefined at /usr/share/perl/5.8/constant.pm line 103.
Constant subroutine S2::STATIC redefined at /usr/share/perl/5.8/constant.pm line 103.
Constant subroutine S2::VTABLE redefined at /usr/share/perl/5.8/constant.pm line 103.
Any ideas as to why this might be happening?
no subject
man perldiag
which told me to look at the "Constant Functions" section inman perlsub
.And I think that what that means is that since constants are inlined for efficiency, redefining the constant on the fly, won't update the places it had previously been inlined into at compile-time.
We could silence it in the same way that we silence "Subroutine redefined" in Apache::LiveJournal, but, assuming that what my understanding in the second paragraph is correct, this might result in some strange behavior, until we restart apache.
Another alternative: silence the warnings, but if a constant may have been redefined because its file was reloaded, print out one warning "Constants may have been redefined; restart web server" or something? It only affects dev servers so we can afford to restart servers as much as wanted.
no subject
no subject
no subject
no subject
You can see it if you, e.g., touch $LJHOME/cgi-bin/DW/InviteCodes.pm; when that is reloaded, you get all the warnings about the constants in there.
no subject
$io->writeln("package S2;");
$io->writeln("use strict;");
$io->writeln("use constant VTABLE => 0;");
$io->writeln("use constant STATIC => 1;");
$io->writeln("use constant PROPS => 2;");
$io->writeln("register_layer($this->{'layerID'});");
I think that results in the constants being redefined every time an S2 layer is loaded? Removing the lines had no immediate effect; I think all the layers would have to be recompiled as well?
no subject
no subject
Edit: which is to say, yes, since they're there, I wouldn't see any harm with removing the lines from BackendPerl.pm. But when I tried that, the warnings didn't disappear immediately.
no subject
no subject
So after trying that, I'm still seeing the redefined constants twice per S2 lastn page call and once per every other S2 page call. Since S2.pm is loaded in LJ::S2 and LJ::S2::EntryPage, I think they are still being reloaded by mod_perl every time, even though the files haven't changed.
no subject
no subject
update s2compiled2 set compdata=replace(compdata,'use constant VTABLE => 0;\nuse constant STATIC => 1;\nuse constant PROPS => 2;\n','');
That seems to have done the trick, phew.