mukeshp has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

We had the script userprops.t which was running fine in 5.22.1 version, but after upgrading to cpan 5.24.3, we see following error :- "Certificatefailed2() failed with error -2. The interface now has an additional optional argument. at ..userprops.t line 62".

Here is the snapshot of userprop.t which call following function.
62 ($data[0],$len[0]) = $users[0]->Certificate(); 63 if(!(defined $data[0]) && !(defined $len[0])) {print "ok 5\n";} els +e {print "not ok 5\n";};
The below is the corresponding sample .XS function for this call:-
void Certificate(pSelf,...) t_testapi_usrcreds * pSelf PPCODE: int certBinaryLen = 0; int ret = 0; char* certificate = NULL; // look for optional returnCode arg SV *rval = ST(3); InitError(items, 3, rval); if (items > 2){ certificate = SvPV_nolen(ST(1)); certBinaryLen = (int)SvIV(ST(2)); if(certificate) { /* Cert is to be set */ }else{ /* Couldn't properly read an argument */ HandleError("Certificate1", items, 3, rval, -1); XSRETURN_UNDEF; } } if(!pSelf->credStruct.lpszCertBinary){ /* The certificate data is not set. */ HandleError("Certificatefailed2", items, 3, rval, -2); XSRETURN_UNDEF; } /* Return certificate currently set */ EXTEND(SP,2); PUSHs(sv_2mortal(newSVpv(pSelf->credStruct.lpszCertBinary,0))); PUSHs(sv_2mortal(newSViv((IV)pSelf->credStruct.nCertBinaryLen ) +)); XSRETURN(2);
void HandleError(char *func, int numArgs, int errorArg, SV *errorSV, i +nt errorCode) { if (numArgs==errorArg+1 && !SvREADONLY(errorSV)) { // new interface: set return code sv_setiv(errorSV, errorCode); } else { // old interface: die with error code and deprecation notifica +tion croak("%s() failed with error %d. The interface now has an add +itional optional argument.", func, errorCode); } }

It is failing when call is returning undef XSRETURN_UNDEF. Does the XSRETURN_UNDEF handling got changed in 5.24.3 version or.? How come the croak changed with upgradation of perl. How to come over this error, this breaking at multiple places in our scripts.

Replies are listed 'Best First'.
Re: cpan 5.24.3 The interface now has an additional optional argument
by Corion (Patriarch) on Feb 06, 2018 at 12:21 UTC

    What module are you talking about?

    From the error message, it seems that the module does not like being called with the deprecated interface that the module itself documents. This seems to be triggered by the Certificatefailed2 part of the code, which is triggered by this check:

    pSelf->credStruct.lpszCertBinary

    This likely means that whatever is stored in pSelf resp. pSelf->credStruct is empty (well, contains a null pointer). The output of the error message via HandleError feels somewhat misleading, but as I don't know the module and API that you are trying to access that is hard to judge.