Bug #70724 [Asn->Csd]: Undefined Symbols from opcache.so on Mac OS X 10.10

From: Date: Sat, 17 Oct 2015 08:53:29 +0000
Subject: Bug #70724 [Asn->Csd]: Undefined Symbols from opcache.so on Mac OS X 10.10
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196657@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70724&edit=1

 ID:                 70724
 Updated by:         laruence@php.net
 Reported by:        for-bugs at hnw dot jp
 Summary:            Undefined Symbols from opcache.so on Mac OS X 10.10
-Status:             Assigned
+Status:             Closed
 Type:               Bug
 Package:            opcache
 Operating System:   Mac OS X
 PHP Version:        7.0.0RC5
 Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d4df6641c871e23478c3137365f682c38d8d95a3
Log: Fixed bug #70724 (Undefined Symbols from opcache.so on Mac OS X 10.10)


Previous Comments:
------------------------------------------------------------------------
[2015-10-17 06:13:13] for-bugs at hnw dot jp

Thanks, Laruence.

Your patch works fine on my environment.

------------------------------------------------------------------------
[2015-10-17 03:34:16] laruence@php.net

could you please verify this patch?

diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index e6d7005..c4b66ea 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -2517,13 +2517,13 @@ static int accel_remap_huge_pages(void *start, size_t size, const char
*name, si
 	}
 	memcpy(mem, start, size);
 
-#ifdef MAP_HUGETLB
+#  ifdef MAP_HUGETLB
 	ret = mmap(start, size,
 		PROT_READ | PROT_WRITE | PROT_EXEC,
 		MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED | MAP_HUGETLB,
 		-1, 0);
-#endif
-#ifdef MADV_HUGEPAGE
+#  endif
+#  ifdef MADV_HUGEPAGE
 	if (ret == MAP_FAILED) {
 		ret = mmap(start, size,
 			PROT_READ | PROT_WRITE | PROT_EXEC,
@@ -2531,7 +2531,7 @@ static int accel_remap_huge_pages(void *start, size_t size, const char *name,
si
 			-1, 0);
 		madvise(start, size, MADV_HUGEPAGE);
 	}
-#endif
+#  endif
 	if (ret == start) {
 	    memcpy(start, mem, size);
 		mprotect(start, size, PROT_READ | PROT_EXEC);
@@ -2565,7 +2565,12 @@ static void accel_move_code_to_huge_pages(void)
 		fclose(f);
 	}
 }
-# endif
+# else
+static void accel_move_code_to_huge_pages(void)
+{
+	return;
+}
+# endif /* defined(MAP_HUGETLB) || defined(MADV_HUGEPAGE) */
 #endif /* HAVE_HUGE_CODE_PAGES */
 
 static int accel_startup(zend_extension *extension)
diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c
index bd53f6e..0d87e46 100644
--- a/ext/opcache/zend_accelerator_module.c
+++ b/ext/opcache/zend_accelerator_module.c
@@ -242,7 +242,6 @@ static ZEND_INI_MH(OnEnable)
 }
 
 #ifdef HAVE_OPCACHE_FILE_CACHE
-
 static ZEND_INI_MH(OnUpdateFileCache)
 {
 	if (new_value) {
@@ -269,6 +268,18 @@ static ZEND_INI_MH(OnUpdateFileCache)
 }
 #endif
 
+#ifdef HAVE_HUGE_CODE_PAGES
+static ZEND_INI_MH(OnUpdateHugeCodePages)
+{
+# if defined(MAP_HUGETLB) || defined(MADV_HUGEPAGE)
+	OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+# else
+	zend_accel_error(ACCEL_LOG_WARNING, "opcache.huge_code_pages has no affect as huge page is
not avaliable\n");
+# endif
+	return SUCCESS;
+}
+#endif
+
 ZEND_INI_BEGIN()
 	STD_PHP_INI_BOOLEAN("opcache.enable"             , "1", PHP_INI_ALL,   
OnEnable,     enabled                             , zend_accel_globals, accel_globals)
 	STD_PHP_INI_BOOLEAN("opcache.use_cwd"            , "1", PHP_INI_SYSTEM,
OnUpdateBool, accel_directives.use_cwd            , zend_accel_globals, accel_globals)
@@ -313,7 +324,7 @@ ZEND_INI_BEGIN()
 	STD_PHP_INI_ENTRY("opcache.file_cache_fallback"           , "1"   ,
PHP_INI_SYSTEM, OnUpdateBool,	   accel_directives.file_cache_fallback,           zend_accel_globals,
accel_globals)
 #endif
 #ifdef HAVE_HUGE_CODE_PAGES
-	STD_PHP_INI_BOOLEAN("opcache.huge_code_pages"             , "0"   ,
PHP_INI_SYSTEM, OnUpdateBool,      accel_directives.huge_code_pages,              
zend_accel_globals, accel_globals)
+	STD_PHP_INI_BOOLEAN("opcache.huge_code_pages"             , "0"   ,
PHP_INI_SYSTEM, OnUpdateHugeCodePages,      accel_directives.huge_code_pages,              
zend_accel_globals, accel_globals)
 #endif
 ZEND_INI_END()



thanks

------------------------------------------------------------------------
[2015-10-16 10:46:08] requinix@php.net

Note that #70725 has a potential patch attached to it.

------------------------------------------------------------------------
[2015-10-16 10:45:51] requinix@php.net

Related To: Bug #70725

------------------------------------------------------------------------
[2015-10-16 07:47:52] for-bugs at hnw dot jp

Description:
------------
I built and ran PHP 7.0.0RC5 on Mac OS X 10.10.
Then "Symbol not found" error occurred.

On the same machine, 7.0.0RC2 runs correctly.

The correct binary can be built by "./configure --disable-huge-code-pages".
On Mac OS X, "HAVE_HUGE_CODE_PAGES" should be undefined.

Test script:
---------------
<?php
echo 1;

Expected result:
----------------
1

Actual result:
--------------
dyld: lazy symbol binding failed: Symbol not found: _accel_move_code_to_huge_pages
  Referenced from:
/Users/hnw/.phpenv/versions/7.0.0RC5/lib/php/extensions/no-debug-non-zts-20151012/opcache.so
  Expected in: flat namespace

dyld: Symbol not found: _accel_move_code_to_huge_pages
  Referenced from:
/Users/hnw/.phpenv/versions/7.0.0RC5/lib/php/extensions/no-debug-non-zts-20151012/opcache.so
  Expected in: flat namespace

Trace/BPT trap: 5


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



--
Edit this bug report at https://bugs.php.net/bug.php?id=70724&edit=1


Thread (5 messages)

« previous php.bugs (#196657) next »