Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

CGI::Application file upload Assertion error with Data::Dumper

by gman (Friar)
on Dec 18, 2009 at 17:17 UTC ( [id://813400]=perlquestion: print w/replies, xml ) Need Help??

gman has asked for the wisdom of the Perl Monks concerning the following question:

Hello

I am building a web application based on CGI::Application. Also using Plugin::Session to keep session state. In one run mode of the application users are allow to upload a file. I am also saving session state in my post run using:

sub cgiapp_postrun { my $self = shift; #die Dumper($self); $self->session->save_param(); $self->session->flush(); }

my session Driver is file and I believe therefor uses Data::Dumper. Anytime I try to either Dump the session data using Dumper() or hit the pst run I get the following error:

Assertion ((buffer)->sv_flags & 0x00000400) failed: file "sv.c", line +1741 at /usr/lib/perl5/5.10.0/i386-linux-thread-multi/Data/Dumper.pm +line 190

Also if I die $q->param('bulk_upload'); the field is not populated. bulk_upload is the name of my upload field.

Has anyone seen this? I found this http://www.nntp.perl.org/group/perl.perl5.porters/2009/05/msg146341.html but don't know enough to know if this is the same issue.

Thanks in advance,

Cory

UPDATE:

perl 5.10.1 installed, getting same error, but found this post

post

Talks about deleting the FH pointer in the session, I have both

$self->session->clear(['bulk_upload']);and $q->param('bulk_upload','' +); $self->session->clear('bulk_upload');

funny thing is it gets past this the first time, and if I clear the CGI session file,

_SESSION_REMOTE_ADDR' => '10.10.192.63','bulk_file' => bless( \*{'Fh:: +fh000018yy_import.txt'}, 'Fh' ),'_SESSION_CTIME' => 1261427840,'bntsu +bmit' => 'Upload File','_SESSION_ATIME' => 1261427915,'bulk_upload' = +> '','authen_loginbutton' => 'Sign In','Agree' => 'Agree','_SESSION_E +XPIRE_LIST' => {}};;$D[rootvi /var/www/chkdwn/cgi-bin/Sup*/Index.pm

After that I get the following Do not know how to reconstitute blessed object of base type GLOB

UPDATE: PROBLEM SOLVED

on the advice from ikegami and others, of not including the CGI upload FH in the session data. I realized that the CGI param had to be copied to a variable and removed from the CGI param list before the CGI::Session config

Here is what the I had to do in the CGI::Application setup stage.

my $q = $self->query(); $upload_file = $q->param('bulk_file'); $q->param('bulk_file',''); $self->session_config(...

Thanks again to all that helped

Replies are listed 'Best First'.
Re: CGI::Application file upload Assertion error with Data::Dumper
by ikegami (Patriarch) on Dec 18, 2009 at 18:48 UTC

    Do you realize you're running a debug build of Perl? That makes it slower. On the plus side, the checks that it slower is what found the problem and tells us exactly where the problem occurred.

    Specifically, on a blank line. Line 1741 of Perl 5.10.0's sv.c is a blank line.

    You don't appear to running stock Perl. Without having the sources that were used to build your Perl, all we can tell is that some function is supposed to be passed a scalar that contains a string (i.e. a scalar with SVf_POK set), but it was passed something different.

    This is either a bug in Perl, or a bug in an XS module. Try upgrading to Perl 5.10.1. Lots of bugs were fixed in 5.10.1.

    However, there's a good chance it's related to the unresolved bug you mentioned. The file handle fields from CGI are very special. They act as a string or a file handle depending on how you use them. The ticket talks of globs, and globs are closely related to file handles. Can you somehow avoid including this field in the session?

    Update: Added last paragraph.

      I am compiling 5.10.1 now.

      Concerning your last paragraph, I have tried using $self->session->clear('bulk_file') with no luck. Is that what you meant?

      Next step I will build a smaller script using CGI::App & Session and see if I can reproduce, thats if the upgrade does not fix my problem.

      Thanks again for yours and faber's help

        Ok after further testing, once the FH 'bulk_file' => bless( \*{'Fh::fh00001Giant.odt'}, 'Fh' ) is in the cgi session file, things go astray. As stated in my update, which probably should have gone down here, I have tried to clear the 'bulk_upload' FH from the session. I also tried this in the post run with no success.

        Does anyone know of the correct way to delete the FH from the session or a way to force clean up after a "clear"?

        Thanks

Re: CGI::Application file upload Assertion error with Data::Dumper
by faber (Acolyte) on Dec 18, 2009 at 18:32 UTC
    Is this only with die()? have you tried printing to STDERR then exiting?
      Here is what I get with a print STDERR Dumper($q);

      [Fri Dec 18 13:38:44 2009] [error] [client 10.10.192.63] [Fri Dec 18 1 +3:38:44 2009] index.pl: Error executing class callback in postrun sta +ge: Assertion ((buffer)->sv_flags & 0x00000400) failed: file "sv.c", +line 1741 at /usr/lib/perl5/5.10.0/i386-linux-thread-multi/Data/Dumpe +r.pm line 190., referer: http://chkdwn.sipsvoip.net/?rm=bulkImport [Fri Dec 18 13:38:44 2009] [error] [client 10.10.192.63] [Fri Dec 18 1 +3:38:44 2009] Carp.pm: \t(in cleanup) Assertion ((buffer)->sv_flags & + 0x00000400) failed: file "sv.c", line 1741 at /usr/lib/perl5/5.10.0/ +i386-linux-thread-multi/Data/Dumper.pm line 190., referer: <removed>

      Thanks, Cory

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://813400]
Approved by keszler
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-29 11:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found