You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Marc Tardif <ma...@sitepak.com> on 2005/07/06 22:08:33 UTC

Failure calling BOOT: code

This is the software installed on my system:

   Red Hat Enterprise Linux ES release 4
   httpd-2.0.54
   mod_perl-2.0.1

This is the configuration in my httpd.conf file:

   LoadModule perl_module modules/mod_perl.so
   PerlRequire /usr/my/dev/lib/My/bootstrapper.pl
   SetHandler modperl
   PerlResponseHandler My::Handler

This is the content of /usr/my/dev/lib/My/bootstrapper.pl:

   use lib '/usr/my/dev/lib';
   open(STDERR, ">>/tmp/mod_perl.error.log") || die $!;

This is the content of /usr/my/dev/lib/My/Handler.pm:

   package My::Handler;

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

   sub handler {
     my $r = shift;
     $r->print("hello_world");
     # require Mozilla::LDAP::API;
     return Apache2::Const::OK;
   }

The problem is that if I uncomment the require line in the handler, I 
get the following error message in /tmp/mod_perl.error.log:

   Error loading Mozilla::LDAP::API: perldap_init failed

The solution might be related to the following XS code in API.xs:

   BOOT:
   if ( perldap_init() != 0) {
      fprintf(stderr,
      "Error loading Mozilla::LDAP::API: perldap_init failed\n");
      exit(1);
   }

So, perhaps perldap_init() is being called multiple times. Is there 
something I can try in mod_perl to avoid this kind of problem? Can I 
provide more information to help solve this problem?

-- 
Marc Tardif
Sitepak
(514) 866-8883

Re: Failure calling BOOT: code

Posted by Stas Bekman <st...@stason.org>.
Marc Tardif wrote:
[...]
> The Mozilla::LDAP::API module was installed from an RPM. I have the 
> source but the makefiles don't work out of the box. I have tried 
> fiddling around with the compilation flags but haven't managed to get 
> the module compiled again. I would prefer to attach to the process with 
> gdb but the problem is that it that the process dies when encountering a 
> problem with the Perl module (see exit(1) in the XS code above).

So you need to set a breakpoint in that code, which is quite tricky, since 
  it won't see the breakpoint before the perl module is loaded. So you 
need to break at BOOT before perldap_init(). e.g. take a look at:
http://perl.apache.org/docs/2.0/devel/debug/c.html#Precooked_gdb_Startup_Scripts
There is no exact script to copy from but you get an idea on how things 
can be automated.

I've tried building Mozilla::LDAP::API, but I couldn't build it since I 
think I don't have mozilla-dev package. Your best bet is to figure out how 
to build it. since in order to debug it with gdb you will still need to 
build it with debugging info enabled.

>> If it was a problem at the startup and if perldap uses some static C 
>> variables, you could have used
>> http://perl.apache.org/docs/2.0/user/handlers/server.html#Dealing_with_Restarts 
> 
> I have tried printing the restart_count value in my handler and it 
> always returns 2. Could that be the problem?

On the start STDERR goes to the console, so the value 1 goes there. Only 
on restart it goes to the file that's where you see 2.

But since the problem happens post startup, it's probably not relevant.

>> Are you using threads?
> 
> No, I'm not using threads. How can I make sure mod_perl.so hasn't been 
> compiled with threads?

You use perl 5.6.1, so there can be no threads :)


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Re: Failure calling BOOT: code

Posted by Marc Tardif <ma...@sitepak.com>.
Stas Bekman wrote:
> Marc Tardif wrote:
> [...]
> 
>> The problem is that if I uncomment the require line in the handler, I 
>> get the following error message in /tmp/mod_perl.error.log:
>>
>>   Error loading Mozilla::LDAP::API: perldap_init failed
>>
>> The solution might be related to the following XS code in API.xs:
>>
>>   BOOT:
>>   if ( perldap_init() != 0) {
>>      fprintf(stderr,
>>      "Error loading Mozilla::LDAP::API: perldap_init failed\n");
>>      exit(1);
>>   }
>>
>> So, perhaps perldap_init() is being called multiple times. Is there 
>> something I can try in mod_perl to avoid this kind of problem? Can I 
>> provide more information to help solve this problem?
> 
> 
> I'd try to add some debug prints in perldap_init() function and see 
> where it fails (or step through with debugger).

The Mozilla::LDAP::API module was installed from an RPM. I have the 
source but the makefiles don't work out of the box. I have tried 
fiddling around with the compilation flags but haven't managed to get 
the module compiled again. I would prefer to attach to the process with 
gdb but the problem is that it that the process dies when encountering a 
problem with the Perl module (see exit(1) in the XS code above).

> If it was a problem at the startup and if perldap uses some static C 
> variables, you could have used
> http://perl.apache.org/docs/2.0/user/handlers/server.html#Dealing_with_Restarts 

I have tried printing the restart_count value in my handler and it 
always returns 2. Could that be the problem?

> However it looks like a runtime problem.
> 
> What if you preload Mozilla::LDAP::API at the server startup?

Same thing, I still get the error message:
Error loading Mozilla::LDAP::API: perldap_init failed

> Are you using threads?

No, I'm not using threads. How can I make sure mod_perl.so hasn't been 
compiled with threads?

> Can you please send the complete bug report as 
> explained at http://perl.apache.org/bugs/?

Done.

-- 
Marc Tardif
Sitepak
(514) 866-8883

Re: Failure calling BOOT: code

Posted by Stas Bekman <st...@stason.org>.
Marc Tardif wrote:
[...]
> The problem is that if I uncomment the require line in the handler, I 
> get the following error message in /tmp/mod_perl.error.log:
> 
>   Error loading Mozilla::LDAP::API: perldap_init failed
> 
> The solution might be related to the following XS code in API.xs:
> 
>   BOOT:
>   if ( perldap_init() != 0) {
>      fprintf(stderr,
>      "Error loading Mozilla::LDAP::API: perldap_init failed\n");
>      exit(1);
>   }
> 
> So, perhaps perldap_init() is being called multiple times. Is there 
> something I can try in mod_perl to avoid this kind of problem? Can I 
> provide more information to help solve this problem?

I'd try to add some debug prints in perldap_init() function and see where 
it fails (or step through with debugger).

If it was a problem at the startup and if perldap uses some static C 
variables, you could have used
http://perl.apache.org/docs/2.0/user/handlers/server.html#Dealing_with_Restarts

However it looks like a runtime problem.

What if you preload Mozilla::LDAP::API at the server startup?

Are you using threads? Can you please send the complete bug report as 
explained at http://perl.apache.org/bugs/?


-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com