Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what is "Attempt to free unreferenced scalar"?

Status
Not open for further replies.

lichtjiang

Programmer
Feb 26, 2007
39
US
I got the following message when one of my perl program exits (it runs multiple threads simultaneously, it has several variable of typess of Thread::Queue and Thread::Semaphore):

Attempt to free unreferenced scalar: SV 0x84f0c00, Perl interpreter: 0x8362c78 during global destruction.

What does this mean and how to track it? Thanks!
 
Hi lichtjiang,

That "sounds" like a Perl bug - Are you running the latest version?

Mike

Hardware is that part of a computer which, when you remove electrical power, doesn't go away.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Thanks.

mine is "v5.8.8 built for i686-linux-thread-multi" on gentoo linux.

there is known bug similar to this? not very sure

I will have to check my code when I have time later ...
 
forgot to mention that I have 4 threads in total. 3 of them used those queues and semaphores. and there were 3 such message reports for them. no report for the remaining one, which just passed queues and semaphores as arguments.

so, more like some problem w/ my code ...
 
Hi lichtjiang,

How are you getting on with this?

If you're still having problems can I suggest that you write as simple and short a script as possible which shows the errors you're seeing.

This will give you a chance to see clearly where any problems might lie and will also (hopefully) give you a script short enough to be posted here should you need to.

Mike

Hardware is that part of a computer which, when you remove electrical power, doesn't go away.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Thanks. Mike. That's what I'm thinking to isolate the problem code and find out what is wrong. But just working on other things and didn't find a time for this.

I will do this and post whatever I will find later ...
 
Suppose we have "A.pl" and "B.pm" as follows.

_A.pl_
...
my $dummy;
threads->create("B::c", ($dummy));
...


_B.pm_
...
sub c{...}
...

"Scalars leaked:" occurs for each ref or a hash (replace $dummy with %dummy in above script) that is passed as argument to "B::c".

"Attempt to free unreferenced scalar" always happens in above example when we pass a variable (of any type) in one process to a sub in another module when it is run as a thread.

So, is this a problem of my script or a bug or some friendly message that can be safely ignored? Any comments? Thanks!
 
Forgot to mention,

"Attempt to free unreferenced scalar" happened for each thread called in the way shown above.
 
Hi,

If you say:

my $dummy = 1;
threads->create("B::c", ($dummy));

does that still give you an error?

Mike

Hardware is that part of a computer which, when you remove electrical power, doesn't go away.

Want great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Yes. In all cases that either message was reported, all arguments (scalar, array, hash and their refs) passed to thread "B::c" have been initialized. In "B::c", it also doesn't matter if those arguments appear as lef-side or right-side (the semaphore and queue definitely change their content and I also tried not to use any argument in "B::c" or just print out some scalar or size of some non-scalar.).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top