Dave Mitchell [Tue, 6 Dec 2016 23:45:35 +0000 (21:45 -0200)]
Handle self destruction manually
A slightly modified version of the failing test code is as follows:
use Variable::Magic qw<wizard cast>;
my $wiz2 = wizard;
my $wiz1 = wizard free =>
sub { warn "recasting\n"; &cast($_[0], $wiz2); die ; };
warn "result of eval = [" . eval {
my $v = do { my $val = 123; \$val };
study;
&cast($v, $wiz1);
warn "just at end of eval\n";
} . "]\n";
warn "just after eval\n";
On 5.24.0, this gives:
just at end of eval
recasting
result of eval = []
recasting
just after eval
The mortal RV that is created to temporarily point at the scalar being
freed (the IV(123) above) to pass to the free method, isn't initially
freed, and is only freed by the FREETMPS in the nextstate following the
eval. When freed, it triggers another free of the IV(123), which although
it should now be under the influence of $wiz2 rather than $wiz1, it still
calls the 'free' anon sub (I don't understand why its still called, and I
haven't looked into it).
The TEMP not getting freed until after the statement following the eval is
the bug my blead patch was supposed to fix (which it does), but which
caused infinite recursion.
My fix avoids making the temporary mortal RV a TEMP on the tmps stack,
and instead stores a pointer to it in the vmg_svt_free_cleanup_ud struct.
This RV is then manually freed in both the normal and exception cleanup
paths.
Vincent Pit [Tue, 6 Sep 2016 21:33:16 +0000 (18:33 -0300)]
Skip len magic test on negative indices on recent perls
Starting from perl 5.25.4, this does not cause len magic to be triggered
anymore. It has been temporarily reverted from the core, but is likely to
come back, so this should appease the smokes.
Vincent Pit [Thu, 1 Oct 2015 13:09:17 +0000 (10:09 -0300)]
Execute magic callbacks into separate stacks
When magic triggered, stack corruption could occur since the magic callback
arguments were passed on the same stack as the ambient one. This issue has
long gone unnoticed because most ops first unpack their stack arguments
before processing magic, but also because this module is mostly used in
practice to capture magic outside of the usual program op structure were
the argument stack is relevant.
This was made visible with core change 6442877a (publicized in perl 5.22.0)
which caused get magic on transliterations to happen on the same C argument
list as a PUSHmortal. This resulted in an undefined behaviour which was
usually resolved by the magic being processed first (for example by gcc),
but cl.exe on win32 prefers to execute the PUSHmortal first, hence the
stack was corrupted.
Vincent Pit [Fri, 25 Sep 2015 10:54:47 +0000 (12:54 +0200)]
Improve support for custom ops
This was added to the core in commit 1830b3d9, which was publicized in perl
5.13.7. Note that our version is slightly different but simpler, since I
can't see how the op type might change during the call to OP_CLASS().
Vincent Pit [Fri, 25 Sep 2015 10:09:04 +0000 (12:09 +0200)]
Represent nulled COPs as B::COP objects
This change was added to the core B.xs in commit 619dadb5, which was made
public in perl 5.21.7. It is pretty unlikely that magic will ever be called
for these nulled ops, but it is better to keep our chunk of B.xs in sync
with the core.
Vincent Pit [Tue, 21 Jul 2015 15:09:57 +0000 (12:09 -0300)]
Simplify the timeout logic in t/09-load-threads.t
The old loop could actually never be executed more than one iteration.
A real good implementation would check whether any of the peers has exited,
but it would involve much more work.
Vincent Pit [Thu, 9 Apr 2015 18:12:26 +0000 (15:12 -0300)]
Don't lock the VMG_LOADED mutex across global destruction
If this mutex falls back to the OP_REFCNT mutex, and that a coderef is
freed during global destruction, the mutex is taken twice and the process
hangs. As a general rule, it does not seem very safe so we just set
vmg_loaded to zero early and only run the global teardown callback if
it is zero. This ensures that this callback will only be called once.
Vincent Pit [Wed, 8 Apr 2015 12:24:50 +0000 (09:24 -0300)]
Reference-count global setup/teardown
This fixes surprises like this one : module loaded in thread 1, then in
thread 2, then thread 1 ends and now the module does not work anymore in
thread 2 (even though it should).
Vincent Pit [Tue, 24 Mar 2015 19:54:30 +0000 (16:54 -0300)]
Update the ActivePerl/gcc-3.4 hack for EUMM 7.04
Starting from this version, PERL_ARCHIVE is quoted so we can no longer set
it to the empty string. Instead, we remove all occurrences of PERL_ARCHIVE
in the linking step section of the Makefile, which is OK since we specify
the perl DLL in other variables. This new technique is still valid for
older versions of EUMM.
Vincent Pit [Tue, 6 Aug 2013 03:23:30 +0000 (00:23 -0300)]
Get rid of t/99-kwalitee.t
New versions started to throw warnings if specific environment variables
are not set. This may be appropriate for dist manager users, but not really
for the rest of the world.
Since kwalitee metrics are either obvious or useless, there's no big loss
in removing this test anyway.
Vincent Pit [Fri, 2 Nov 2012 00:27:25 +0000 (22:27 -0200)]
Don't run the POD spelling test in taint mode
This causes the test to crash on perl 5.12 and below with sensitive
architectures like FreeBSD. Ultimately the root of the issue seems to have
been https://rt.perl.org/rt3/Public/Bug/Display.html?id=60378.