Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
the script is crashing perl with the following messsage.

Hm. Mixing up the trace output from your program with the error message (and posting it without <code></code> blocks so all the newlines get eaten by the html) makes life difficult for those of whom you are asking for help.

The actual message you are receiving is just:

Free to wrong pool 49c7480 not 163ea8, <FILE> line 5 during global des +truction.

And the first thing to say about that is it isn't "a crash". This is an informational message issued only when the program has ended and Perl is freeing up the memory used by the program.

Essentially, the program is finished, done and dusted, -- whether it has worked or not is a different matter -- and Perl has detected an anomaly in its usage of memory whilst cleaning up. It is telling you that you may want to look more closely at it, but it isn't actually crashing; and the program may have completely correctly despite that anomaly.

What the message is telling you is that a piece of memory that was allocated by one thread; is being freed within the context of another thread. Whilst that can cause problems within your program; the fact that it is only being detected "during global destruction" often means that it didn't prevent the program from working or completing.

Now to the possible causes of that anomaly.

The usual cause of this cross-over of memory from one thread to another is accidental closure of a thread subroutine over a variable created (explicitly or implicitly) within the main thread code. And there are two main ways for that to happen.

  1. Non-shared, lexical (my) variables declared in your main thread, and re-used (without re-declaration) within thread subroutines.

    I do not see any of these in your code.

    This can often happen accidentally when thread subroutines are position at the end of the file. You use (and properly declare) a variable within your main program; and then re-use the name within the subroutine, but forget to declare it locally, and thus you get an accidental closure with no warnings.

    My tip for avoiding this is to put your subroutines -- especially those use as threads; but it works for all subroutines -- at the top of your program before your main line code.

    It flies in the face of certain conventions; but it is the conventions that are flawed here.

  2. The use of package-scoped, non-lexical variable -- ie. variables used but not declared with my -- within subroutines used as threads.

    Your thread procedure has two of these:

    Global symbol "$pingit" requires explicit package name at l +ine 81. Global symbol "$colItems" requires explicit package name at + line 91.

You also have several other variables that you haven't declared with my:

Global symbol "$linecount" requires explicit package name at 1018589.p +l line 21. Global symbol "$row" requires explicit package name at line + 23. Global symbol "$line" requires explicit package name at lin +e 24. Global symbol "$mainparam" requires explicit package name at 1018589.p +l line 28. Global symbol "$thr0" requires explicit package name at lin +e 29. Global symbol "$thr1" requires explicit package name at lin +e 33. Global symbol "$thread_count" requires explicit package name at 101858 line 53. Global symbol "$pingit" requires explicit package name at l +ine 67. Global symbol "$colItems" requires explicit package name at + line 97. had compilation errors.

These would all be caught for you by use strict;

So, my suggestions to you are:

  1. Add use strict; to the top of your program.

    And then eliminate all those errors by declaring all your variables with my.

  2. Move your GetTimeZone() subroutine to the top of your program.

    Just before print "Starting main program\n"; would be good.

Then try re-running your program. The chances are that those two simple changes will make the problem 'go away', but if they do not, come back and post your modified code and we can try to help you further.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
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.

In reply to Re: WMI query with Threads by BrowserUk
in thread WMI query with Threads by vamsinm

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (7)
    As of 2017-10-18 17:56 GMT
    Find Nodes?
      Voting Booth?
      My fridge is mostly full of:

      Results (250 votes). Check out past polls.