php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70724 Undefined Symbols from opcache.so on Mac OS X 10.10
Submitted: 2015-10-16 07:47 UTC Modified: 2015-10-17 06:13 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: for-bugs at hnw dot jp Assigned: laruence (profile)
Status: Closed Package: opcache
PHP Version: 7.0.0RC5 OS: Mac OS X
Private report: No CVE-ID: None
 [2015-10-16 07:47 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-10-16 10:46 UTC] requinix@php.net
Note that #70725 has a potential patch attached to it.
 [2015-10-17 03:34 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2015-10-17 03:34 UTC] 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-17 06:13 UTC] for-bugs at hnw dot jp
Thanks, Laruence.

Your patch works fine on my environment.
 [2015-10-17 08:53 UTC] laruence@php.net
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)
 [2015-10-17 08:53 UTC] laruence@php.net
-Status: Assigned +Status: Closed
 [2015-10-25 12:42 UTC] ab@php.net
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=74004a160d0f606202a4745f4abdd54dbca95238
Log: Fixed bug #70724 (Undefined Symbols from opcache.so on Mac OS X 10.10)
 [2016-07-20 11:36 UTC] davey@php.net
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)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC