/usr/share/doc/libapache2-mod-perl2-doc/docs/2.0/user/troubleshooting/troubleshooting.html is in libapache2-mod-perl2-doc 2.0.10-2ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | <?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body>
<ul id="index">
<li><a href="#NAME">NAME</a></li>
<li><a href="#Description">Description</a></li>
<li><a href="#Building-and-Installation">Building and Installation</a>
<ul>
<li><a href="#Cannot-find--lgdbm-libgdbm.so.3:-open-failed:-No-such-file-or-directory">Cannot find -lgdbm / libgdbm.so.3: open failed: No such file or directory</a></li>
</ul>
</li>
<li><a href="#Configuration-and-Startup">Configuration and Startup</a>
<ul>
<li><a href="#Cant-locate-TestFilter-in_str_consume.pm-in-INC">Can't locate TestFilter/in_str_consume.pm in @INC...</a></li>
<li><a href="#mod_perl.c-is-not-compatible-with-this-version-of-Apache-found-20020628-need-20020903">"mod_perl.c" is not compatible with this version of Apache (found 20020628, need 20020903)</a></li>
<li><a href="#Server-Hanging-at-the-Startup">Server Hanging at the Startup</a></li>
<li><a href="#No-space-left-on-device">(28)No space left on device</a></li>
<li><a href="#Segmentation-Fault-when-Using-DBI">Segmentation Fault when Using DBI</a></li>
<li><a href="#Perl-directive-missing-closing"><Perl> directive missing closing '>'</a></li>
<li><a href="#Invalid-per-unknown-PerlOption:-ParseHeaders-on-HP-UX-11-for-PA-RISC">'Invalid per-unknown PerlOption: ParseHeaders' on HP-UX 11 for PA-RISC</a></li>
</ul>
</li>
<li><a href="#Shutdown-and-Restart">Shutdown and Restart</a>
<ul>
<li><a href="#Subroutines-in-perl-sections-under-threaded-mpm">Subroutines in <perl> sections under threaded mpm</a></li>
<li><a href="#Modules-using-Scalar::Util::weaken-under-threaded-mpm">Modules using Scalar::Util::weaken under threaded mpm</a></li>
</ul>
</li>
<li><a href="#Code-Parsing-and-Compilation">Code Parsing and Compilation</a>
<ul>
<li><a href="#Segfault-with-__read_nocancel-Backtrace">Segfault with __read_nocancel Backtrace</a></li>
<li><a href="#Registry-scripts-fail-to-load-with:-Unrecognized-character-xEF-at">Registry scripts fail to load with: Unrecognized character \xEF at ...</a></li>
</ul>
</li>
<li><a href="#Runtime">Runtime</a>
<ul>
<li><a href="#error_log-is-Full-of-Escaped-n-t-etc">error_log is Full of Escaped \n, \t, etc.</a></li>
<li><a href="#Problems-with-Catching-Signals">Problems with Catching Signals</a></li>
<li><a href="#APR::Socket::recv:-11-Resource-temporarily-unavailable-at">APR::Socket::recv: (11) Resource temporarily unavailable at ...</a></li>
<li><a href="#APR::UUID-new-Hanging">APR::UUID->new Hanging</a></li>
<li><a href="#Memory-Leaks">Memory Leaks</a></li>
<li><a href="#C-Libraries-Dont-See-ENV-Entries-Set-by-Perl-Code">C Libraries Don't See %ENV Entries Set by Perl Code</a></li>
<li><a href="#Error-about-not-finding-Apache.pm-with-CGI.pm">Error about not finding Apache.pm with CGI.pm</a></li>
<li><a href="#Error-string-not-specified-yet">20014:Error string not specified yet</a></li>
<li><a href="#Invalid-argument:-core_output_filter:-writing-data-to-the-network">(22)Invalid argument: core_output_filter: writing data to the network</a></li>
<li><a href="#undefined-symbol:-apr_table_compress">undefined symbol: apr_table_compress</a></li>
<li><a href="#Variable-x-will-not-stay-shared-at">Variable $x will not stay shared at</a></li>
<li><a href="#Sometimes-it-Works-Sometimes-it-Doesnt">Sometimes it Works, Sometimes it Doesn't</a>
<ul>
<li><a href="#An-Easy-Break-in">An Easy Break-in</a></li>
<li><a href="#Thinking-mod_cgi">Thinking mod_cgi</a></li>
<li><a href="#Regular-Expression-Memory">Regular Expression Memory</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#Issues-with-APR-Used-Outside-of-mod_perl">Issues with APR Used Outside of mod_perl</a></li>
<li><a href="#Maintainers">Maintainers</a></li>
<li><a href="#Authors">Authors</a></li>
</ul>
<h1 id="NAME">NAME</h1>
<p>Troubleshooting mod_perl problems</p>
<h1 id="Description">Description</h1>
<p>Frequently encountered problems (warnings and fatal errors) and their troubleshooting.</p>
<h1 id="Building-and-Installation">Building and Installation</h1>
<h2 id="Cannot-find--lgdbm-libgdbm.so.3:-open-failed:-No-such-file-or-directory">Cannot find -lgdbm / libgdbm.so.3: open failed: No such file or directory</h2>
<p>Please see: <a>Missing or Misconfigured libgdbm.so</a>.</p>
<p>Also it seems that on Solaris this exact issue doesn't show up at compile time, but at run time, so you may see the errors like:</p>
<pre><code> .../mod_perl-1.99_17/blib/arch/auto/APR/APR.so' for module APR:
ld.so.1: /usr/local/ActivePerl-5.8/bin/perl: fatal:
libgdbm.so.3: open failed: No such file or directory at
...5.8.3/sun4-solaris-thread-multi/DynaLoader.pm line 229.</code></pre>
<p>the solution is the same, make sure that you have the libgdbm shared library and it's properly symlinked.</p>
<h1 id="Configuration-and-Startup">Configuration and Startup</h1>
<h2 id="Cant-locate-TestFilter-in_str_consume.pm-in-INC">Can't locate <i>TestFilter/in_str_consume.pm</i> in <code>@INC</code>...</h2>
<p>Sometimes you get a problem of perl not being able to locate a certain Perl module. This can happen in the mod_perl test suite or in the normal mod_perl setup. One of the possible reasons is a low limit on the number of files that can be opened by a single process. To check whether this is the problem run the process under <code>strace(1)</code> or an equivalent utility.</p>
<p>For example on OpenBSD 3.5 the default setting for a maximum number of files opened by a single process seems to be 64, so when you try to run the mod_perl test suite, which opens a few hundreds of files, you will have a problem. e.g. the test suite may fail as:</p>
<pre><code> [Wed Aug 25 09:49:40 2004] [info] 26 Apache2:: modules loaded
[Wed Aug 25 09:49:40 2004] [info] 7 APR:: modules loaded
[Wed Aug 25 09:49:40 2004] [info] base server + 20 vhosts ready
to run tests
[Wed Aug 25 09:49:40 2004] [error] Can't locate
TestFilter/in_str_consume.pm in @INC (@INC contains: ...</code></pre>
<p>Running the system calls tracing program (<code>ktrace(1)</code> on OpenBSD, <code>strace(1)</code> on Linux):</p>
<pre><code> % sudo ktrace -d /usr/local/apache/bin/httpd -d /tmp/mod_perl-2.0/t \
-f /tmp/mod_perl-2.0/t/conf/httpd.conf -DAPACHE2 -X</code></pre>
<p>looking at the ktrace dump reveals:</p>
<pre><code> 16641 httpd NAMI "/tmp/mod_perl-2.0/t/lib/TestFilter/in_str_consume.pmc"
16641 httpd RET stat -1 errno 2 No such file or directory
16641 httpd CALL open(0x3cdae100,0,0)
16641 httpd RET open -1 errno 24 Too many open files</code></pre>
<p>It's clear that Perl can't load <i>TestFilter/in_str_consume.pm</i> because it can't open the file.</p>
<p>This problem can be resolved by increasing the open file limit to 128 (or higher):</p>
<pre><code> $ ulimit -n 128</code></pre>
<h2 id="mod_perl.c-is-not-compatible-with-this-version-of-Apache-found-20020628-need-20020903">"mod_perl.c" is not compatible with this version of Apache (found 20020628, need 20020903)</h2>
<p>That error message means that mod_perl was built against Apache released on or post-20020628, but you are trying to load it against one released on or post-20020903. You will see the same error message for any other Apache module -- this is an error coming from Apache, not mod_perl.</p>
<p>Apache bumps up a special magic number every time it does a binary incompatible change, and then it makes sure that all modules that it loads were compiled against the same compatibility generation (which may include only one or quite a few Apache releases).</p>
<p>You may encounter this situation when you upgrade to a newer Apache, without rebuilding mod_perl. Or when you have several versions of Apache installed on the same system. Or when you install prepackaged binary versions which aren't coming from the source and aren't made against the same Apache version.</p>
<p>The solution is to have mod_perl built against the same Apache installed on your system. So either build from source or contact your binary version supplier and get a proper package(s) from them.</p>
<h2 id="Server-Hanging-at-the-Startup">Server Hanging at the Startup</h2>
<p>First you need to figure out where it hangs. strace(1) or an equivalent utility can be used to discover which call the server hangs on. You need to start the process in the single server mode so you will have only one process to monitor.</p>
<p>For example if the server hangs during 'make test', you should run:</p>
<pre><code> % cd modperl-2.0
% strace /path/to/httpd -d t -f t/conf/httpd.conf \
-DAPACHE2 -DONE_PROCESS -DNO_DETATCH</code></pre>
<p>(and may be <code>-DPERL_USEITHREADS</code> if it was in the original output of <code>make test</code>.)</p>
<p>If the trace ends with:</p>
<pre><code> open("/dev/random", O_RDONLY) = 3
read(3, <unfinished ...></code></pre>
<p>then you have a problem with your OS, as <i>/dev/random</i> doesn't have enough entropy to give the required random data, and therefore it hangs. This may happen in <code>apr_uuid_get()</code> C call or Perl <code>APR::UUID->new</code>.</p>
<p>The solution in this case is either to fix the problem with your OS, so that</p>
<pre><code> % perl -le 'open I, "/dev/random"; read I, $d, 10; print $d'</code></pre>
<p>will print some random data and not block. Or you can use an even simpler test:</p>
<pre><code> % cat /dev/random</code></pre>
<p>which should print some random data and not block.</p>
<p>If you can't fix the OS problem, you can rebuild Apache 2.0 with <code>--with-devrandom=/dev/urandom</code> - however, that is not secure for certain needs. Alternatively setup EGD and rebuild Apache 2.0 with <code>--with-egd</code>. Apache 2.1/apr-1.1 will have a self-contained PRNG generator built-in, which won't rely on <i>/dev/random</i>.</p>
<h2 id="No-space-left-on-device">(28)No space left on device</h2>
<p>httpd-2.0 is not very helpful at telling which device has run out of precious space. Most of the time when you get an error like:</p>
<pre><code> (28)No space left on device:
mod_rewrite: could not create rewrite_log_lock</code></pre>
<p>it means that your system have run out of semaphore arrays. Sometimes it's full with legitimate semaphores at other times it's because some application has leaked semaphores and haven't cleaned them up during the shutdown (which is usually the case when an application segfaults).</p>
<p>Use the relevant application to list the ipc facilities usage. On most Unix platforms this is usually an <code>ipcs(1)</code> utility. For example linux to list the semaphore arrays you should execute:</p>
<pre><code> % ipcs -s
------ Semaphore Arrays --------
key semid owner perms nsems
0x00000000 2686976 stas 600 1
0x00000000 2719745 stas 600 1
0x00000000 2752514 stas 600 1</code></pre>
<p>Next you have to figure out what are the dead ones and remove them. For example to remove the semid 2719745 execute:</p>
<pre><code> % ipcrm -s 2719745</code></pre>
<p>Instead of manually removing each (and sometimes there can be many of them), and if you know that none of listed the semaphores is really used (all leaked), you can try to remove them all:</p>
<pre><code> % ipcs -s | perl -ane '`ipcrm -s $F[1]`'</code></pre>
<p>httpd-2.0 seems to use the key <code>0x00000000</code> for its semaphores on Linux, so to remove only those that match that key you can use:</p>
<pre><code> % ipcs -s | perl -ane '/^0x00000000/ && `ipcrm -s $F[1]`'</code></pre>
<p>Notice that on other platforms the output of <code>ipcs -s</code> might be different, so you may need to apply a different Perl one-liner.</p>
<h2 id="Segmentation-Fault-when-Using-DBI">Segmentation Fault when Using DBI</h2>
<p>Update DBI to at least version 1.31.</p>
<h2 id="Perl-directive-missing-closing"><Perl> directive missing closing '>'</h2>
<p>See the <a>Apache2::PerlSections</a> manpage.</p>
<h2 id="Invalid-per-unknown-PerlOption:-ParseHeaders-on-HP-UX-11-for-PA-RISC">'Invalid per-unknown PerlOption: ParseHeaders' on HP-UX 11 for PA-RISC</h2>
<p>When building mod_perl 2.0 on HP-UX 11 for PA-RISC architecture, using the HP ANSI C compiler, please make sure you have installed patches PHSS_29484 and PHSS_29485. Once installed the issue should go away.</p>
<h1 id="Shutdown-and-Restart">Shutdown and Restart</h1>
<p>Issues happening during server shutdown and restart, or during specific interpreter shutdown at runtime with threaded mpm.</p>
<h2 id="Subroutines-in-perl-sections-under-threaded-mpm">Subroutines in <perl> sections under threaded mpm</h2>
<p>If you have defined a subroutine inside a <perl> section, under threaded mpm (or under perl with enabled ithreads which spawn its own ithreads), like so:</p>
<pre><code> <Perl>
sub foo {}
</Perl></code></pre>
<p>At the server shutdown, or when any interpreter quits you will see the following error in the <i>error_log</i>:</p>
<pre><code> Attempt to free temp prematurely: SV 0x91b8e74,
Perl interpreter: 0x8547698 during global destruction.
Scalars leaked: 1</code></pre>
<p>This is a bug in Perl and as of Perl 5.8.4 it's not resolved. For more information see:</p>
<p>http://rt.perl.org:80/rt3/Ticket/Display.html?id=29018</p>
<h2 id="Modules-using-Scalar::Util::weaken-under-threaded-mpm">Modules using <code>Scalar::Util::weaken</code> under threaded mpm</h2>
<p>Modules using <code>Scalar::Util::weaken</code> under threaded mpm may get:</p>
<pre><code> Attempt to free unreferenced scalar SV 0x8154f74.</code></pre>
<p>when each interprter exits.</p>
<p>This is a bug in Perl and as of Perl 5.8.4 it's not resolved. For more information see:</p>
<p>http://rt.perl.org:80/rt3/Ticket/Display.html?id=24660</p>
<h1 id="Code-Parsing-and-Compilation">Code Parsing and Compilation</h1>
<h2 id="Segfault-with-__read_nocancel-Backtrace">Segfault with __read_nocancel Backtrace</h2>
<p>If your application segfaults and you get a similar to the following backtrace:</p>
<pre><code> (gdb) bt
#0 0x4030d4d1 in __read_nocancel () from /lib/tls/libpthread.so.0
#1 0x00000000 in ?? ()</code></pre>
<p>that usually means that you've build your non-mod_perl modules with ithreads enabled perl. Then you have built a new perl <b>without</b> ithreads. But you didn't nuke/rebuild the old non-mod_perl modules. Now when you try to run those, you get the above segfault. To solve the problem recompile all the modules. The easiest way to accomplish that is to either remove all the modules completely, build the new perl and then install the new modules. You could also try to create a bundle of the existing modules using <code>CPAN.pm</code> prior to deleting the old modules, so you can easily reinstall all the modules you previously had.</p>
<h2 id="Registry-scripts-fail-to-load-with:-Unrecognized-character-xEF-at">Registry scripts fail to load with: Unrecognized character \xEF at ...</h2>
<p>Certain editors (in particular on win32) may add a UTF-8 Byte Order Marker (BOM: http://www.unicode.org/faq/utf_bom.html#BOM) at the beginning of the file. Since <code><a>ModPerl::RegistryCooker</a></code> adds extra code in front of the original script, before compiling it, it creates a situation where BOM appears past the beginning of the file, which is why the error:</p>
<pre><code> Unrecognized character \xEF at ...</code></pre>
<p>is thrown by Perl.</p>
<p>The simplest solution is to configure your editor to not add BOMs (or switch to another editor which allows you to do that).</p>
<p>You could also subclass <code><a>ModPerl::RegistryCooker</a></code> or its existing subclasses to try to remove BOM in ModPerl::RegistryCooker::read_script():</p>
<pre><code> # remove BOM
${$self->{CODE}} =~ s/^(?:
\xef\xbb\xbf |
\xfe\xff |
\xff\xfe |
\x00\x00\xfe\xff |
\xff\xfe\x00\x00
)//x;</code></pre>
<p>but do you really want to add an overhead of this operation multiple times, when you could just change the source file once? Probably not. It was also reported that on win32 the above s/// doesn't work.</p>
<h1 id="Runtime">Runtime</h1>
<h2 id="error_log-is-Full-of-Escaped-n-t-etc">error_log is Full of Escaped \n, \t, etc.</h2>
<p>It's an Apache "feature", see <code><a>-DAP_UNSAFE_ERROR_LOG_UNESCAPED</a></code>.</p>
<h2 id="Problems-with-Catching-Signals">Problems with Catching Signals</h2>
<p>See <a>Using Signal Handlers</a>.</p>
<h2 id="APR::Socket::recv:-11-Resource-temporarily-unavailable-at">APR::Socket::recv: (11) Resource temporarily unavailable at ...</h2>
<p>You need to make sure that the socket is set to <a>blocking IO mode</a> before using it.</p>
<h2 id="APR::UUID-new-Hanging"><code>APR::UUID->new</code> Hanging</h2>
<p>See <a href="#Server_Hanging_at_the_Startup">Server Hanging at the Startup</a>.</p>
<h2 id="Memory-Leaks">Memory Leaks</h2>
<ul>
<li><p>s/// in perls 5.8.1 and 5.8.2</p>
<p>p5-porters report: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-12/msg00634.html</p>
<p>Fixed in 5.8.3. There is no workaround but to upgrade to 5.8.3 or higher.</p>
</li>
</ul>
<h2 id="C-Libraries-Dont-See-ENV-Entries-Set-by-Perl-Code">C Libraries Don't See <code>%ENV</code> Entries Set by Perl Code</h2>
<p>For example some people have reported problems with <code>DBD::Oracle</code> (whose guts are implemented in C), which doesn't see environment variables (like <code>ORACLE_HOME</code>, <code>ORACLE_SID</code>, etc.) set in the perl script and therefore fails to connect.</p>
<p>The issue is that the C array <code>environ[]</code> is not thread-safe. Therefore mod_perl 2.0 unties <code>%ENV</code> from the underlying <code>environ[]</code> array under the <i><a>perl-script</a></i> handler.</p>
<p>The <code>DBD::Oracle</code> driver or client library uses <code>getenv()</code> (which fetches from the <code>environ[]</code> array). When <code>%ENV</code> is untied from <code>environ[]</code>, Perl code will see <code>%ENV</code> changes, but C code will not.</p>
<p>The <i><a>modperl</a></i> handler does not untie <code>%ENV</code> from <code>environ[]</code>. Still one should avoid setting <code>%ENV</code> values whenever possible. And if it is required, should be done at startup time.</p>
<p>In the particular case of the <code>DBD::</code> drivers, you can set the variables that don't change (<code>$ENV{ORACLE_HOME}</code> and <code>$ENV{NLS_LANG}</code> in the startup file, and those that change pass via the <code>connect()</code> method, e.g.:</p>
<pre><code> my $sid = 'ynt0';
my $dsn = 'dbi:Oracle:';
my $user = 'username/password';
my $password = '';
$dbh = DBI->connect("$dsn$sid", $user, $password)
or die "Cannot connect: " . $DBI::errstr;</code></pre>
<p>Also remember that <code>DBD::Oracle</code> requires that <i>ORACLE_HOME</i> (and any other stuff like <i>NSL_LANG</i> stuff) be in <code>%ENV</code> when <code>DBD::Oracle</code> is loaded (which might happen indirectly via the <code>DBI</code> module. Therefore you need to make sure that wherever that load happens <code>%ENV</code> is properly set by that time.</p>
<p>Another solution that works <b>only with prefork mpm</b>, is to use <code>Env::C</code> ( http://search.cpan.org/dist/Env-C/ ). This module sets the process level environ, bypassing Perl's <code>%ENV</code>. This module is not thread-safe, due to the nature of environ process struct, so don't even try using it in a threaded environment.</p>
<h2 id="Error-about-not-finding-Apache.pm-with-CGI.pm">Error about not finding <i>Apache.pm</i> with <i>CGI.pm</i></h2>
<p>You need to install at least version 3.11 of CGI.pm to work under mod_perl 2.0, as earlier CGI.pm versions aren't mod_perl 2.0 aware.</p>
<h2 id="Error-string-not-specified-yet">20014:Error string not specified yet</h2>
<p>This error is reported when some undefined Apache error happens. The known cases are:</p>
<dl>
<dt id="when-using-mod_deflate">when using mod_deflate</dt>
<dd>
<p>A bug in mod_deflate was triggering this error, when a response handler would flush the data that was flushed earlier: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22259 It has been fixed in httpd-2.0.48.</p>
</dd>
</dl>
<h2 id="Invalid-argument:-core_output_filter:-writing-data-to-the-network">(22)Invalid argument: core_output_filter: writing data to the network</h2>
<p>Apache uses the sendfile syscall on platforms where it is available in order to speed sending of responses. Unfortunately, on some systems, Apache will detect the presence of sendfile at compile-time, even when it does not work properly. This happens most frequently when using network or other non-standard file-system.</p>
<p>The whole story and the solutions are documented at: http://httpd.apache.org/docs-2.0/faq/error.html#error.sendfile</p>
<h2 id="undefined-symbol:-apr_table_compress">undefined symbol: apr_table_compress</h2>
<p>After a successful mod_perl build, sometimes during the startup or a runtime you'd get an "undefined symbol: foo" error. The following is one possible scenario to encounter this problem and possible ways to resolve it.</p>
<p>Let's say you ran mod_perl's test suite:</p>
<pre><code> % make test</code></pre>
<p>and got errors, and you looked in the <i>error_log</i> file (<i>t/logs/error_log</i>) and saw one or more "undefined symbol" errors, e.g.</p>
<pre><code> % undefined symbol: apr_table_compress</code></pre>
<dl>
<dt id="Step-1">Step 1</dt>
<dd>
<p>From the source directory (same place you ran "make test") run:</p>
<pre><code> % ldd blib/arch/auto/APR/APR.so | grep apr-</code></pre>
<p>ldd is not available on all platforms, e.g. not on Darwin/OS X. Instead on Darwin/OS X, you can use their otool.</p>
<p>You you should get a full path, for example:</p>
<pre><code> libapr-0.so.0 => /usr/local/apache2/lib/libapr-0.so.0 (0x40003000)</code></pre>
<p>or</p>
<pre><code> libapr-0.so.0 => /some/path/to/apache/lib/libapr-0.so.0 (0x40003000)</code></pre>
<p>or something like that. It's that full path to libapr-0.so.0 that you want.</p>
</dd>
<dt id="Step-2">Step 2</dt>
<dd>
<p>Do:</p>
<pre><code> % nm /path/to/your/libapr-0.so.0 | grep table_compress</code></pre>
<p>for example:</p>
<pre><code> % nm /usr/local/apache2/lib/libapr-0.so.0 | grep table_compress</code></pre>
<p>You should get something like this:</p>
<pre><code> 0000d010 T apr_table_compress</code></pre>
<p>If you get the message:</p>
<pre><code> nm: /usr/local/apache2/lib/libapr-0.so.0: no symbols</code></pre>
<p>that means that the library was stripped. You probably want to obtain Apache 2.x or libapr source, matching your binary and check it instead. Or rebuild it with debugging enabled, which will not strip the symbols.</p>
<p>Note that the "grep table_compress" is only an example, the exact string you are looking for is the name of the "undefined symbol" from the <i>error_log</i> file. So, if you get:</p>
<pre><code> undefined symbol apr_holy_grail</code></pre>
<p>then you would do:</p>
<pre><code> % nm /usr/local/apache2/lib/libapr-0.so.0 | grep holy_grail</code></pre>
</dd>
<dt id="Step-3">Step 3</dt>
<dd>
<p>Now, let's see what shared libraries your apache binary has. So, if in step 1 you got <i>/usr/local/apache2/lib/libapr-0.so.0</i> then you will do:</p>
<pre><code> % ldd /usr/local/apache2/bin/httpd</code></pre>
<p>if in step 1 you got <i>/foo/bar/apache/lib/libapr-0.so.0</i> then you do:</p>
<pre><code> % ldd /foo/bar/apache/bin/httpd</code></pre>
<p>The output should look something like this:</p>
<pre><code> libssl.so.2 => /lib/libssl.so.2 (0x40023000)
libcrypto.so.2 => /lib/libcrypto.so.2 (0x40054000)
libaprutil-0.so.0 => /usr/local/apache2/lib/libaprutil-0.so.0 (0x40128000)
libgdbm.so.2 => /usr/lib/libgdbm.so.2 (0x4013c000)
libdb-4.0.so => /lib/libdb-4.0.so (0x40143000)
libexpat.so.0 => /usr/lib/libexpat.so.0 (0x401eb000)
libapr-0.so.0 => /usr/local/apache2/lib/libapr-0.so.0 (0x4020b000)
librt.so.1 => /lib/librt.so.1 (0x40228000)
libm.so.6 => /lib/i686/libm.so.6 (0x4023a000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x4025c000)
libnsl.so.1 => /lib/libnsl.so.1 (0x40289000)
libdl.so.2 => /lib/libdl.so.2 (0x4029f000)
libpthread.so.0 => /lib/i686/libpthread.so.0 (0x402a2000)
libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)</code></pre>
<p>Those are name => value pairs showing the shared libraries used by the <code>httpd</code> binary.</p>
<p>Take note of the value for <i>libapr-0.so.0</i> and compare it to what you got in step 1. They should be the same, if not, then mod_perl was compiled pointing to the wrong Apache installation. You should run "make clean" and then</p>
<pre><code> % perl Makefile.pl MP_APACHE_CONFIG=/path/to/apache/bin/apr-config</code></pre>
<p>using the correct path for the Apache installation.</p>
</dd>
<dt id="Step-4">Step 4</dt>
<dd>
<p>You should also search for extra copies of <i>libapr-0.so.0</i>. If you find one in <i>/usr/lib</i> or <i>/usr/local/lib</i> that will explain the problem. Most likely you have an old pre-installed apr package which gets loaded before the copy you found in step 1.</p>
<p>On most Linux (and Mac OS X) machines you can do a fast search with:</p>
<pre><code> % locate libapr-0.so.0</code></pre>
<p>which searches a database of files on your machine. The "locate" database isn't always up-to-date so a slower, more comprehensive search can be run (as root if possible):</p>
<pre><code> % find / -name "libapr-0.so.0*"</code></pre>
<p>or</p>
<pre><code> % find /usr/local -name "libapr-0.so.0*"</code></pre>
<p>You might get output like this:</p>
<pre><code> /usr/local/apache2.0.47/lib/libapr-0.so.0.9.4
/usr/local/apache2.0.47/lib/libapr-0.so.0
/usr/local/apache2.0.45/lib/libapr-0.so.0.9.3
/usr/local/apache2.0.45/lib/libapr-0.so.0</code></pre>
<p>in which case you would want to make sure that you are configuring and compiling mod_perl with the latest version of apache, for example using the above output, you would do:</p>
<pre><code> % perl Makefile.PL MP_AP_CONFIG=/usr/local/apache2.0.47
% make
% make test</code></pre>
</dd>
</dl>
<p>There could be other causes, but this example shows you how to act when you encounter this problem.</p>
<h2 id="Variable-x-will-not-stay-shared-at">Variable $x will not stay shared at</h2>
<p>This warning is normally as a result of variables that your script is sharing with subroutines globally, rather than passing by value or reference. As the cause and solution of this is virtually identical to another commonly encountered problem (<a>Sometimes it works, sometimes it doesn't</a>), the text is not repeated here but is instead included in that section which follows this one.</p>
<p>You may have read somewhere <i>out there</i> that this warning can be ignored, but if you read on you will see that you should <i>never</i> ignore the warning. The other thing that might confuse you is that this warning is normally encountered when defining subroutines within subroutines. So why would you experience it in your script where that is not the case? The reason is because mod_perl wraps your script in its own subroutine (see the <a>Perl Reference</a> documentation for more details).</p>
<h2 id="Sometimes-it-Works-Sometimes-it-Doesnt">Sometimes it Works, Sometimes it Doesn't</h2>
<p>When you start running your scripts under mod_perl, you might find yourself in a situation where a script seems to work, but sometimes it screws up. And the more it runs without a restart, the more it screws up. Often the problem is easily detectable and solvable. You have to test your script under a server running in single process mode (<code>httpd -X</code>).</p>
<p>Generally the problem is the result of using global variables (normally accompanied by a <a>Variable $x will not stay shared at</a> warning). Because global variables don't change from one script invocation to another unless you change them, you can find your scripts do strange things.</p>
<p>Let's look at three real world examples:</p>
<h3 id="An-Easy-Break-in">An Easy Break-in</h3>
<p>The first example is amazing: Web Services. Imagine that you enter some site where you have an account, perhaps a free email account. Having read your own mail you decide to take a look at someone else's.</p>
<p>You type in the username you want to peek at and a dummy password and try to enter the account. On some services this will work!!!</p>
<p>You say, why in the world does this happen? The answer is simple: <b>Global Variables</b>. You have entered the account of someone who happened to be served by the same server child as you. Because of sloppy programming, a global variable was not reset at the beginning of the program and voila, you can easily peek into someone else's email! Here is an example of sloppy code:</p>
<pre><code> use vars ($authenticated);
my $q = new CGI;
my $username = $q->param('username');
my $passwd = $q->param('passwd');
authenticate($username,$passwd);
# failed, break out
unless ($authenticated){
print "Wrong passwd";
exit;
}
# user is OK, fetch user's data
show_user($username);
sub authenticate{
my ($username,$passwd) = @_;
# some checking
$authenticated = 1 if SOME_USER_PASSWD_CHECK_IS_OK;
}</code></pre>
<p>Do you see the catch? With the code above, I can type in any valid username and any dummy password and enter that user's account, provided she has successfully entered her account before me using the same child process! Since <code>$authenticated</code> is global--if it becomes 1 once, it'll stay 1 for the remainder of the child's life!!! The solution is trivial--reset <code>$authenticated</code> to 0 at the beginning of the program.</p>
<p>A cleaner solution of course is not to rely on global variables, but rely on the return value from the function.</p>
<pre><code> my $q = CGI->new;
my $username = $q->param('username');
my $passwd = $q->param('passwd');
my $authenticated = authenticate($username,$passwd);
# failed, break out
unless ($authenticated){
print "Wrong passwd";
exit;
}
# user is OK, fetch user's data
show_user($username);
sub authenticate{
my ($username,$passwd) = @_;
# some checking
return (SOME_USER_PASSWD_CHECK_IS_OK) ? 1 : 0;
}</code></pre>
<p>Of course this example is trivial--but believe me it happens!</p>
<h3 id="Thinking-mod_cgi">Thinking mod_cgi</h3>
<p>Just another little one liner that can spoil your day, assuming you forgot to reset the <code>$allowed</code> variable. It works perfectly OK in plain mod_cgi:</p>
<pre><code> $allowed = 1 if $username eq 'admin';</code></pre>
<p>But using mod_perl, and if your system administrator with superuser access rights has previously used the system, anybody who is lucky enough to be served later by the same child which served your administrator will happen to gain the same rights.</p>
<p>The obvious fix is:</p>
<pre><code> $allowed = $username eq 'admin' ? 1 : 0;</code></pre>
<h3 id="Regular-Expression-Memory">Regular Expression Memory</h3>
<p>Another good example is usage of the <code>/o</code> regular expression modifier, which compiles a regular expression once, on its first execution, and never compiles it again. This problem can be difficult to detect, as after restarting the server each request you make will be served by a different child process, and thus the regex pattern for that child will be compiled afresh. Only when you make a request that happens to be served by a child which has already cached the regex will you see the problem. Generally you miss that. When you press reload, you see that it works (with a new, fresh child). Eventually it doesn't, because you get a child that has already cached the regex and won't recompile because of the <code>/o</code> modifier.</p>
<p>An example of such a case would be:</p>
<pre><code> my $pat = $q->param("keyword");
foreach( @list ) {
print if /$pat/o;
}</code></pre>
<p>To make sure you don't miss these bugs always test your CGI in <a>single process mode</a>.</p>
<p>To solve this particular <code>/o</code> modifier problem refer to <a>Compiled Regular Expressions</a>.</p>
<p>For more details and further examples please see the <a>Perl Reference</a> documentation.</p>
<h1 id="Issues-with-APR-Used-Outside-of-mod_perl">Issues with APR Used Outside of mod_perl</h1>
<p>It doesn't strictly belong to this document, since it's talking about APR usages outside of mod_perl, so this may move to its own dedicated page, some time later.</p>
<p>Whenever using an <code>APR::</code> package outside of mod_perl, you need to:</p>
<pre><code> use APR;</code></pre>
<p>in order to load the XS subroutines. For example:</p>
<pre><code> % perl -MAPR -MAPR::UUID -le 'print APR::UUID->new->format'</code></pre>
<h1 id="Maintainers">Maintainers</h1>
<p>Maintainer is the person(s) you should contact with updates, corrections and patches.</p>
<ul>
<li><p>Stas Bekman</p>
</li>
</ul>
<h1 id="Authors">Authors</h1>
<ul>
<li><p>Stas Bekman</p>
</li>
</ul>
<p>Only the major authors are listed above. For contributors see the Changes file.</p>
</body>
</html>
|