On Tue, Nov 05, 2002 at 03:03:40PM -0600, Garrett Goebel wrote:
> What is the story behind the CRIMSON_SCOPE_HACK?
>
> I see that it exists for each wheel, that it is meant to prevent SEGV's in
> older versions of Perl, and that it appears to be used at the top of
> anonymous subroutines passed as parameters to $kernel->state(...).
>
> What older versions of Perl?
> How does this prevent SEGV?
>
> sub CRIMSON_SCOPE_HACK ($) { 0 }
> ....
> sub {
> # prevents SEGV
> 0 && CRIMSON_SCOPE_HACK('<');
>
> # subroutine starts here
> ....
Oh, gee, that's ages old. I found this mention of it in POE's
CHANGES:
POE CHANGES/Changes in POE 0.05 54
This version was released on 1999-01-30.
Backed out the change in 0.05_04 where wheels call their event
handlers directly. This causes some sort of stupid closure or
destructor trick (we're still not sure which) that makes perl SEGV on
some systems.
Back to POE CHANGES.
And this:
POE CHANGES/Changes in POE 0.05 56
This version was released on 1999-02-02.
Crimson found the real cause of Perl's coredumps, which allowed the
0.05_54 change to be rolled back.
Back to POE CHANGES.
Unfortunately I didn't have the foresight to log exactly what was
going on at the time or the version of Perl that was affected.
According to http://history.perl.org/ Perl 5.005_03 was released in
March 1999, so we must have been using 5.005_01 or so.
Crimson was the nick of the person who hunted the error down inside
Perl's guts. I asked him about the problem:
Yes, scoping was causing things to fall out of context a tick sooner
than expected, which triggered a realloc bug on some platforms when
not using the built in malloc in Perl.
Adding the definition to the head eliminated the problem because it
delayed release until the sub requested it.
The dynamics behind it were that Perl was inappropriately releasing
the SV* items.
This was fixed, that I know of, in 5.6
There is some dispute over the exact nature of the items being
released, but that's relatively unimportant now that the problem's
fixed.
Unfortunately again, POE supports Perl as far back as 5.004-ish
(although that's slowly being phased out), so it looks like the
CRIMSON_SCOPE_HACK needs to stay for a while.
-- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/