Ian
Ian

Reputation: 13842

mod_perl cannot use threaded MPM without ithreads enabled Perl

Firstly, I have asked a similar previous question years ago for an older version Compile Perl without threads but my previous answer doesn't seem to work now.

My set up is a custom compiled version of Perl

This is perl 5, version 34, subversion 1 (v5.34.1) built for x86_64-linux

CFLAGS='-m64 -mtune=nocona' ./Configure -des -A ccflags=-fPIC -Dprefix=/opt/perl

Which to my understanding shows that threads aren't enabled (I think it would say at the end if so)

I have trying to get this running with Apache 2.4.53 (but I don't think it's getting that far anyway).

Apache config options..

./configure --enable-proxy --enable-rewrite --enable-headers --enable-ssl --with-apr=/usr/local/apr/

As far as I'm aware, and previous answer, was if using Perl without threads, you can compile mod_perl without threads also, this is done by using

mod_perl version is 2.0.12
MP_NO_THREADS=1

So my full command for trying to compile mod_perl is

perl Makefile.PL MP_NO_THREADS=1 MP_APXS=/usr/local/apache2/bin/apxs

the readme says...

# For httpd-2.4, we can't use mpm_is_threaded(), because MPMs are loadable
# modules. We therefore treat httpd as a whole project as threaded. It is
# still possible to disable threading by using MP_NO_THREADS=1

I can also see a bit of code in the Makefile.PL

if ($build->{MP_NO_THREADS}) {
        $build_threaded = 0;
}

and I can see $build_threaded indeed gets set to 0.

However, when I make && make test

I get

[Thu Apr 28 12:18:02.392480 2022] [perl:error] [pid 38185:tid 140616570507840] 
cannot use threaded MPM without ithreads enabled Perl

I can't really see anything in the code (other than checks) that does anything different depending on that code though, but I'm not familiar with it at all, so probably missing something important ?

I have also tried with -Uuseithreads -Uusethreads -Dusethreads=undef

Edit: the bit of code producing the error looks like

## src/modules/perl/mod_perl.c

#ifndef USE_ITHREADS
    if (modperl_threaded_mpm()) {
        ap_log_error(APLOG_MARK, APLOG_ERR, 0, base_server,
                     "cannot use threaded MPM without ithreads enabled Perl");
        exit(1);
    }
#endif

and

Apache2::Build::PERL_HAS_ITHREADS ? "w/" : "w/o";
shows as "w/o" when running

Digging further I see the code seems to call ap_mpm_query() so checking with Apache and in apachectl -v this looks incorrect...I think threaded should be no, so checking on why that is..

Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)

Which is odd..so I think

Upvotes: 1

Views: 403

Answers (1)

Ian
Ian

Reputation: 13842

Looks like something changed with Apache, so seem to have to specify the mpm mode, so if I change Apache compile to --with-mpm=prefork this seems to work.

./configure --enable-proxy --enable-rewrite --enable-headers --enable-ssl --with-apr=/usr/local/apr/  --with-mpm=prefork

Upvotes: 1

Related Questions