mp2/perl bug in substr( lc( $utf8_url ) )

2007-12-05 Thread John ORourke

Hi folks,

I appear to have found a bug, possibly in perl's utf8 handling but I 
need to create a test to make sure.  I have a workaround which is 
surprisingly simple, hopefully someone can explain it!


I'm not using the 'mp2bug' template because I have 2 different 
architectures, 1 which exhibits the bug and one which does not - they 
are described at the bottom.


I'm going to try the obvious solution - upgrading Apache and libapreq to 
see if that fixes it, when I have some time.


Anyway here it is: I was doing this in a handler: (abbreviated for 
simplicity)


-apache2.conf:

PerlTypeHandler $My::Persistent::Object-type_handler

-My/Persistent/Object.pm:

sub type_handler {  # method handler for Type phase, with a persistent 
object

   my $r=shift;
   my $uri=decode_utf8($r-uri());
   warn got uri $uri\n;
   my $path=substr(lc($uri),0,2048); # limit ridiculous paths
   warn got path $path;
}

---

After a given process had served a few requests I was seeing this:
   got uri /something/here
   got path /somethi   --- path truncated to a certain no. of chars

Then it got stranger - it seemed to truncate all URLs sent to that 
process to that same no. of chars for the life of the process, and the 
no. of chars appeared to be a low but random number - 6, 15 etc!  
Clearly by this point I was going slightly insane so these assumptions 
may not be entirely

correct.

--WORKAROUND:
Then even stranger - by replacing this:
   my $path = substr( lc( $uri ), 0, 2048 )
with
   my $path = lc( $uri );
   $path=substr( $path, 0, 2048 );
the problem went away!

Oddly, I have seen this on one setup but not another

Here is the setup I DID see the problem on:

---
OS: Ubuntu 6.06.1 LTS
Apache: 2.0.55 prefork mpm, 32-bit
Perl: 5.8.7  (also seen on a similar setup with 5.8.8)
Apache2::Request   : 2.07
CGI: 3.10
ExtUtils::MakeMaker: 6.17, 6.38
LWP: 5.803
mod_perl   : -
mod_perl2  : 2.02
---

And here is the one I DID NOT see it on:
---
Fedora Core 5
Perl 5.8.8
Linux 2.6.9-34.elsmp
Apache 2.2.0 prefork mpm, 32-bit
Apache2::Request   : 2.08
CGI: 3.15
ExtUtils::MakeMaker: 6.30
LWP: 5.805
mod_perl   : -
mod_perl2  : 2.02

--

For now I don't have time to investigate further, having found a 
workaround, but I'll post again if I find anything more.


cheers
John



Client denied/Invalid Argument

2007-12-05 Thread Proneet Biswas

Hi,
 I am a newbie to the mod_perl for Apache . I am trying to run a simple 
perl script under Apache 2.2 . HOwever, it seems to be either crashign 
teh server or saying client denied by server configuration.

The PERL is Active Perl 5.8
The Apache Server is version 2.2.6

The httpd.conf reads like this :

LoadFile C:/Perl/bin/perl58.dll
LoadModule perl_module modules/mod_perl.so

PerlModule ModPerl::Registry
Alias /perl/ C:/Apache22/perl/
Location /perl
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
Options +ExecCGI
PerlOptions +ParseHeaders
/Location

PerlModule Apache2::Hello
Location /hello
   SetHandler modperl
   PerlResponseHandler Apache2::Hello
/Location

The Apache error log reads:

[Wed Dec 05 16:53:05 2007] [notice] Child 4224: Starting thread to 
listen on port 80.
[Wed Dec 05 16:53:19 2007] [notice] Parent: child process exited with 
status 9 -- Restarting.
[Wed Dec 05 16:53:19 2007] [notice] Apache/2.2.6 (Win32) mod_perl/2.0.3 
Perl/v5.8.8 configured -- resuming normal operations

[Wed Dec 05 16:53:19 2007] [notice] Server built: Sep  5 2007 08:58:56
[Wed Dec 05 16:53:19 2007] [crit] (22)Invalid argument: Parent: Failed 
to create the child process.
[Wed Dec 05 16:53:19 2007] [crit] (OS 6)The handle is invalid.  : 
master_main: create child process failed. Exiting.
[Wed Dec 05 16:53:49 2007] [notice] Parent: Forcing termination of child 
process 36


I would appreciate if I could get some pointers/workaround for this issue.

Regards
Proneet.

--





Unqualified segmentation fault from Apache2::Request-new()

2007-12-05 Thread Colin Wetherbee

Greetings.

I accidentally made the mistake of calling Apache2::Request-new() 
without passing $r, and it turns out that causes Apache to segfault and 
not return anything to the browser.  I'm only pointing this out because 
it seems like there should be a more graceful way of handling this.


