[PHP-DEV] PHP 4.0 Bug #7940 Updated: undefined symbol: bc_compare From: astmail <email protected>
Date: 11/23/00

ID: 7940
User Update by: astmail <email protected>
Status: Open
Bug Type: Dynamic loading
Description: undefined symbol: bc_compare

Quick and dirty patch (allows at least httpsd to be started):
==============================================
--- cmp/php-4.0.3pl1/Zend/zend_extensions.c Mon Sep 25 20:10:45 2000
+++ src/php-4.0.3pl1/Zend/zend_extensions.c Thu Nov 23 16:45:08 2000
@@ -23,6 +23,15 @@
 ZEND_API zend_llist zend_extensions;
 static int last_resource_number;
 
+#if ZEND_EXTENSIONS_SUPPORT
+#ifdef COMPILE_DL_BCMATH
+int (*__bc_compare)(void *n1,void *n2)=NULL;
+void (*__str2num)(void *n,char *s,int i)=NULL;
+void (*__init_num)(void *n)=NULL;
+void (*__free_num)(void *n)=NULL;
+#endif
+#endif
+
 int zend_load_extensions(char **extension_paths)
 {
        char **p = extension_paths;
@@ -123,6 +132,17 @@
 
        zend_append_version_info(&extension);
        /*fprintf(stderr, "Loaded %s, version %s\n", extension.name, extension.version);*/
+#ifdef COMPILE_DL_BCMATH
+ if(!__bc_compare)
+ {
+ __bc_compare=DL_FETCH_SYMBOL(handle,"bc_compare");
+ __str2num=DL_FETCH_SYMBOL(handle,"str2num");
+ __init_num=DL_FETCH_SYMBOL(handle,"init_num");
+ __free_num=DL_FETCH_SYMBOL(handle,"free_num");
+ if(!__bc_compare||!__str2num||!__init_num||!__free_num)
+ __bc_compare=NULL;
+ }
+#endif
 #endif
 
        return SUCCESS;
--- cmp/php-4.0.3pl1/Zend/zend_operators.c Tue Sep 5 19:55:56 2000
+++ src/php-4.0.3pl1/Zend/zend_operators.c Thu Nov 23 16:43:08 2000
@@ -36,6 +36,15 @@
 #include "ext/bcmath/number.h"
 #endif
 
+#if ZEND_EXTENSIONS_SUPPORT
+#ifdef COMPILE_DL_BCMATH
+extern int (*__bc_compare)(void *n1,void *n2);
+extern void (*__str2num)(void *n,char *s,int i);
+extern void (*__init_num)(void *n);
+extern void (*__free_num)(void *n);
+#endif
+#endif
+
 ZEND_API double zend_string_to_double(const char *number, zend_uint length)
 {
        double divisor = 10.0;
@@ -1568,7 +1577,21 @@
        if ((ret1=is_numeric_string(s1->value.str.val, s1->value.str.len, &lval1, &dval1)) &&
                (ret2=is_numeric_string(s2->value.str.val, s2->value.str.len, &lval2, &dval2))) {
 #if WITH_BCMATH
- if ((ret1==FLAG_IS_BC) || (ret2==FLAG_IS_BC)) {
+ if (((ret1==FLAG_IS_BC) || (ret2==FLAG_IS_BC))
+#if ZEND_EXTENSIONS_SUPPORT
+#ifdef COMPILE_DL_BCMATH
+ && __bc_compare
+#endif
+#endif
+ ) {
+#if ZEND_EXTENSIONS_SUPPORT
+#ifdef COMPILE_DL_BCMATH
+#define bc_compare(a,b) (*__bc_compare)(a,b)
+#define str2num(a,b,c) (*__str2num)(a,b,c)
+#define init_num(a) (*__init_num)(a)
+#define free_num(a) (*__free_num)(a)
+#endif
+#endif
                        bc_num first, second;
 
                        /* use the BC math library to compare the numbers */
==============================================

Previous Comments:
---------------------------------------------------------------------------

[2000-11-23 06:54:51] astmail <email protected>
/usr/local/apache/bin/httpsd
Syntax error on line 241 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/libexec/libphp4.so into server: undefined symbol:
bc_compare

Excerpt from php compile time configuration:
--enable-bcmath=shared

Problem:
in Zend/zend_operators.c, function zendi_smart_strcmp(),
there is an unconditional call to bc_compare when bcmath is built, not taking care of the fact that if the bcmath extension is built as a dso it may be possibly not loaded.

Please note:
DSOs are very helpful if you do one standard build for a variety of servers and configurations so doing a non-shared build is not a solution.

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

Full Bug description available at: http://bugs.php.net/?id=7940

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>