Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Attempt to free unreferenced scalar

by deadpickle (Pilgrim)
on Mar 03, 2009 at 18:20 UTC ( [id://747830]=perlquestion: print w/replies, xml ) Need Help??

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

Well. I'm getting the error
Attempt to free unreferenced scalar: SV 0x316cc3c, Perl interpreter: 0 +x240a4bc a t server.pl line 67.
in my server code. Never seen this before. What scares me is the Perl interpreter part. Any ideas?
#!/usr/bin/perl -w use strict; use IO::Socket; use File::Slurp; use threads; use threads::shared; use XML::LibXML; my $subscribe:shared = 0; my $socket=new IO::Socket::INET->new(PeerPort=>12345,Proto=>'udp',Peer +Addr=>'localhost'); print "This is a test Sending Server\n"; my $capxml = read_file("C:\\Users\\deadpickle\\Desktop\\UAS\\GRRUVI_1. +60\\test xml\\capabilities.xml"); my $recv = threads->new(\&recvxml); my $send = threads->new(\&sendxml); while(1){ } sub sendxml{ my $socket=new IO::Socket::INET->new(PeerPort=>12345,Proto=>'udp', +PeerAddr=>'localhost'); while (1) { #send capabilities every 10 seconds $socket->send($capxml); print "Sending Capabilities\n"; sleep 10; } } sub recvxml{ my $xml; my $kid; my $socket=new IO::Socket::INET->new(LocalPort=>56789,Proto=>'udp' +); while(1) { print "Waiting for message\n"; $socket->recv($xml,3000); print "Recieved Message: $xml\n"; # Parse Message my $parser = XML::LibXML->new; $parser->recover(1); my $doc = $parser->parse_string($xml); my $element = $doc->getDocumentElement; my $elname = $element -> getName(); if ($elname eq 'StreamSubscribe') { my @cap = $element -> childNodes(); foreach $kid(@cap) { $elname = $kid -> getName(); if ($elname eq 'System') { my @syscap = $element -> childNodes(); foreach $kid(@syscap) { $elname = $kid -> getName(); if ($elname eq 'Stream') { my $stream = $kid->textContent; $subscribe = 1 if ($stream eq 'Telemetry') +; $subscribe = 2 if ($stream eq 'Flight Plan +'); } } } } } print "Subscribed to Telemetry\n" if $subscribe == 1; print "Subscribed to Flight Plan\n" if $subscribe == 2; } }

Replies are listed 'Best First'.
Re: Attempt to free unreferenced scalar
by Anonymous Monk on Mar 03, 2009 at 18:29 UTC
      Looks like the problem was that I used the variable $kid repeatedly and all I needed to do was replace the over used variables. A noob error... how embarrassing.
        What is an "overused" variable? More importantly, is an error caused because the variable eventually starts to wear out?
Re: Attempt to free unreferenced scalar
by ikegami (Patriarch) on Mar 03, 2009 at 18:24 UTC

    Threads + XS module = Big Red Flag.

    Is XML::LibXML thread-safe?

    Update: There's a section on multi-threading in its documentation. Does it help?

      I had been using it in the other program with no problems and that program is heavily threaded. I looked at some of the links presented but could not defer much from them, at least at the surface.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://747830]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-19 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found