Fun with Threads - "Attempt to free unreferenced scalar during globaldestruction."

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default Fun with Threads - "Attempt to free unreferenced scalar during globaldestruction."

    My aim is to have a module, "ToolsThread", which I can pass commands to so
    that it'll execute them in its own thread. However when I call join on the
    thread, it seems to all go wrong. It all behaves as normal up to the point
    I call join on the thread in the quit function, then it gives me the
    message

    Attempt to free unreferenced scalar during global destruction.

    I'm not sure what that means, but I don't like it.

    Here is the relevant code (ToolsThread.pm is the module, testToolsThread
    is a basic test script. I would have more code in the loop eventually,
    assuming I can get it to work)

    ##ToolsThread.pm
    package ToolsThread;

    use strict;
    use warnings;
    use threads;
    use threads::shared;
    use Thread::Queue;

    our $queue = new Thread::Queue;
    our $thread = threads->create(\&Run,$queue);

    sub Run{
    my $queue = shift;
    while(1){
    my $incoming = $queue->dequeue;
    if ($incoming eq "quit"){
    last;
    }
    }
    }

    sub Quit{
    $queue->enqueue('quit');
    $thread->join();
    }

    ##testToolsThread.pl
    use strict;
    use warnings;
    use threads;
    use threads::shared;
    use Thread::Queue;
    use ToolsThread;

    ToolsThread::Quit;

    Stuart Moore Guest

  2. Similar Questions and Discussions

    1. HELP - User threads "Waiting on a buffer"
      All, We are running into an issue with IDS 7.31.UD4 engine. We are running some load testing against our applications, and we notice that...
    2. Previous "existing" threads suddenly missing?
      I found a Fireworks thread in Google that was dated September 30th: ...
    3. CLI connection failed. SQL30082N Attempt to establish connection failed with security reason "24"
      Hi, have you found the failure? Because I'm now in the same situation and don't know how to go on??? :( Thanks Originally posted by Prince...
    4. SQL30082N Attempt to establish connection failed with security reason "24"
      I have a DB2 8.1.2 (fixpack 2) client connecting to a DB2 7.2.7 (fixpack 9) server. The DB2 7.2.7 instance is configured with the following...
    5. Older "Free" license for OSR502+?
      After about a 3 year hiaties from OSR50x, I have decided to come back to it; but I can not find anything relating to the Free Unix program that was...
  3. #2

    Default Re: Fun with Threads - "Attempt to free unreferenced scalar during global destruction."

    Stuart Moore <stjm2@hermes.cam.ac.uk> wrote in message news:<Pine.SOL.4.44.0306271347280.25299-100000@orange.csi.cam.ac.uk>...
    > My aim is to have a module, "ToolsThread", which I can pass commands to so
    > that it'll execute them in its own thread. However when I call join on the
    > thread, it seems to all go wrong. It all behaves as normal up to the point
    > I call join on the thread in the quit function, then it gives me the
    > message
    >
    > Attempt to free unreferenced scalar during global destruction.
    >
    > I'm not sure what that means, but I don't like it.
    >
    > Here is the relevant code (ToolsThread.pm is the module, testToolsThread
    > is a basic test script. I would have more code in the loop eventually,
    > assuming I can get it to work)
    >
    > ##ToolsThread.pm
    > package ToolsThread;
    >
    > use strict;
    > use warnings;
    > use threads;
    > use threads::shared;
    > use Thread::Queue;
    >
    > our $queue = new Thread::Queue;
    > our $thread = threads->create(\&Run,$queue);
    # change to this (I don't know why it is like this though)
    our $thread = threads->create("Run",$queue);
    >
    > sub Run{
    > my $queue = shift;
    > while(1){
    > my $incoming = $queue->dequeue;
    > if ($incoming eq "quit"){
    > last;
    > }
    > }
    > }
    >
    > sub Quit{
    > $queue->enqueue('quit');
    > $thread->join();
    > }
    >
    > ##testToolsThread.pl
    > use strict;
    > use warnings;
    > use threads;
    > use threads::shared;
    > use Thread::Queue;
    > use ToolsThread;
    >
    > ToolsThread::Quit;
    Bryan Castillo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139