Пропустить навигацию.
Главная

KNOWN PROBLEMS

This section outlines all known problems that exist in the perl_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 perl_call_* will be wrong.

2. In Perl 5.000 and 5.001 there is a problem with using perl_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) ;
perl_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 perl_call_* as shown below

void
Call_fred()
CODE:
PUSHMARK(SP) ;
perl_call_pv("fred", G_EVAL|G_DISCARD|G_NOARGS) ;
fprintf(stderr, "back in Call_fred\n") ;

Perl — высокоуровневый интерпретируемый динамический язык программирования общего назначения, созданный Ларри Уоллом, лингвистом по образованию. Название языка представляет собой аббревиатуру, которая расшифровывается как Practical Extraction and Report Language «практический язык для извлечения данных и составления отчётов». Первоначально аббревиатура состояла из пяти символов и в таком виде в точности совпадала с английским словом pearl, жемчужина. Но затем стало известно, что такой язык существует (см. PEARL) и букву «а» убрали. Талисманом языка Perl является верблюд — не слишком красивое, но очень выносливое животное, способное выполнять тяжёлую работу.