|Syntactic Confectionery Delight|
Temp file handles refcount bug?by ELISHEVA (Prior)
|on Mar 14, 2011 at 20:06 UTC||Need Help??|
ELISHEVA has asked for the
wisdom of the Perl Monks concerning the following question:
Today while testing code I ran across an error that was new to me: "Attempt to free unreferenced scalar: SV 0x8238030, Perl interpreter: 0x817b008 during global destruction.". I've been able to isolate the issue to the code at the end of this post.
It seems to be due to some interaction between tied handles, select, temporary file handles created by File::Temp, and number of lines of code in the module(!). Merely by commenting out one line of code in a method that is never even called, I can make Perl stop complaining for 2 of the 3 complaining cases.
I'm guessing this is a Perl bug because commenting out a line that is never executed shouldn't change the behavior of a script, but I'd like another set of eyes. Is this just on my build/platform: Debian (Lenny) - system perl (5.10.0)? Am I using something in a way that was never intended and so confusing perl?
As can be seen from the script below, I've tried a number of different types of file handles (string backed, plain, STDOUT, STDERR, permanent temp files) and the only kind of handle that consistently shows a problem is a runtime only temp file: i.e. a nameless temp file handle or a named file handle that is supposed to go away when the program dies.
Also I'm curious what is the Perl interpreter doing that it is so sensitive to a line commented out? Memory corruption? Something else?
The test script I'm using is posted below.