# PCRE symbol visibility bug

- Thread: https://externals.io/message/42209
- Original archive: https://news-web.php.net/php.internals/42209
- Started by shire on 2008-12-09T22:09:11+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #42209 — shire — 2008-12-09T22:09:11+00:00

URL: https://externals.io/message/42209#42209

When using GCC 4.x with php-5.3, and an extension (such as APC) that  
references PCRE functions (pcre_exec) that are bundled with PHP in the  
pcre extension.  The symbols defined in the PHP binaries don't include  
a visibility "default" attribute, and are currently set to "hidden" in  
CFLAGS.  This makes the symbols unavailable to any .so extension,  
which triggers a fault.

It seems like adding the visibility attribute to the bundled PHP code  
should fix this, but I wanted to post here as perhaps someone has a  
better suggestion.  It would probably be better if this didn't modify  
the pcrelib/* files.  I've included a patch as a possible fix, I can  
go ahead and commit this if this is what we want, but I'm hoping  
someone has some other suggestions.


before:
shire@shirebook:/usr/local/apache/libexec$ nm `which php` | grep  
pcre_exec
000266b4 t _php_pcre_exec

after:
shire@shirebook:/usr/local/apache/libexec$ nm `which php` | grep  
pcre_exec
000266b4 T _php_pcre_exec


cvs diff: Diffing .
cvs diff: Diffing doc
Index: pcre_internal.h
===================================================================
RCS file: /repository/php-src/ext/pcre/pcrelib/pcre_internal.h,v
retrieving revision 1.1.2.1.2.5.2.5
diff -u -r1.1.2.1.2.5.2.5 pcre_internal.h
--- pcre_internal.h     9 Sep 2008 07:55:08 -0000       1.1.2.1.2.5.2.5
+++ pcre_internal.h     9 Dec 2008 22:05:57 -0000
@@ -119,9 +119,17 @@
  #    endif
  #  else
  #    ifdef __cplusplus
-#      define PCRE_EXP_DECL       extern "C"
+#      if defined(__GNUC__) && __GNUC__ >= 4
+#        define PCRE_EXP_DECL       __attribute__  
((visibility("default"))) extern "C"
+#      else
+#        define PCRE_EXP_DECL       extern "C"
+#      endif
  #    else
-#      define PCRE_EXP_DECL       extern
+#      if defined(__GNUC__) && __GNUC__ >= 4
+#        define PCRE_EXP_DECL       __attribute__  
((visibility("default"))) extern
+#      else
+#        define PCRE_EXP_DECL       extern
+#      endif
  #    endif
  #    ifndef PCRE_EXP_DEFN
  #      define PCRE_EXP_DEFN       PCRE_EXP_DECL


-shire

---

## #42211 — Nuno Lopes — 2008-12-10T10:16:52+00:00

URL: https://externals.io/message/42209#42211 · In reply to: #42209

I've commited a fix. I didn't patch the pcre_internal.h file directly, 
otherwise the patch would be reverted on the next upgrade of the pcre lib.

Thanks,
Nuno

----- Original Message ----- 
From: "shire" <shire@php.net>
To: "PHP Internals List" <internals@lists.php.net>
Sent: Tuesday, December 09, 2008 10:09 PM
Subject: [PHP-DEV] PCRE symbol visibility bug


>
> When using GCC 4.x with php-5.3, and an extension (such as APC) that 
> references PCRE functions (pcre_exec) that are bundled with PHP in the 
> pcre extension.  The symbols defined in the PHP binaries don't include  a 
> visibility "default" attribute, and are currently set to "hidden" in 
> CFLAGS.  This makes the symbols unavailable to any .so extension,  which 
> triggers a fault.
>
> It seems like adding the visibility attribute to the bundled PHP code 
> should fix this, but I wanted to post here as perhaps someone has a 
> better suggestion.  It would probably be better if this didn't modify  the 
> pcrelib/* files.  I've included a patch as a possible fix, I can  go ahead 
> and commit this if this is what we want, but I'm hoping  someone has some 
> other suggestions.
>
>
> before:
> shire@shirebook:/usr/local/apache/libexec$ nm `which php` | grep 
> pcre_exec
> 000266b4 t _php_pcre_exec
>
> after:
> shire@shirebook:/usr/local/apache/libexec$ nm `which php` | grep 
> pcre_exec
> 000266b4 T _php_pcre_exec
>
>
> cvs diff: Diffing .
> cvs diff: Diffing doc
> Index: pcre_internal.h
> ===================================================================
> RCS file: /repository/php-src/ext/pcre/pcrelib/pcre_internal.h,v
> retrieving revision 1.1.2.1.2.5.2.5
> diff -u -r1.1.2.1.2.5.2.5 pcre_internal.h
> --- pcre_internal.h     9 Sep 2008 07:55:08 -0000       1.1.2.1.2.5.2.5
> +++ pcre_internal.h     9 Dec 2008 22:05:57 -0000
> @@ -119,9 +119,17 @@
>  #    endif
>  #  else
>  #    ifdef __cplusplus
> -#      define PCRE_EXP_DECL       extern "C"
> +#      if defined(__GNUC__) && __GNUC__ >= 4
> +#        define PCRE_EXP_DECL       __attribute__ 
> ((visibility("default"))) extern "C"
> +#      else
> +#        define PCRE_EXP_DECL       extern "C"
> +#      endif
>  #    else
> -#      define PCRE_EXP_DECL       extern
> +#      if defined(__GNUC__) && __GNUC__ >= 4
> +#        define PCRE_EXP_DECL       __attribute__ 
> ((visibility("default"))) extern
> +#      else
> +#        define PCRE_EXP_DECL       extern
> +#      endif
>  #    endif
>  #    ifndef PCRE_EXP_DEFN
>  #      define PCRE_EXP_DEFN       PCRE_EXP_DECL
>
>
> -shire
