php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50140 [PATCH] With default compilation option, php symbols are unresolved for nsapi
Submitted: 2009-11-10 18:46 UTC Modified: 2009-11-17 21:18 UTC
From: basant dot kukreja at gmail dot com Assigned: thetaphi (profile)
Status: Closed Package: iPlanet related
PHP Version: 5.3SVN-2009-11-10 (SVN) OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: basant dot kukreja at gmail dot com
New email:
PHP Version: OS:

 

 [2009-11-10 18:46 UTC] basant dot kukreja at gmail dot com
Description:
------------
On Fedora 11, by default gcc uses 
"-fvisibility=hidden", When we compile it for Sun Web Server using following
configure options, php compiles fine.
'./configure' '--with-nsapi=<server_path>' '--with-zlib' '--prefix=/usr/local'

But when we start the web server, we get the following error : 

failure: CORE2253: Error running Init function load-modules: dlsym for php5_init failed (<path>/lib/libphp5.so: undefined symbol: php5_init)
failure: server initialization failed



Expected result:
----------------
Server should be able to load php correctly.

Actual result:
--------------
Sun Web Server fails to start because of unexported symbols.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-10 18:48 UTC] basantk@php.net
Here is how symbols looks like :


$ nm .libs/libphp5.so | grep php5
004dcfb7 t php5_auth_trans
004dc661 t php5_close
004dc802 t php5_execute
004dc6d4 t php5_init

Symbols are not exported by default.

If we remove 
-fvisibility=hidden from compilation options then php compiles
fine and server is able to load libphp5.so correctly.

 [2009-11-10 18:59 UTC] basantk@php.net
Here is the snipp from gcc man page :
<man gcc>
"
 -fvisibility=default|internal|hidden|protected
...
          For those adding visibility support to existing code, you may find #pragma GCC visibility of
           use.  This works by you enclosing the declarations you wish to set visibility for with (for
           example) #pragma GCC visibility push(hidden) and #pragma GCC visibility pop. 
...
"


Pusing default visibility before including nsapi.h (and popping after) would
help in compiling and loading php correctly with nsapi servers.

Here is the patch against recent php 5.3 svn
--------------------------------------------
Index: sapi/nsapi/nsapi.c
===================================================================
--- sapi/nsapi/nsapi.c  (revision 290447)
+++ sapi/nsapi/nsapi.c  (working copy)
@@ -66,7 +66,9 @@
 /*
  * NSAPI includes
  */
+#pragma GCC visibility push(default)
 #include "nsapi.h"
+#pragma GCC visibility pop
 
 #define NSLS_D         struct nsapi_request_context *request_context
 #define NSLS_DC                , NSLS_D
--------------------------------------------


 [2009-11-10 19:14 UTC] basantk@php.net
The previous patch didn't resolve the problem, here is what helped 
resolved the issue. NSAPI_PUBLIC should have made the symbols public
but it seems it doesn't.

Index: sapi/nsapi/nsapi.c
===================================================================
--- sapi/nsapi/nsapi.c  (revision 290447)
+++ sapi/nsapi/nsapi.c  (working copy)
@@ -67,6 +67,7 @@
  * NSAPI includes
  */
 #include "nsapi.h"
+#pragma GCC visibility push(default)
 
 #define NSLS_D         struct nsapi_request_context *request_context
 #define NSLS_DC                , NSLS_D
 [2009-11-10 19:20 UTC] basantk@php.net
From nsapi.h : 

#ifdef XP_UNIX
#define NSAPI_PUBLIC
...

It seems NSAPI_PUBLIC is expanded to empty string.

--------------------------------------------

When I expanded after preprocessing nsapi.c, here is what I got :

# 915 ".../php-src-5.3/sapi/nsapi/nsapi.c"
int php5_init(pblock *pb, Session *sn, Request *rq)

--------------------------------------
So we need to tell gcc to export the NSAPI_PUBLIC symbols.
 [2009-11-11 12:35 UTC] jani@php.net
Check how this is fixed for Apache: sapi/apache2handler/php_apache.h and search for "visibility". I think you should do that instead of using any #pragma's.
 [2009-11-11 17:39 UTC] basantk@php.net
Thanks Jani for your suggestion. Based on your suggestion, I have
revised the patch. Here is the new patch :
---------------------------------------------
Index: sapi/nsapi/nsapi.c
===================================================================
--- sapi/nsapi/nsapi.c	(revision 290447)
+++ sapi/nsapi/nsapi.c	(working copy)
@@ -67,6 +67,11 @@
  * NSAPI includes
  */
 #include "nsapi.h"
+/* fix for gcc4 visibility issue */
+#ifndef PHP_WIN32
+# undef NSAPI_PUBLIC
+# define NSAPI_PUBLIC PHPAPI
+#endif
 
 #define NSLS_D		struct nsapi_request_context *request_context
 #define NSLS_DC		, NSLS_D
-------------------------------------------

With this patch, when I preprocess the file, on linux I get following
for php5_init :

int __attribute__ ((visibility("default"))) php5_init(pblock *pb, Session *sn, Request *rq)
-------------------------------------------

The above correctly export the symbols.

 [2009-11-17 19:58 UTC] basantk@php.net
Here is the link to the patch (submitted in previous comments) :
http://bitbucket.org/basantk/phpbugs/raw/d3b5e6d6e344/php_gcc_nsapi_fix.txt

 [2009-11-17 20:47 UTC] thetaphi@php.net
I'll take care. Thanks for the patch!

Will commit this to 5.3 and trunk.
 [2009-11-17 21:17 UTC] svn@php.net
Automatic comment from SVN on behalf of thetaphi
Revision: http://svn.php.net/viewvc/?view=revision&revision=290887
Log: Fix bug #50140: With default compilation option, php symbols are unresolved for nsapi
 [2009-11-17 21:18 UTC] thetaphi@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

I'll committed to trunk and PHP_5_3 branch.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 07:01:29 2024 UTC