### Code
package Test::Handler;

use Apache2::RequestRec;
use Apache2::Const -compile = qw(OK);

sub handler
{
  my ($r) = @_;

  my $req = Apache2::Request-new();

  return Apache2::Const::OK;
}

1;
### End Code

### Log (LogLevel debug)
[Thu Dec 06 02:16:46 2007] [notice] Apache/2.2.3 (Debian) 
mod_apreq2-20051231/2.6.0 mod_perl/2.0.3 Perl/v5.8.8 configured -- 
resuming normal operations

[Thu Dec 06 02:16:46 2007] [info] Server built: Dec  2 2007 18:11:50
[Thu Dec 06 02:16:46 2007] [debug] prefork.c(993): AcceptMutex: sysvsem 
(default: sysvsem)
[Thu Dec 06 02:16:51 2007] [notice] child pid 22461 exit signal 
Segmentation fault (11)

### End Log

Colin


modperl on Win32 is still happening

2007-12-05 Thread Foo JH
Looking at the (albeit small) stream of entries to the mailing list, I'm 
actually quite happy to notice that people are:

1. Still using modperl. Some newbie questions may suggest fresh blood...
2. Still using modperl on Win32 (despite the 'limitations'). Good news 
for Microsoft, but I personally believe it's a gentle step for people to 
learn modperl, then move into the Linux/ BSD platform.





Re: Unqualified segmentation fault from Apache2::Request-new()

2007-12-05 Thread Colin Wetherbee

Colin Wetherbee wrote:

use Apache2::RequestRec;
use Apache2::Const -compile = qw(OK);


To be clear, this also occurs with 'use Apache2::Request' at the top. :)

Colin


Looking for a career in Perl overseas

2007-12-05 Thread Foo JH

For what it's worth, I'm gonna try anyway...

I'm a Perl/ C# developer in Singapore with some 9 years in development, 
looking forward to enjoy a career in a new culture and environment 
(outside of Singapore). No criminal records, though some will claim I've 
sinned for learning C# instead of Java.


If your company is seeking an experienced developer, and is willing to 
relocate new staff, please contact me at [EMAIL PROTECTED]


Thanks.


Re: Flex

2007-12-05 Thread Jonathan Vanasco


On Dec 3, 2007, at 6:30 PM, Boysenberry Payne wrote:

Our system could benefit a lot from being able to compile SWFs on  
the fly; right now they're all
static files loaded dynamically.  I could see making them  
dynamically as needed, while still serving

up the static renditions.


We do some dynamic SWF generation via mod_perl; there are some  
actionscript bytecode compilers under perl

There's also a decent Python and Erlang library out there too.

For anything dynamic, its pretty simple- you can merge swfs, do simple  
actions / var publishers as wrappers which load desgined flash files,  
etc.


not very hard!


Re: Flex

2007-12-05 Thread Jonathan Vanasco


Ext is good.  Personally, I like the MochiKit system (though a good  
friend maintains it).  A few of the big-guys use it for all their  
internal systems.


It has a neat dev enviroment - even has an interpreter for you to dev  
in.

http://mochikit.com/examples/interpreter/index.html

On Dec 2, 2007, at 6:30 PM, Perrin Harkins wrote:


On Dec 2, 2007 6:10 PM, David Scott [EMAIL PROTECTED] wrote:
AJAX is anything but time-consuming once you get the hang of it.  I  
much

prefer it to traditional server-side dynamic page construction, which
really is time-consuming.


My experience has been that even the best JavaScript tools (Firebug)
are pretty weak compared to the Perl dev environment, and
cross-browser problems are an ongoing issue, despite the wealth of JS
libraries intended to paper over them.  Maybe Flex has these problems
too, but in theory the cross-browser stuff could be better.

It also sound nice to use a dev tool that was actually intended for
GUI programming, rather than the bolted-on feel of JS + CSS + HTML.




Re: Flex

2007-12-05 Thread Jonathan Vanasco


On Dec 3, 2007, at 6:30 PM, Boysenberry Payne wrote:

Our system could benefit a lot from being able to compile SWFs on  
the fly; right now they're all
static files loaded dynamically.  I could see making them  
dynamically as needed, while still serving

up the static renditions.


We do some dynamic SWF generation via mod_perl; there are some  
actionscript bytecode compilers under perl

There's also a decent Python and Erlang library out there too.

For anything dynamic, its pretty simple- you can merge swfs, do simple  
actions / var publishers as wrappers which load desgined flash files,  
etc.


not very hard!


Re: Client denied/Invalid Argument

2007-12-05 Thread Randy Kobes

On Wed, 5 Dec 2007, Proneet Biswas wrote:


