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

#!/usr/bin/perl use strict; use CGI; use Authen::Captcha; my $query = new CGI; # # Generate captcha # # Note: in a real script, the data_folder should be placed # outside the www document root # my $captcha = Authen::Captcha->new( data_folder => '/var/www/html/captcha', output_folder => '/var/www/html/captcha', ); my $captcha_characters = 4; my $MD5 = $captcha->generate_code($captcha_characters); # # Print report # print $query->header(); print "<html><body><img src=\"/captcha/$MD5.png\"></body></html>";

Under mod_perl (1.3.x), this code causes a segmentation fault when it tries to run $captcha->generate_code(4). When not under mod_perl, it runs fine. In the same server I've run thousands of lines of perl code using DBI, CGI, and other assorted modules, so I don't think my mod_perl installation is mis-configured. I believe it was setup with DO_EVERYTHING=1 (or similar), the lack of which seemed to be the source of many of my early mod_perl woes a year ago.

There's some really big brains here, so I'm hoping that someone can point me to the instruction I need to fix this problem, and hopefully learn a little along the way.

Thanks for the responses in advance, and thanks for all the other great posts that keep me lurking here daily for months on end.

Replies are listed 'Best First'.
Re: Authen::Captcha Segmentation Fault Under mod_perl
by tachyon (Chancellor) on Mar 15, 2004 at 23:28 UTC

    Pure perl virtually never seg faults, but Authen::Captcha uses GD and MD5 which are mostly C. MD5 is very simple (relatively) and well tested so I would suspect your GD install has some issue under mod perl. GD is a Perl XS wrapper on top of the gd grpahics library. Before you get carried away with debugging I would do a bottom up reinstall on GD and see if it goes away. By bottom up I mean remove gd and GD, then reinstall gd and then GD. See note at the end and get the latest stable version of gd and most recent GD.pm.

    If that fails you may like to try our version (written before A::C was available). It will almost certainly segfault as well as it will probably be GD/gd doing it but then at least you have evidence that it is most probably the common elements (GD or MD5). You will need a font library (freetype) installed if you want to be able to have random fonts happening.