Running Znuny OTRS in a FreeBSD Jail with apache24 and mod_perl2 Upgrade perl5-5.36.3_2 to perl5-5.40.2_2 needed packages have been rebuild successful in clean environment. [...] ap24-mod_authnz_external24-3.3.3 Allows users authentication based on external mechanisms on apache 2.4 ap24-mod_perl2-2.0.13,3 Embeds a Perl interpreter in the Apache server apache24-2.4.63 Version 2.4.x of Apache web server apr-1.7.5.1.6.3_4 Apache Portability Library [...] Regression: Apache24 fails to start if mod_perl2 is enabled httpd_error.log: panic: MUTEX_LOCK (22) [Magic.xs:525] during global destruction. revert to perl5-5.36.3_2 not possible any more. running "pkg upgrade -f" to catch missing revision bumps. Apache24 still fails to start
Searching for the panic message gets me to https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=977810;msg=2 (with Perl 5.36) https://stackoverflow.com/questions/4902718/detecting-global-destruction-in-perl (with Perl 5.14) https://github.com/Perl/perl5/issues/9698 (with Perl 5.10) So, I don't think this is a 5.40 problem.
I rebuild all Packages with: DEFAULT_VERSIONS+=perl5=5.38 pkg updated 377+ packages. resulting: perl5-5.38.4_1 Practical Extraction and Report Language apache24 starts now, mod_perl2 application is working again. Summary: mod_perl2 does no longer work with perl5-5.40.2_2 mod_perl2 does still work with perl5-5.38.4_1 In the changelog at https://perldoc.perl.org/perl5400delta I see no relevant changes to "global destruction". I am not sure what has ben changed in the behavior. And if there is any workaround or patch needed for 5.40.*
I can reproduce it with the official package set: Empty Jail: # pkg install ap24-mod_perl2 # pkg install otrs # cat > /usr/local/etc/apache24/Includes/perl.conf << 'EOD' LoadModule perl_module libexec/apache24/mod_perl.so PerlRequire /usr/local/otrs/scripts/apache2-perl-startup.pl EOD # service apache24 onestart # tail /var/log/httpd-error.log panic: MUTEX_LOCK (22) [Magic.xs:525] during global destruction. PerlRequire was needed to trigger the bug. I disabled modules to track down the problem Finally disabling only one module "DateTime" fixed the startup of apache: The application was not tested. --- /usr/local/otrs/scripts/apache2-perl-startup.pl.orig +++ /usr/local/otrs/scripts/apache2-perl-startup.pl @@ -67,7 +67,7 @@ eval { require Net::DNS }; # Preload DateTime, an expensive external dependency. +# use DateTime (); -use DateTime (); # Preload dependencies that are always used. use Template (); # service apache24 onestart # tail /var/log/httpd-error.log [Fri Jun 06 10:08:24.610090 2025] [mpm_prefork:notice] [pid 18684] AH00163: Apache/2.4.63 (FreeBSD) mod_perl/2.0.13 Perl/v5.40.2 configured -- resuming normal operations [Fri Jun 06 10:08:24.610319 2025] [core:notice] [pid 18684] AH00094: Command line: '/usr/local/sbin/httpd -D NOHTTPACCEPT'
I rebuild all Packages with: DEFAULT_VERSIONS+=perl5=5.42 needed packages have been rebuild successful in poudriere # tail /var/log/httpd-error.log panic: MUTEX_LOCK (22) [Magic.xs:525] during global destruction. When disabling "use DateTime ();", apache starts. p5-DateTime-1.66 has a problem loaded into mod_perl2. ap24-mod_perl2-2.0.13,3 apache24-2.4.65_1 apr-1.7.5.1.6.3_5 graphite2-1.3.14 graphviz-current-14.0.1 hidapi-0.15.0 libpaper-1.1.28_1 openldap26-client-2.6.10 p5-Algorithm-C3-0.11 p5-Algorithm-Diff-1.1903 p5-Apache-DBI-1.12_2 p5-AppConfig-1.71 p5-Archive-Zip-1.68 p5-Authen-NTLM-1.09_1 p5-Authen-SASL-2.1900 p5-B-Hooks-EndOfScope-0.28 p5-BSD-Resource-1.2911 p5-Bit-Vector-7.4_1 p5-CGI-4.70 p5-CPAN-Requirements-Dynamic-0.002_1 p5-CSS-Minifier-0.01_1 p5-CSS-Minifier-XS-0.13 p5-Capture-Tiny-0.50 p5-Carp-Clan-6.08 p5-Class-Accessor-Lite-0.08 p5-Class-C3-0.35 p5-Class-Data-Inheritable-0.10 p5-Class-Inspector-1.36 p5-Class-Method-Modifiers-2.15 p5-Class-Mix-0.006 p5-Class-Singleton-1.6 p5-Class-XSAccessor-1.19_2,1 p5-Clone-0.47 p5-Clone-PP-1.08 p5-Convert-BinHex-1.125 p5-Crypt-Eksblowfish-0.009_3 p5-Crypt-PasswdMD5-1.42 p5-Crypt-Random-Source-0.12 p5-Crypt-SSLeay-0.72_3 p5-Crypt-URandom-0.54 p5-DBD-mysql-5.008 p5-DBI-1.647_1 p5-Data-OptList-0.114 p5-Date-Pcalc-6.1_1 p5-DateTime-1.66 p5-DateTime-Locale-1.45 p5-DateTime-TimeZone-2.65,1 p5-Devel-CallChecker-0.009 p5-Devel-CheckLib-1.16 p5-Devel-StackTrace-2.05 p5-Digest-HMAC-1.05 p5-Digest-MD5-2.59_1 p5-Dist-CheckConflicts-0.11_1 p5-DynaLoader-Functions-0.004 p5-Email-Valid-1.204 p5-Encode-Locale-1.05 p5-Eval-Closure-0.14 p5-Exception-Class-1.45 p5-Exporter-Tiny-1.006002 p5-ExtUtils-Config-0.010 p5-ExtUtils-Helpers-0.028 p5-ExtUtils-InstallPaths-0.015 p5-ExtUtils-PkgConfig-1.16 p5-File-Find-Rule-0.35 p5-File-Listing-6.16 p5-File-ShareDir-1.118 p5-File-ShareDir-Install-0.14 p5-File-Slurp-Tiny-0.004 p5-File-Which-1.27 p5-Font-TTF-1.06 p5-GD-2.83 p5-GD-Graph-1.56 p5-GD-TextUtil-0.86_5 p5-HTML-Parser-3.83 p5-HTML-Tagset-3.24 p5-HTTP-Cookies-6.11 p5-HTTP-Date-6.06 p5-HTTP-Message-7.00 p5-HTTP-Negotiate-6.01_1 p5-IO-HTML-1.004 p5-IO-Interactive-1.027,1 p5-IO-SessionData-1.03_1 p5-IO-Socket-SSL-2.095 p5-IO-String-1.08_1 p5-JSON-4.10 p5-JSON-XS-4.04 p5-JavaScript-Minifier-1.16 p5-JavaScript-Minifier-XS-0.15 p5-LWP-MediaTypes-6.04 p5-LWP-Protocol-https-6.14 p5-Lingua-Translit-0.28 p5-List-MoreUtils-0.430 p5-List-MoreUtils-XS-0.430 p5-Locale-Codes-3.64 p5-Locale-gettext-1.07 p5-Locale-libintl-1.35 p5-MIME-Base32-1.303 p5-MIME-Base64-3.16 p5-MIME-Tools-5.515,2 p5-MRO-Compat-0.15 p5-Mail-IMAPClient-3.43 p5-Mail-Tools-2.22 p5-Math-Random-ISAAC-1.004_2 p5-Math-Random-ISAAC-XS-1.004_3 p5-Math-Random-Secure-0.080001_1 p5-Module-Build-0.4234 p5-Module-Build-Tiny-0.052 p5-Module-Find-0.17 p5-Module-Implementation-0.09_1 p5-Module-Runtime-0.018 p5-Moo-2.005005 p5-Mozilla-CA-20250602 p5-Net-DNS-1.53,1 p5-Net-Domain-TLD-1.75 p5-Net-HTTP-6.24 p5-Net-IMAP-Simple-1.2212 p5-Net-SSLGlue-1.058 p5-Net-SSLeay-1.94 p5-Number-Compare-0.03_1 p5-PDF-API2-2.048 p5-PDF-API2-XS-1.002 p5-Package-Stash-0.40 p5-Package-Stash-XS-0.30 p5-Params-Classify-0.015 p5-Params-Util-1.102 p5-Params-Validate-1.31 p5-Params-ValidationCompiler-0.31 p5-Parse-RecDescent-1.967015 p5-Path-Class-0.37 p5-Pod-Strip-1.100 p5-Proc-Daemon-0.23 p5-Ref-Util-XS-0.117 p5-Role-Tiny-2.002004 p5-SOAP-Lite-1.27 p5-Schedule-Cron-Events-1.95_1 p5-Set-Crontab-1.03_1 p5-Sisimai-5.4.1 p5-Specio-0.52 p5-Sub-Exporter-0.991 p5-Sub-Exporter-Progressive-0.001013 p5-Sub-Identify-0.14 p5-Sub-Install-0.929 p5-Sub-Quote-2.006009 p5-Sys-Hostname-Long-1.5_1 p5-Task-Weaken-1.06 p5-Template-Toolkit-3.102 p5-Test-Inter-1.12 p5-Text-CSV-2.06 p5-Text-CSV_XS-1.61 p5-Text-Diff-1.45 p5-Text-Glob-0.11 p5-Text-Unidecode-1.30 p5-TimeDate-2.33,1 p5-Try-Tiny-0.32 p5-Type-Tiny-2.008003 p5-Type-Tiny-XS-0.025 p5-Types-Serialiser-1.01 p5-URI-5.34 p5-Unicode-EastAsianWidth-12.0 p5-Variable-Magic-0.64 p5-WWW-RobotRules-6.02_1 p5-XML-FeedPP-0.95 p5-XML-LibXML-2.0210_1,1 p5-XML-LibXML-Simple-0.95 p5-XML-LibXSLT-2.003000_1 p5-XML-NamespaceSupport-1.12 p5-XML-Parser-2.47 p5-XML-Parser-Lite-0.722 p5-XML-SAX-1.02 p5-XML-SAX-Base-1.09 p5-XML-TreePP-0.43 p5-XString-0.005 p5-YAML-1.31 p5-YAML-LibYAML-0.90 p5-common-sense-3.75 p5-libwww-6.80 p5-namespace-autoclean-0.31 p5-namespace-clean-0.27 perl5-5.42.0_1
I have found the issue is p5-Variable-Magic. If I forcibly uninstall p5-Variable-Magic, mod_perl2 with perl5-5.40+ does not crash with DateTime loaded.
Set this in httpd.conf: PerlSetEnv B_HOOKS_ENDOFSCOPE_IMPLEMENTATION PP This forces Variable::Magic to use PurePerl implementation instead of XS. Now DateTime works without crashing mod_perl. Verified with lang/perl5.42.