Hi,
I am a newbie to the mod_perl for Apache . I am trying to run a simple perl 
script under Apache 2.2 . HOwever, it seems to be either crashign teh server 
or saying client denied by server configuration.

The PERL is Active Perl 5.8
The Apache Server is version 2.2.6


You may have come across the problem described at:
 http://apache.sunsite.ualberta.ca/httpd/binaries/win32/README.html
which says

Warning: we have reports that mod_perl and some non-ASF 
modules which rely on maipulating pipe handles in a 
Windows-specific manner do not work with the changes 
introduced to solve piped logging and overall consistencey 
to the Unix port. If you encouter such issues, 2.2.4 would 
be the version to fall back on until the next release.


Try reverting to 2.2.4 to see if that helps.

--
best regards,
Randy Kobes


Re: mp1 internal_redirect question

2007-12-05 Thread Silent
I tryed mod_rewrite to redirect base on user_agent, it works very fine!
but I still want to know how to do it in mod_perl.




2007/12/2, Silent [EMAIL PROTECTED]:

 Hi,

 I want to develop a script like this:

 the script randomly send a html page or mp3 file, but I met some problems,


 #!/usr/bin/perl

 use Apache;
 my $r=Apache-request;

 my @file = ( { '/1.mp3' = 'audio/mpeg' },
  { '/aaa.html' = 'text/html' },
  { '/bbb.html' = 'text/html' },
  { '/1.png' = 'image/png'}
 );

 my $idx = int rand(4);
 my @ks = keys %{$file[$idx]};
 my $key = shift @ks;

 warn($file[$idx]{$key} -- $key);  # log

 $r-content_type($file[$idx]{$key});  # content-type

 #$r-send_http_header;# this seems can be omited

 $r-internal_redirect_handler($key);  #  redirect to file , also tryed
 internal_redirect

  end

  I am using apache1.3.x+mod_perl 1.29

 IfModule mod_perl.c
   PerlModule Apache::Registry
   IfModule mod_alias.c
