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

Hi,

I have a threaded program that is occaisonally dieing with

Thread 20 terminated abnormally: panic: COND_SIGNAL (298) at cm.pl line 487. Terminating on signal SIGINT(2)

Doesn't seem to happen in the lab when only using small numbers of equipment, it is happening occaisonally in the field on large numbers.

No real pattern to exactly when it stops as far as I can see.

I can't find any decent documentation on that error message, can anyone point me in the right direction?

Thanks,

Graham

Replies are listed 'Best First'.
Re: Perl Thread Quitting Abnormally
by BrowserUk (Patriarch) on Jul 05, 2010 at 16:13 UTC

    What OS? What version of Perl? What type of "equipment"? How many is "small numbers"? Ditto "large numbers"?

    SIGINT(2) is ^C (on some systems), or could result from a kill 2, $pid from somewhere. On some systems it might be the OS itself terminating the process because it has exceeded some statutory limit or other.

    In a nutshell, if you want useful help with this, you're going to have ante up with considerably more information.

    Chances are, that given sufficient information it will be trivial to fix; but in the mean time you will doubtless get a bunch of "use POE", "use fork" and "threads are broken" advice.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Hi

      Active Perl 5.10 on Windows 2003 Server.

      This is perl, v5.10.0 built for MSWin32-x86-multi-thread (with 3 registered patches, see perl -V for more detail) Copyright 1987-2007, Larry Wall Binary build 1002 283697 provided by ActiveState http://www.ActiveState.com Built Jan 10 2008 11:00:53

      Equipment is microwave radio links, the threaded code uses SNMP_Session to upload inventory statistics via SNMPv1.

      Small is ~20 NEs.

      Large is ~2000NEs.

      The number of threads is controlable via config file, problems have been seen at anywhere between 20 and 50 threads, I'm now trying with fewer threads to see where the problems are.

      I'm the only one logged into the system. Other Perl processes are also running, they are not being affected.

      Thanks

      graham

        Thread 20 terminated abnormally: panic: COND_SIGNAL (298) at cm.pl line 487. Terminating on signal SIGINT(2)

        The error breaks down into several parts:

        1. Thread 20 terminated abnormally:

          Fairly obviously means that thread number 20 was started, but it terminated as a result of something other than return or 'running off the end of the sub'.

        2. panic: COND_SIGNAL (298) at cm.pl line 487.

          This is the reason it terminated. Perl (threads.pm) itself terminated it because of an unexpected internal error condition (panic).

          In this case, the code is executing (either explicitly in your code or implicitly through perl internal code):

          #define COND_SIGNAL(c) \ STMT_START { \ if ((c)->waiters > 0 && \ ReleaseSemaphore((c)->sem,1,NULL) == 0) \ Perl_croak_nocontext("panic: COND_SIGNAL (%ld)",GetLastError() +); \ } STMT_END

          The 298 is the system error code returned by GetLastError after the ReleaseSemaphore() call fails.

          It translates to "Too many posts were made to a semaphore." which is further explained as

          There is a limited number of times that an event semaphore can be posted. You tried to post an event semaphore that has already been posted the maximum number of times.

          If you are making extensive use of threads::shared::cond_* calls in your code, that could be the root of the problem. If you want help in debugging that further, you will have to "show us the code".

          If you are not using the cond_* calls in your code, then it could be that you've unearthed a bug in Perl itself. You might try upgrading your versions of Perl to (say) 5.10.1. And/or your version of threads &| threads::shared.

        3. Terminating on signal SIGINT(2)

          Under most circumstances, this will only occur if you (or someone) types ^C. Did you fail to mention that your application is hanging and you get the above error message only when you interrupt it?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Perl Thread Quitting Abnormally
by Proclus (Beadle) on Jul 05, 2010 at 22:46 UTC
    BrowserUK sees the future. :)

    I will advice you to use POE. But really, I have done extensive amount of SNMP work with POE, and it will most likely make your life much easier.

    Here is the module you need: POE::Component::SNMP

    It may be cryptic at first, but since you have SNMP experience you can correlate.