Re: [mp2] Perl 5.10 fixes from SVN cause SIGBUS on sparc
On Mon, Mar 10, 2008 at 10:53:54PM -0700, Philippe M. Chiasson wrote: > >>Niko Tyni wrote: > >>>We're switching to Perl 5.10 in Debian soon, and I'm trying to update the > >>>mod_perl2 package to keep it working. Unfortunately the ModPerl-Registry > >>>test suite is failing on the Sparc architecture because apache2 is killed > >>>by a bus error (SIGBUS). > How about this s/U16/U32/ diff, basically keeping the flag type at U32, > since it was not an essential part of the fix itself. No, that doesn't help either. It turns out the U16/U32 thing was a bad guess on my part. After some code staring and debugging, I found the real bug. It's not architecture-specific really, it just happens to bite worst on Sparc. The non-void function modperl_thx_interp_get() function is doing a plain 'return;' when it means to 'return NULL;'. The result is that the MP_APR_POOL_SV_TAKES_OWNERSHIP() macro increments a more or less random memory location, in this case my_perl->tScopestack aka. PL_scopestack, making it non-aligned as a side effect. Patch attached; this fixes the bus error for me. Cheers, -- Niko Tyni [EMAIL PROTECTED] Index: src/modules/perl/modperl_interp.c === --- src/modules/perl/modperl_interp.c (revision 635485) +++ src/modules/perl/modperl_interp.c (working copy) @@ -581,7 +581,7 @@ modperl_interp_t *interp; dTHXa(thx); SV **svp = hv_fetch(PL_modglobal, MP_THX_INTERP_KEY, strlen(MP_THX_INTERP_KEY), 0); -if (!svp) return; +if (!svp) return NULL; interp = INT2PTR(modperl_interp_t *, SvIV(*svp)); return interp; }
VC 'library' builds with visual studio
I found this very interesting blog entry by Jim Beveridge about archiving an object library (.lib, or .a for unix-heads) on various flavors of Visual Studio 2005 and later... http://qualapps.blogspot.com/2007/12/winsxs-breaks-old-debug-libraries.html so anything we ship as a lib (which isn't a dynamic library) looks to be next to useless once we adopt a modern version of VC. Bill
mod_perl 2.0 Handler issue
Hello everyone, I am writing my first mod_perl handler. I've looked at some of the docs online and have come up with the config/code below. However, when I go to visit the URL in Apache, I get a download prompt for type: httpd/unix-directory. OS Info: CentOS release 4.6 (Final) Package info: perl-5.8.8-11 httpd-2.0.59-1.el4s1.10.el4.centos mod_perl-2.0.3-1.el4s1.3 Apache config: PerlRequire /etc/httpd/perl/startup.pl SetHandler modperl PerlResponseHandler Myserver::Handler /etc/httpd/perl/startup.pl: use lib qw(/home/Perl/); 1; /home/perl/Myserver/Handler.pm package Myserver::Handler; #Setup some essentials use strict; #strict tolerance for code use Carp; #debugging use diagnostics;#more debugging use warnings; #more debugging #Handler-related stuff use Apache2::RequestRec (); use Apache2::RequestIO (); use Apache2::Const -compile => qw(OK); sub handler { my $self= shift; return Apache2::Const::OK; } 1; -- xyon <[EMAIL PROTECTED]>
Config related to Registry Scripts
I just installed mod_perl and am trying to follow the fast start instructions here: http://perl.apache.org/docs/2.0/user/intro/start_fast.html#Registry_Scri pts I added the following to the apache configuration file...in my case lxtuxa19.conf Alias /perl/ "/home/webperl/" SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI Order allow,deny Allow from all I created a directory called /home/webperl/ and have placed the rock.pl script in it the permissions are: # ls -l /home | grep webperl drwxrwxrwx 3 root root 4096 Mar 12 11:16 webperl # ls -l /home/webperl | grep rock -rwxr-xr-x 1 pjc002 u-unix 94 Mar 12 11:16 rock.pl When I attempt http://lxtuxa19/perl/rock.pl I get HTTP 404 - Page not found. I see the following in the error_log: [Wed Mar 12 11:29:31 2008] [notice]Apache/2.0.50 (Unix) mod_jk/1.2.15 CovalentSNMP/2.3.0 mod_perl/2.0.3 Perl/v5.8.3 configured -- resuming normal operations [Wed Mar 12 11:29:31 2008] [notice] SNMP: CovalentSNMP/2.3.0 started (user '0' - SNMP address '1610' - pid '12586')[Wed Mar 12 11:32:34 2008] [error] slurp_filename('rock.pl') / opening: (2) No such file or directory at /usr/lib/perl5/site_perl/5.8.3/i586-linux-thread-multi/ModPerl/RegistryC ooker.pm line 541 >From looking at the RegistryCooker.pm lines I believe that it can't find my rock.pl file. I am new to apache and have read config docs most of the morning; can anyone spot what is wrong or suggest other config declarations that might be conflicting with this one? Thanks in advance for your help. Paula
Re: mod_perl 2.0 Handler issue
Got it sorted, I forgot I had removed the content_type definition from the handler. It's always the simple things that hang ya up. /home/perl/Myserver/Handler.pm package Myserver::Handler; #Setup some essentials use strict; #strict tolerance for code use Carp; #debugging use diagnostics;#more debugging use warnings; #more debugging #Handler-related stuff use Apache2::RequestRec (); use Apache2::RequestIO (); use Apache2::Const -compile => qw(OK); sub handler { my $self= shift; $self->content_type('text/html'); return Apache2::Const::OK; } 1; On Wed, 2008-03-12 at 12:29 -0400, xyon wrote: > Hello everyone, > > I am writing my first mod_perl handler. I've looked at some of the docs > online and have come up with the config/code below. However, when I go > to visit the URL in Apache, I get a download prompt for type: > httpd/unix-directory. > > > > OS Info: > > CentOS release 4.6 (Final) > > > > > Package info: > > perl-5.8.8-11 > httpd-2.0.59-1.el4s1.10.el4.centos > mod_perl-2.0.3-1.el4s1.3 > > > > > Apache config: > > PerlRequire /etc/httpd/perl/startup.pl > > SetHandler modperl > PerlResponseHandler Myserver::Handler > > > > > > /etc/httpd/perl/startup.pl: > > use lib qw(/home/Perl/); > 1; > > > > > /home/perl/Myserver/Handler.pm > > package Myserver::Handler; > > #Setup some essentials > use strict; #strict tolerance for code > use Carp; #debugging > use diagnostics;#more debugging > use warnings; #more debugging > > #Handler-related stuff > use Apache2::RequestRec (); > use Apache2::RequestIO (); > use Apache2::Const -compile => qw(OK); > > sub handler { > my $self= shift; > return Apache2::Const::OK; > } > > 1; > > >
Re: mod_perl 2.0 Handler issue
xyon wrote: Hello everyone, I am writing my first mod_perl handler. I've looked at some of the docs online and have come up with the config/code below. However, when I go to visit the URL in Apache, I get a download prompt for type: httpd/unix-directory. [snip] try this : sub handler { my $r= shift; # get the Apache Request object $r->content_type('text/html'); # set some Response header $r->print("It works !); # send some content return Apache2::Const::OK; # make Apache happy } In your original version, what happens is : sub handler { my $self= shift; # you get the Request object here # you return no content at all return Apache2::Const::OK; # tell Apache it's OK } I guess that with no content returned (not even HTTP headers), Apache is left to wonder what to return, and returns something to the browser with a funny content type. On the other hand, if in your http config you had : PerlResponseHandler Myserver::Handler->handler then your handler sub should be : sub handler { my $self = shift; # get Myserver::Handler class my $r= shift; # get the Apache Request object $r->content_type('text/html'); # set the Response headers $r->print("It works !); # send some content return Apache2::Const::OK; # make Apache happy } That is because with the Package->sub syntax in the http config, mod_perl sets up the call differently, and calls you sub() as a method. One last tip : If, instead of returning Apache2::const::OK in your handler, you send nothing back but return Apache2::const::DECLINED, then Apache will revert to its own default handler, and send back what it would normally send (probably a directory listing in this case). Hope this helps. André
environment variable
hi, the app i wrote is run under Apache::Registry only. i am wondering if SetEnv/PassEnv will cause any problem in this case (since setenv and passenv only affect %ENV for content generation phase and beyond)? also, a question on apache.. i have tried the following under plain CGI SetEnv PATH xxx SetEnv Qiang xxx and the first one doesn't change PATH env at all. however, the second one show up in ENV. what i am doing wrong here? a backgroug for this question is that i would like to use /usr/local/bin/perl but have /bin/env perl as my shebang line.. thanks. Qiang Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
RE: Config related to Registry Scripts
Kindly Ignore -- solution found It was a conflict with the configuration for mod_jk. Paula
Re: mod_perl 2.0 Handler issue
Hey everyone, I am working on my first Object-Oriented project, and have hit a slight snag. I am using HTML::Template to output within the View module, but it never outputs. I don't see any errors in the logs, I just get a blank page. Below is pertinent information including a test script with its output: OS Info: CentOS release 4.6 (Final) Package info: perl-5.8.8-11 perl-HTML-Template-2.9-1 httpd-2.0.59-1.el4s1.10.el4.centos mod_perl-2.0.3-1.el4s1.3 /home/perl/Myserver/View.pm package Myserver::View; #Setup some essentials use strict; #strict tolerance for code use Carp; #debugging use diagnostics;#more debugging use warnings; #more debugging #Loadup some needed functions use HTML::Template; sub new { my $self= shift; return $self; } sub mainpage { my $self= shift; my $template= HTML::Template->new( filename => '/home/Perl/tmpl/mainpage.tmpl', cache => 1, debug => 1, stack_debug => 1 ); print "Content-Type: text/html\n\n"; $template->output; return $self; } 1; /home/Perl/tests/View_mainpage.pl #!/usr/bin/perl -w # Test printing of the main page print "Main Page.."; #Let's load the view module use lib "../"; use Myserver::View; #Now let's load some things that are very handy use strict; #strict tolerance for code use Carp; #debugging use warnings; #more debugging use diagnostics;#even more debugging # Let's create an object my $view= Myserver::View->new; # Now, let's tell View to display the main page $view->mainpage; print ".OK"; 1; /home/Perl/tmpl/mainpage.tmpl: Test! Output with debugging on (as above): $ tests/View_mainpage.pl ### HTML::Template Debug ### In _parse: ### HTML::Template _param Stack Dump ### $VAR1 = [ \'Test! ' ]; Main Page..Content-Type: text/html ### HTML::Template Debug ### In output ### HTML::Template output Stack Dump ### $VAR1 = [ \'Test! ' ]; .OK Output without debugging: $ tests/View_mainpage.pl Main Page..Content-Type: text/html .OK -- xyon <[EMAIL PROTECTED]>
Custom Object-Oriented Module using HTML::Template
Hey everyone, Firstly, I apologize I sent the previous email under an incorrect subject line. I am working on my first Object-Oriented project, and have hit a slight snag. I am using HTML::Template to output within the View module, but it never outputs. I don't see any errors in the logs, I just get a blank page. Below is pertinent information including a test script with its output: OS Info: CentOS release 4.6 (Final) Package info: perl-5.8.8-11 perl-HTML-Template-2.9-1 httpd-2.0.59-1.el4s1.10.el4.centos mod_perl-2.0.3-1.el4s1.3 /home/perl/Myserver/View.pm package Myserver::View; #Setup some essentials use strict; #strict tolerance for code use Carp; #debugging use diagnostics;#more debugging use warnings; #more debugging #Loadup some needed functions use HTML::Template; sub new { my $self= shift; return $self; } sub mainpage { my $self= shift; my $template= HTML::Template->new( filename => '/home/Perl/tmpl/mainpage.tmpl', cache => 1, debug => 1, stack_debug => 1 ); print "Content-Type: text/html\n\n"; $template->output; return $self; } 1; /home/Perl/tests/View_mainpage.pl #!/usr/bin/perl -w # Test printing of the main page print "Main Page.."; #Let's load the view module use lib "../"; use Myserver::View; #Now let's load some things that are very handy use strict; #strict tolerance for code use Carp; #debugging use warnings; #more debugging use diagnostics;#even more debugging # Let's create an object my $view= Myserver::View->new; # Now, let's tell View to display the main page $view->mainpage; print ".OK"; 1; /home/Perl/tmpl/mainpage.tmpl: Test! Output with debugging on (as above): $ tests/View_mainpage.pl ### HTML::Template Debug ### In _parse: ### HTML::Template _param Stack Dump ### $VAR1 = [ \'Test! ' ]; Main Page..Content-Type: text/html ### HTML::Template Debug ### In output ### HTML::Template output Stack Dump ### $VAR1 = [ \'Test! ' ]; .OK Output without debugging: $ tests/View_mainpage.pl Main Page..Content-Type: text/html .OK -- xyon <[EMAIL PROTECTED]>
Re: Custom Object-Oriented Module using HTML::Template
On Wed, Mar 12, 2008 at 11:02:27PM +, xyon wrote: > Hey everyone, > > Firstly, I apologize I sent the previous email under an incorrect subject > line. > Yes, but you still hijacked another thread. => In-Reply-To: <[EMAIL PROTECTED]> Please don't do that. Start a new thread by sending a new message to the list. Don't just repky some random message and change the subject line. Regards, -Roberto -- Roberto C. Sánchez http://people.connexer.com/~roberto http://www.connexer.com signature.asc Description: Digital signature
Re: Custom Object-Oriented Module using HTML::Template
Roberto � wrote: On Wed, Mar 12, 2008 at 11:02:27PM +, xyon wrote: Hey everyone, Firstly, I apologize I sent the previous email under an incorrect subject line. Yes, but you still hijacked another thread. => In-Reply-To: <[EMAIL PROTECTED]> Please don't do that. Start a new thread by sending a new message to the list. Don't just repky some random message and change the subject line. At least give him credit for showing plenty of diagnostic information. That's something we rarely see with newbies. :) Colin
Re: Custom Object-Oriented Module using HTML::Template
Fixed. I forgot to print the template->output. print $template->output; On Wed, 2008-03-12 at 23:02 +, xyon wrote: > Hey everyone, > > Firstly, I apologize I sent the previous email under an incorrect subject > line. > > I am working on my first Object-Oriented project, and have hit a slight > snag. I am using HTML::Template to output within the View module, but it > never outputs. I don't see any errors in the logs, I just get a blank > page. Below is pertinent information including a test script with its > output: > > > > OS Info: > > CentOS release 4.6 (Final) > > > > > Package info: > > perl-5.8.8-11 > perl-HTML-Template-2.9-1 > httpd-2.0.59-1.el4s1.10.el4.centos > mod_perl-2.0.3-1.el4s1.3 > > > > > /home/perl/Myserver/View.pm > > package Myserver::View; > > #Setup some essentials > use strict; #strict tolerance for code > use Carp; #debugging > use diagnostics;#more debugging > use warnings; #more debugging > > #Loadup some needed functions > use HTML::Template; > > sub new { > my $self= shift; > return $self; > } > > sub mainpage { > my $self= shift; > my $template= HTML::Template->new( filename => > '/home/Perl/tmpl/mainpage.tmpl', > cache => 1, > debug => 1, > stack_debug => 1 ); > print "Content-Type: text/html\n\n"; > $template->output; > return $self; > } > > 1; > > > > > /home/Perl/tests/View_mainpage.pl > > #!/usr/bin/perl -w > > # Test printing of the main page > print "Main Page.."; > > #Let's load the view module > use lib "../"; > use Myserver::View; > #Now let's load some things that are very handy > use strict; #strict tolerance for code > use Carp; #debugging > use warnings; #more debugging > use diagnostics;#even more debugging > > # Let's create an object > my $view= Myserver::View->new; > > # Now, let's tell View to display the main page > $view->mainpage; > > print ".OK"; > > 1; > > > > > /home/Perl/tmpl/mainpage.tmpl: > > Test! > > > > > Output with debugging on (as above): > > $ tests/View_mainpage.pl > ### HTML::Template Debug ### In _parse: > ### HTML::Template _param Stack Dump ### > > $VAR1 = [ > \'Test! > ' > ]; > > Main Page..Content-Type: text/html > > ### HTML::Template Debug ### In output > ### HTML::Template output Stack Dump ### > > $VAR1 = [ > \'Test! > ' > ]; > > .OK > > > > > Output without debugging: > > $ tests/View_mainpage.pl > Main Page..Content-Type: text/html > > .OK > > > >
Re: Custom Object-Oriented Module using HTML::Template
On Wed, Mar 12, 2008 at 07:58:25PM -0400, Colin Wetherbee wrote: > Roberto � wrote: > >On Wed, Mar 12, 2008 at 11:02:27PM +, xyon wrote: > >>Hey everyone, > >> > >>Firstly, I apologize I sent the previous email under an incorrect subject > >>line. > >> > > > >Yes, but you still hijacked another thread. > > > >=> In-Reply-To: <[EMAIL PROTECTED]> > > > >Please don't do that. Start a new thread by sending a new message to > >the list. Don't just repky some random message and change the subject > >line. > > At least give him credit for showing plenty of diagnostic information. > That's something we rarely see with newbies. :) > True. I apologize for overlooking that. Regards, -Roberto -- Roberto C. Sánchez http://people.connexer.com/~roberto http://www.connexer.com signature.asc Description: Digital signature
[Apache::DBI] [PATCH] use PerlChildExitHandler to properly disconnect
This Patch fixes annoying log messages (notably with postgresql, but others may apply) because Apache::DBI fails to disconnect properly at exit time. (it stops the buggers below from filling my logs...) LOG: unexpected EOF on client connection LOG: could not receive data from client: Connection reset by peer Note the first hunk *might* be a bug fix as under MP2 Apache->can('push_handlers') returns false. It does not look (unless im missing something) like the PerlCleanupHandler for AutoCommit rollback ever got registered... (Patch attached as well in case white space damage occurs) applies cleanly against 1.05/1.06 diff -x '*~' -ruN Apache-DBI-1.05.orig/lib/Apache/DBI.pm Apache-DBI-1.05/lib/Apache/DBI.pm --- Apache-DBI-1.05.orig/lib/Apache/DBI.pm 2006-11-03 23:17:44.0 -0700 +++ Apache-DBI-1.05/lib/Apache/DBI.pm 2008-03-12 17:38:37.455592048 -0600 @@ -137,7 +137,7 @@ # script has finished if AutoCommit is off. however, cleanup can only # be determined at end of handle life as begin_work may have been called # to temporarily turn off AutoCommit. -if (!$Rollback{$Idx} and Apache->can('push_handlers')) { +if (!$Rollback{$Idx} and (Apache->can('push_handlers') || MP2)) { debug(2, "$prefix push PerlCleanupHandler"); if (MP2) { my $s = Apache2::ServerUtil->server; @@ -151,6 +151,17 @@ $Rollback{$Idx} = 1; } +if (Apache->can('push_handlers') || MP2) { +debug(2, "$prefix push PerlChildExitHandler"); +if (MP2) { +my $s = Apache2::ServerUtil->server; +$s->push_handlers("PerlChildExitHandler", sub { child_disconnect($Idx) }); +} +else { +Apache->push_handlers("PerlChildExitHandler", sub { child_disconnect($Idx) }); +} +} + # do we need to ping the database ? $PingTimeOut{$dsn} = 0 unless $PingTimeOut{$dsn}; $LastPingTime{$dsn} = 0 unless $LastPingTime{$dsn}; @@ -236,6 +247,26 @@ 1; } +sub child_disconnect { +my $Idx = shift; + +my $prefix = "$$ Apache::DBI"; +debug(2, "$prefix PerlChildExitHandler"); + +if ($Connected{$Idx}) { +cleanup($Idx); + +{ +package Apache::DBI::db; +eval { $Connected{$Idx}->SUPER::disconnect(); }; +delete $Connected{$Idx} +} +debug(2, "$prefix PerlChildExitHandler disconnect for '$Idx'"); +} + +1; +} + # Store the default start state of each dbh in the handle # Note: This uses private_Apache_DBI hash ref to store it in the handle itself my @attrs = qw( apache_dbi_exithandler.patch Description: Binary data
Re: [mp2] Perl 5.10 fixes from SVN cause SIGBUS on sparc
Niko Tyni wrote: On Mon, Mar 10, 2008 at 10:53:54PM -0700, Philippe M. Chiasson wrote: Niko Tyni wrote: We're switching to Perl 5.10 in Debian soon, and I'm trying to update the mod_perl2 package to keep it working. Unfortunately the ModPerl-Registry test suite is failing on the Sparc architecture because apache2 is killed by a bus error (SIGBUS). How about this s/U16/U32/ diff, basically keeping the flag type at U32, since it was not an essential part of the fix itself. No, that doesn't help either. It turns out the U16/U32 thing was a bad guess on my part. After some code staring and debugging, I found the real bug. It's not architecture-specific really, it just happens to bite worst on Sparc. Thanks a lot for the debugging work! Committed revision 636631. -- Philippe M. Chiasson GPG: F9BFE0C2480E7680 1AE53631CB32A107 88C3A5A5 http://gozer.ectoplasm.org/ m/gozer\@(apache|cpan|ectoplasm)\.org/ signature.asc Description: OpenPGP digital signature
Re: Custom Object-Oriented Module using HTML::Template
try print $template->output; You forgot the print(); xyon wrote: Hey everyone, Firstly, I apologize I sent the previous email under an incorrect subject line. I am working on my first Object-Oriented project, and have hit a slight snag. I am using HTML::Template to output within the View module, but it never outputs. I don't see any errors in the logs, I just get a blank page. Below is pertinent information including a test script with its output: OS Info: CentOS release 4.6 (Final) Package info: perl-5.8.8-11 perl-HTML-Template-2.9-1 httpd-2.0.59-1.el4s1.10.el4.centos mod_perl-2.0.3-1.el4s1.3 /home/perl/Myserver/View.pm package Myserver::View; #Setup some essentials use strict; #strict tolerance for code use Carp; #debugging use diagnostics;#more debugging use warnings; #more debugging #Loadup some needed functions use HTML::Template; sub new { my $self= shift; return $self; } sub mainpage { my $self= shift; my $template= HTML::Template->new( filename => '/home/Perl/tmpl/mainpage.tmpl', cache => 1, debug => 1, stack_debug => 1 ); print "Content-Type: text/html\n\n"; $template->output; return $self; } 1; /home/Perl/tests/View_mainpage.pl #!/usr/bin/perl -w # Test printing of the main page print "Main Page.."; #Let's load the view module use lib "../"; use Myserver::View; #Now let's load some things that are very handy use strict; #strict tolerance for code use Carp; #debugging use warnings; #more debugging use diagnostics;#even more debugging # Let's create an object my $view= Myserver::View->new; # Now, let's tell View to display the main page $view->mainpage; print ".OK"; 1; /home/Perl/tmpl/mainpage.tmpl: Test! Output with debugging on (as above): $ tests/View_mainpage.pl ### HTML::Template Debug ### In _parse: ### HTML::Template _param Stack Dump ### $VAR1 = [ \'Test! ' ]; Main Page..Content-Type: text/html ### HTML::Template Debug ### In output ### HTML::Template output Stack Dump ### $VAR1 = [ \'Test! ' ]; .OK Output without debugging: $ tests/View_mainpage.pl Main Page..Content-Type: text/html .OK