|
This section outlines all known problems that exist in the call_* functions.
- 1.
-
If you are intending to make use of both the G_EVAL and G_SCALAR flags in your code,
use a version of Perl greater than 5.000. There is a bug in version 5.000 of Perl which
means that the combination of these two flags will not work as described in the section FLAG
VALUES.
Specifically, if the two flags are used when calling a subroutine and that subroutine
does not call die, the value returned by call_* will be wrong.
- 2.
-
In Perl 5.000 and 5.001 there is a problem with using call_* if the Perl sub you
are calling attempts to trap a die.
The symptom of this problem is that the called Perl sub will continue to completion,
but whenever it attempts to pass control back to the XSUB, the program will immediately
terminate.
For example, say you want to call this Perl sub
sub fred
{
eval { die "Fatal Error" ; }
print "Trapped error: $@\n"
if $@ ;
}
|
|
via this XSUB
void
Call_fred()
CODE:
PUSHMARK(SP) ;
call_pv("fred", G_DISCARD|G_NOARGS) ;
fprintf(stderr, "back in Call_fred\n") ;
|
|
When Call_fred is executed it will print
Trapped error: Fatal Error
|
|
As control never returns to Call_fred, the "back in Call_fred"
string will not get printed.
To work around this problem, you can either upgrade to Perl 5.002 or higher, or use the
G_EVAL flag with call_* as shown below
void
Call_fred()
CODE:
PUSHMARK(SP) ;
call_pv("fred", G_EVAL|G_DISCARD|G_NOARGS) ;
fprintf(stderr, "back in Call_fred\n") ;
|
|
|
|