Bug 26088 - regexp broken, pcre conflicts with HP-UX system lib with DSO and gcc
Summary: regexp broken, pcre conflicts with HP-UX system lib with DSO and gcc
Status: RESOLVED DUPLICATE of bug 27550
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Core (show other bugs)
Version: 2.0.48
Hardware: HP HP-UX
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Depends on:
Reported: 2004-01-13 11:51 UTC by Deron Meranda
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Deron Meranda 2004-01-13 11:51:14 UTC
Regular expression support is completely broken under HP-UX 11.0, whether in
core or in modules such as mod_rewrite.  Compiled with gcc 3.3 (32-bit) and with
most eveverything as DSOs (shared libraries).  Also compiled with OpenSSL 0.9.7c
 which are dynamic libraries themselves.

This appears to be a link-time conflict between the embedded PCRE library in
Apache and the libc system library in HP-UX.  HP's /usr/lib/libc.sl library
defines the code symbols regcomp, regexec, regerror, and regfree; all of which
are incompatible with pcre's posix api's (or at least pcre's headers).

I was able to determine that during the Apache compile, the embedded PCRE header
files were being used (which defined all the REG* enum identifiers, such as
REG_NOMATH=17).  But at runtime the call to regexec inside the APR wrappers (in
util.c) would routinely get back result codes of 20.  Under HP-UX, REG_NOMATCH
is defined to be 20.  Interesting no core was ever produced, but no regex's
would match either.

I was also able to determine that during the libtool linking of .libs/httpd that
the pcreposix.o object file would never be inserted into the executable (despite
the pcre library being presented to libtool's link command).

By carefully reordering the low-level link command executed by libtool, I was
able to force the pcreposix.o object file into httpd.  I basically moved the
pcre library immediately after libmain instead of after all the OpenSSL dynamic
library link flags.  This allowed the core regex's to work (such as in
DirectoryMatch), but those in modules such as mod_rewrite would still fail.

I eventually got everything to work by simply renaming the four functions in the
Apache codebase so they no longer conflicted with HP's:

   regcomp()  ->  posix_regcomp()
   regexec()  ->  posix_regexec()
   regerror() ->  posix_regerror()
   regfree()  ->  posix_regfree()

Those appear in these source files:

  srclib/pcre/pcreposix.c, .h

With no changes other than renaming those four function identifiers, regular
expressions are now fully working both in core and in modules.
Comment 1 Joe Orton 2004-03-09 23:55:40 UTC
Dup'ing against a newer report which has attached patches; thanks for the report
and analysis.

*** This bug has been marked as a duplicate of 10734 ***
Comment 2 Joe Orton 2004-03-09 23:56:24 UTC
I must stop screwing that up...
Comment 3 Joe Orton 2004-03-09 23:57:29 UTC
Reduping against a bug number not an attachment number....

*** This bug has been marked as a duplicate of 27550 ***