Hello, I would very much appreciate your answers on the following issue. I have a multi threaded application. Each thread is running a function that creates a perl interpreter and uses it to parse and then run a perl function from an arbitrary file. After running this application for a while the application is stuck and
I can see that 10 threads are in the perl_parse function. An inner looks show that all threads are in the SWIG_Init function created by SWIG. I think it has something to do with the function Swig_TypeClientData but i'm not sure. I'm running on WInXP with perl 5.8.3.809, and I'm using SWIG 1.3.27 to wrap my c++ classes and pass them to the perl functions. Are any of you are familiar with such a problem? Do you have an idea why this can happen? I've attached my function code and marked the line where the threads are "stuck": __declspec(dllexport) long CFTPerlUserExitInstanceRun(char *FileName,char *FuncName,struct PerlParmInfo *ParmsVec,unsigned int ParmsVecSize,char* pReason,int *pCount,int *pUserExitRc) { long lRc = 0; int count = -1; PerlInterpreter* my_perl = NULL; char *embedding[] = { "", FileName}; while (true) { my_perl = perl_alloc(); if (my_perl == NULL) { lRc = -1; break; } EnterCriticalSection(&g_ParserCS); PERL_SET_CONTEXT(my_perl); PL_perl_destruct_level = 1; perl_construct(my_perl); LeaveCriticalSection(&g_ParserCS); // ***************************************************** // THREADS ARE STUCK IN PERL_PARSE // ***************************************************** lRc = perl_parse(my_perl, xs_init, 2, embedding , NULL); if (lRc != 0) { lRc = -2; break; } dSP; ENTER; SAVETMPS; PUSHMARK(SP); // push parms to stack char ParmType[MAX_PARM_TYPE_LEN]; for(unsigned int i=0; i<ParmsVecSize; i++) { strncpy(ParmType, PERL_WRAP_PACKAGE_NAME, MAX_PARM_TYPE_LEN-1); strncat(ParmType, "::", MAX_PARM_TYPE_LEN-3); strncat(ParmType, ParmsVec[i].parmtype, MAX_PARM_TYPE_LEN- strlen(PERL_WRAP_PACKAGE_NAME)-3); SV *pSVParm = sv_newmortal(); sv_setref_pv( pSVParm, ParmType, ParmsVec[i].parm ); XPUSHs(pSVParm); } PUTBACK; try { count = call_pv(FuncName, G_EVAL|G_SCALAR); } catch(...) { lRc = -3; } SPAGAIN; // Check the eval first if (SvTRUE(ERRSV)) { STRLEN n_a; strncpy(pReason, SvPV(ERRSV, n_a), MAX_PERL_REASON_LENGTH-1); //@G1028 lRc = -4; POPs ; } else { if (count != 1) { *pCount = count; lRc = -5; } else { *pUserExitRc = POPi; } } PUTBACK ; FREETMPS ; LEAVE ; break; } if (my_perl != NULL) { EnterCriticalSection(&g_ParserCS); PL_perl_destruct_level = 1; perl_destruct(my_perl); LeaveCriticalSection(&g_ParserCS); perl_free(my_perl); } return lRc; } Thank you very much. Lily.