Solved (very odd!?) was: Losing a file handle in perl

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Tue Dec 14 14:28:40 UTC 2004


On Mon, Dec 13, 2004 at 09:08:00PM -0500, Madison Kelly wrote:
> This has to be the oddest bug I ever came across... it's fixed, and I'll 
> write what happened in case it helps someone later:
> 
> After sending this message I tried to look at the source of the page 
> being displayed (web-interface). The very, very odd thing was that the 
> source was for an entirely different page from what was being displayed. 
> The source was the source you would see when you first start the program 
>  before you have logged in even though what was being displayed was a 
> page from within the program (where it displays partition information). 
> The actual, current partition information was being rendered and 
> displayed by the browser but the source was different anyway. This was 
> try after clearing the cache and even in a separate browser that I had 
> never run the program in.
> 
> I also tried closing and re-opening the file handle after returning to 
> the main script but that didn't help as well. So, not knowing what else 
> to try, I started temporarily deleting chunks of code until the problem 
> went away. Doing this I narrowed the problem down to, of all things, a 
> simple variable that I wasn't using any more. The oddest part is that 
> the string variable ($tspace) is not used or called anywhere anymore. It 
> -should- have simply been empty or null.
> 
> Once I changed it to use the proper string variable name 
> ($image_name{'tspace'}) the problem went away, the right source was 
> shown in the browser and the logs started working again.
> 
> Can anyone explain how this could happen?

Are you using mod_perl in apache?  Or are you running perl cgi instead?

mod_perl like other perl accelerators do NOT reinitialize variables to
NULL/0 each time a script is run and don't reparse the script each time,
to save cpu time and hence speed things up.  This can make sloppy
programs misbehave (and most perl programs are sloppy).

Lennart Sorensen
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list