Alias /perl/ /var/www/perl/
   /IfModule
   Location /perl
 SetHandler perl-script
 PerlHandler Apache::Registry
 Options +ExecCGI
   /Location
 /IfModule

 the url is http://192.168.0.1/rand/asd.mp3 ,  rand is the script
 name, asd.mp3 is just a fake path_info.

 tested with MSIE6 and firefox2 on windowsXP-pro-sp2,

 firefox2 works fine, when mp3 file reached, it ask for download or play

 MSIE6 sometimes works,
 but sometimes:
 1. sometimes text file was processed by windows mediaplayer
 2. sometimes png file was processed by windows mediaplayer
 3. sometimes mp3 file was showed as text file, (losts of non-string char
 in IE)

 and I am sure the content-type is sended correctly (watching the log warn)

 are the problems as IE6 natures ?
 is there any other proper way to do this ?



 question 2:
 with mod_perl2, internal_redirect seems can access system file, such as
 /etc/*, but mod_perl1 seems can only access files under apache documentroot
 right ?

 thanks!



Re: Can't locate object method session via package HTML::Mason::Request::ApacheHandler .

2007-12-05 Thread Darragh Gammell
Hi

 Ive recently tried moving a website from an old server which is having
 hardware issues to a recently purchased server.

 Old Server ran:
 Linux 2.6.11-1-686-smp #1 SMP Mon Jun 20 20:18:45 MDT 2005 i686 GNU/Linux
 Mason 1.21
 mod_perl
 and apache 1.3


 I'm now trying to get the same website running on:

 Ubuntu gutsy Linux 2.6.22-14-server
 Apache2
 mod_perl2

 Highlights for the apache2 hhtpd.conf :

 PerlModule HTML::Mason
 PerlModule HTML::Mason::ApacheHandler
 PerlModule Apache2::Request
 PerlModule Apache::DBI

 and the vhost:

 PerlRequire /etc/apache2/handler.pl

 Directory /home/mac/public_html
 #Options -Indexes
 #HTML::Mason handles any .html files
 FilesMatch \.html
 SetHandler perl-script
 PerlHandler HTML::Mason::ApacheHandler
 /FilesMatch
 # Deny .comp files from being accessed directly
 /Directory

 FilesMatch \.mc|autohandler|dhandler
 SetHandler perl-script
 PerlInitHandler Apache2::Const::NOT_FOUND
 /FilesMatch




 Im getting this error in the browser however:

 *error:*  Can't locate object method session via package
 HTML::Mason::Request::ApacheHandler at /home/mac/public_html/autohandler
 line 402.
  *context:*   *...*
  *398:*  % }  *399:*
  *400:*  %filter  *401:*
  *402:*  if ($m-session-{textonly} eq on) {  *403:*  s/img
 src=.+?//g;  *404:*  unless ($m-session-{inside_file_management} eq
 yes) {  *405:*  s/\script.+\/SCRIPT//g;  *406:*
 s/\script.+\/script//g;  *...*
*code stack:*  /home/mc2/public_html/autohandler:402

 Can't locate object method session via package 
 HTML::Mason::Request::ApacheHandler at /home/mac/public_html/autohandler 
 line 402.


 Trace begun at /usr/local/share/perl/5.8.8/HTML/Mason/Exceptions.pm line 129
 HTML::Mason::Exceptions::rethrow_exception('Can\'t locate object method 
 session via package HTML::Mason::Request::ApacheHandler at 
 /home/mac/public_html/autohandler line 402.^J') called at 
 /home/mac/public_html/autohandler line 402
 HTML::Mason::Commands::__ANON__('!-- AUTOHANDLER START NOW--') called at 
 /usr/local/share/perl/5.8.8/HTML/Mason/Request.pm line 1277
 HTML::Mason::Request::comp(undef, undef, undef) called at 
 /usr/local/share/perl/5.8.8/HTML/Mason/Request.pm line 466
 eval {...} at /usr/local/share/perl/5.8.8/HTML/Mason/Request.pm line 466
 eval {...} at /usr/local/share/perl/5.8.8/HTML/Mason/Request.pm line 418
 HTML::Mason::Request::exec('HTML::Mason::Request::ApacheHandler=HASH(0x39f6200)')
  called at /usr/local/share/perl/5.8.8/HTML/Mason/ApacheHandler.pm line 168
 HTML::Mason::Request::ApacheHandler::exec('HTML::Mason::Request::ApacheHandler=HASH(0x39f6200)')
  called at /usr/local/share/perl/5.8.8/HTML/Mason/ApacheHandler.pm line 826
 HTML::Mason::ApacheHandler::handle_request('HTML::Mason::ApacheHandler=HASH(0x341fbf0)',
  'Apache2::RequestRec=SCALAR(0x25b42e0)') called at (eval 32) line 8
 HTML::Mason::ApacheHandler::handler('HTML::Mason::ApacheHandler', 
 'Apache2::RequestRec=SCALAR(0x25b42e0)') called at -e line 0


 eval {...} at -e line 0



 Any help/indications regarding whats going on here would be greatly
 appreciated.
 Just reply with what info is better to give too if this isnt enough.

 Thanks in advance

 Darragh


 For reference heres whats installed along with the OS:

 apt-get update
 apt-get upgrade
 apt-get install build_essential
 apt-get install ssh
 apt-get install apache2
 apt-get install postgresql-8.2
 apt-get install apt-show-versions
 apt-get install libapache2-mod-perl2-dev
 apt-get install libhtml-mason-perl
 apt-get install apache2-prefork-dev
 apt-get install apache2-src
 apt-get install sendmail
 apt-get install libapache2-mod-apreq2
 apt-get install libapache2-request-perl (and use 'a2enmod apreq' to load the 
 module into Apache2.)


 HTML::Mason (HTML-Mason-1.37)
 Data::Dumper(Data-Dumper-2.121)
 DBI(DBI-1.601)
 DBD(DBD-Pg-1.49)
 CGI(CGI.pm-3.31)
 Date::Parse(TimeDate-1.16)
 Date::Calc(Date-Calc-5.4)
 mod_perl2 (mod_perl-2.0.3
 ) need to cd /usr/lib;ln -s /usr/lib/libperl.so.5.8 libperl.so
 ExtUtils::XSBuilder(ExtUtils-XSBuilder-0.28)
 version(version-0.74)
 Parse::RecDescent(Parse-RecDescent-v1.95.1)
 Apache::Cookie (libapreq2-2.08)

 Apache::DBI(Apache-DBI-1.06)
 Sub::Uplevel(Sub-Uplevel-0.18)
 Test::Simple(Test-Simple-0.74)
 Test::Tester(Test-Tester-0.106)
 Test::NoWarnings(Test-NoWarnings-0.084)
 Test::Exception(Test-Exception-0.25)
 Test::Deep(Test-Deep-0.099)
 Apache::Session(Apache-Session-1.81)
 Apache::Session::Wrapper(Apache-Session-Wrapper-0.33)
 MasonX::Request::WithApacheSession(MasonX-Request-WithApacheSession-0.30)
 Text::Reform(Text-Reform-v1.12.2
 )
 Text::Autoformat(Text-Autoformat-v1.14.0)
 MIME::Base64(MIME-Base64-3.07)
 Pod::Escapes(Pod-Escapes-1.04)
 Pod::Simple(Pod-Simple-3.05)
 Test::Pod(Test-Pod-1.26)
 MIME::Types(MIME-Types-1.22)
 Mail::Address(MailTools-2.02)