develooper Front page | perl.perl5.porters | Postings from February 2000

[ID 20000225.002] malfunction of "die" in special case

Vaclav Ovsik
February 25, 2000 03:05
[ID 20000225.002] malfunction of "die" in special case
Message ID:
Hi everybody,

I encounter strange behavior of exception mechanismus under
specific conditions.
When I use 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, but my result is only that occurence of error behavior
is dependent on existence of object TempFile in

Example cgi script:

    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:
    <form action="/cgi-bin/bugtest" enctype="multipart/form-data" method=post>
     <input type=file name="somefile">
     <input type=submit>

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 into cgi-bin
directory and modify source.
After following change die works:

    --- Fri Feb 25 11:51:12 2000
    +++      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},

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 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:
    osname=linux, osvers=2.2.5-22smp, archname=i386-linux
    uname='linux 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
    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

version 2.46 (with same efect 2.56)

	Vaclav Ovsik		email:
	ICZ a.s.		phone: +420 19 7165659
				fax:   +420 19 7165651 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About