On Sun, Sep 07, 2003 at 10:42:17AM -0700 Jan Dubois wrote:
> On Sun, 07 Sep 2003 18:40:59 +0200, Tassilo von Parseval
> <[EMAIL PROTECTED]> wrote:

> >I'll do a few tests and see whether not using G_EVAL can produce
> >inconsistent results. I guess that
> >
> >    if (SvTRUE(ERRSV)) croak(Nullch);
> >
> >would then fix them. Thanks for warning me!
> 
> The problem typically only manifests in a little more complicate
> scenarios.  That is, when the Perl code that calls your XS wraps the call
> in an eval {} block and the Perl code called from your XS dies.  Then Perl
> (at least used to) get confused about stack frames.
> 
> You may want to take a look at this p5p thread:
> 
> http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&th=5b781e81ad8dd07&seekm=20020630130739.1394.2%40bactrian.elixent.com&frame=off

Oh! This thread shows that this has already gained some fame (infame,
rather) among those having enough experience with it.

> I have some code where even exiting the Perl interpreter must not
> terminate the hosting process, so in addition to always passing G_EVAL I
> also wrap the call in a JMPENV block (to catch exit() etc).  And I put the
> whole thing inside a try/catch block (in C++) to catch them if they call
> another XS extension from their Perl code, and they have an access
> violation in there.  Still doesn't protect against user code calling
> POSIX::_exit(), but then it is their own fault. :)
> 
> All that will be overkill for your situation, but I still think that not
> using G_EVAL from XS is dangerous because you typically don't remember to
> recheck your calls when you later change the called code.

Yes, it's definitely overkill in that a die() in the callback should
indeed just terminate the whole program. But I don't want to produce
segfaults or so if someone uses eval{} with it in a too smart and
imaginative way (the cited thread mentions such coredumps).

Thanks everyone for all those pointers! I am a little wiser now. :-)

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval

Reply via email to