Front page | perl.perl5.porters |
Postings from February 2000
[ID 20000225.002] malfunction of "die" in special case
From:
Vaclav Ovsik
Date:
February 25, 2000 03:05
Subject:
[ID 20000225.002] malfunction of "die" in special case
Message ID:
Pine.BSF.4.21.0002251125500.16011-100000@ns.i.cz
Hi everybody,
I encounter strange behavior of exception mechanismus under
specific conditions.
When I use CGI.pm module and use strict and file upload is in progres
and I throw exception using die something. The content of exception,
scalar (or ref) thrown by die, is losed.
I tried long time to figure out more specific symptoms by tracking
CGI.pm, but my result is only that occurence of error behavior
is dependent on existence of object TempFile in CGI.pm.
Example cgi script:
==========================
#!/usr/bin/perl
use strict;
use lib '.';
use CGI;
print "Content-encoding: text/plain\r\n\r\n";
print "\$CGI::VERSION == $CGI::VERSION\n";
eval {
my $q = new CGI;
# undef $q; # when undefed object $q, all is OK
die "My exception !";
};
print "After eval: ", $@;
==========================
The script should be called from html form, with _FILLED_ some file to upload.
Example html page:
==========================
<html>
<head>
</head>
<body>
<form action="/cgi-bin/bugtest" enctype="multipart/form-data" method=post>
<input type=file name="somefile">
<input type=submit>
</form>
</body>
</html>
==========================
The eval is only for evidence. You can cut it out, but than you must
look for results into error log of webserver.
When I was trying to analyze problem, I copied the CGI.pm into cgi-bin
directory and modify source.
After following change die works:
--- CGI.pm.Orig Fri Feb 25 11:51:12 2000
+++ CGI.pm Fri Feb 25 11:52:41 2000
@@ -2805,7 +2805,9 @@
# Save some information about the uploaded file where we can get
# at it later.
$self->{'.tmpfiles'}->{$filename}= {
- name => $tmpfile,
+# name => $tmpfile,
+# object $tmpfile (TempFile) is garbage collected
+
info => {%header},
};
push(@{$self->{$param}},$filehandle);
Oh, mistery. I am totaly misunderstanding.
I think, that die tries to discover last file operation, to complete
message with something like 'at chunk ...', but CGI.pm crazy hacks
with filehandles confuse it.
(For this time I undef CGI object before die.)
Used perl:
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
Platform:
osname=linux, osvers=2.2.5-22smp, archname=i386-linux
uname='linux porky.devel.redhat.com 2.2.5-22smp #1 smp wed jun 2 09:11:51 edt 1999 i686 unknown '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='cc', optimize='-O2', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
stdchar='char', d_stdstdio=undef, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lc -lposix -lcrypt
libc=, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under linux
Compiled at Aug 30 1999 23:09:51
@INC:
/usr/lib/perl5/5.00503/i386-linux
/usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/i386-linux
/usr/lib/perl5/site_perl/5.005
.
Used CGI.pm
version 2.46 (with same efect 2.56)
--
Vaclav Ovsik email: Vaclav.Ovsik@i.cz
ICZ a.s. phone: +420 19 7165659
fax: +420 19 7165651
-
[ID 20000225.002] malfunction of "die" in special case
by Vaclav Ovsik