perl_parse and multi threading

Discussion in 'Perl Misc' started by lililevy@hotmail.com, Aug 1, 2006.

  1. Guest

    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 I'm having a deadlock and
    I can see that 10 threads are in the perl_parse function.
    I'm running on WInXP with perl 5.8.3.809.
    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.parmtype, MAX_PARM_TYPE_LEN-
    strlen(PERL_WRAP_PACKAGE_NAME)-3);

    SV *pSVParm = sv_newmortal();
    sv_setref_pv( pSVParm, ParmType, ParmsVec.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.
     
    , Aug 1, 2006
    #1
    1. Advertising

  2. Hello,

    wrote:
    > 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 I'm having a deadlock and
    > I can see that 10 threads are in the perl_parse function.
    > I'm running on WInXP with perl 5.8.3.809.
    > Are any of you are familiar with such a problem? Do you have an idea
    > why this can happen?
    >


    Try to ask in perl.xs. I think they have more experience regarding this
    issues.

    regards,
    Reinhard
     
    Reinhard Pagitsch, Aug 3, 2006
    #2
    1. Advertising

  3. -berlin.de Guest

    Reinhard Pagitsch <> wrote in comp.lang.perl.misc:
    > Hello,
    >
    > wrote:
    > > 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 I'm having a deadlock and
    > > I can see that 10 threads are in the perl_parse function.
    > > I'm running on WInXP with perl 5.8.3.809.
    > > Are any of you are familiar with such a problem? Do you have an idea
    > > why this can happen?
    > >

    >
    > Try to ask in perl.xs. I think they have more experience regarding this
    > issues.


    What is perl.xs? It's not a Usenet group.

    Anno
     
    -berlin.de, Aug 3, 2006
    #3
  4. Dr.Ruud Guest

    -berlin.de schreef:
    > Reinhard Pagitsch:
    >> lililevy:


    >>> 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 I'm having a deadlock and
    >>> I can see that 10 threads are in the perl_parse function.
    >>> I'm running on WInXP with perl 5.8.3.809.
    >>> Are any of you are familiar with such a problem? Do you have an idea
    >>> why this can happen?

    >>
    >> Try to ask in perl.xs. I think they have more experience regarding
    >> this issues.

    >
    > What is perl.xs? It's not a Usenet group.


    You can find it as such at news://nntp.perl.org/perl.xs
    and at several other mail2news-gateways.

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, Aug 3, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    38
    Views:
    1,319
    Dennis Lee Bieber
    Feb 15, 2005
  2. Replies:
    9
    Views:
    1,125
    Mark Space
    Dec 29, 2007
  3. Steven Woody
    Replies:
    0
    Views:
    474
    Steven Woody
    Jan 9, 2009
  4. akineko
    Replies:
    3
    Views:
    2,730
    Jesse Noller
    Jan 29, 2009
  5. Jan Engelhardt

    perl_parse() crashes with no apparent reason

    Jan Engelhardt, Oct 14, 2004, in forum: Perl Misc
    Replies:
    0
    Views:
    243
    Jan Engelhardt
    Oct 14, 2004
Loading...

Share This Page