Bug #70973 [Com]: Segmentation fault when no huge pages available

From: Date: Fri, 27 Nov 2015 20:21:08 +0000
Subject: Bug #70973 [Com]: Segmentation fault when no huge pages available
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-197470@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70973&edit=1

 ID:                 70973
 Comment by:         cv at jet9 dot ru
 Reported by:        cv at jet9 dot ru
 Summary:            Segmentation fault when no huge pages available
 Status:             Closed
 Type:               Bug
 Package:            opcache
 Operating System:   CentOS 6
 PHP Version:        7.0.0RC7
 Assigned To:        laruence
 Block user comment: N
 Private report:     N

 New Comment:

I've just checked on commit e9a8d7ff1d59cbcaf4b5cec728a94fb0d54dd993, it's all right. Got
warning "Zend OPcachehuge_code_pages: mmap(HUGETLB) failed: Cannot allocate memory (12)"
and than run continues fine.

Fix confirmed, thanks.


Previous Comments:
------------------------------------------------------------------------
[2015-11-27 16:30:47] laruence@php.net

The fix for this bug has been committed.

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/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

it should be fixed  http://git.php.net/?p=php-src.git;a=commit;h=e9a8d7ff1d59cbcaf4b5cec728a94fb0d54dd993

------------------------------------------------------------------------
[2015-11-27 15:32:36] laruence@php.net

Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e9a8d7ff1d59cbcaf4b5cec728a94fb0d54dd993
Log: Fixed bug #70977, #70973 (Segmentation fault with opcache.huge_code_pages=1)

------------------------------------------------------------------------
[2015-11-27 11:53:42] laruence@php.net

how about this one? http://pastebin.com/sqXMzZLT

thanks

------------------------------------------------------------------------
[2015-11-26 15:51:28] cv at jet9 dot ru

No, the bug still exists. With the patch applied the function accel_move_code_to_huge_pages()
returns and segfault raises later:

(gdb) br /usr/src/debug/php-7.0.0RC8/ext/opcache/ZendAccelerator.c:2620
(gdb) run
Breakpoint 1, accel_startup (extension=<value optimized out>) at
/usr/src/debug/php-7.0.0RC8/ext/opcache/ZendAccelerator.c:2620
2620                    if (!ZCG(accel_directives).enable_cli &&
(gdb) n
2619                    accel_startup_ok = 0;
(gdb)
2620                    if (!ZCG(accel_directives).enable_cli &&
(gdb)
2621                        strcmp(sapi_module.name, "cli") == 0) {
(gdb)
2620                    if (!ZCG(accel_directives).enable_cli &&
(gdb)
2622                            zps_startup_failure("Opcode Caching is disabled for CLI",
NULL, accelerator_remove_cb);
(gdb)

Program received signal SIGSEGV, Segmentation fault.
zend_llist_del_element (l=0x9dc8e0, element=0x0, compare=0x7fffedf40590
<accelerator_remove_cb>) at /usr/src/debug/php-7.0.0RC8/Zend/zend_llist.c:91
91      {

------------------------------------------------------------------------
[2015-11-26 04:10:56] laruence@php.net

I can not reproduce this simply, so could you please test with this patch?

diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index e23e751..ae10d12 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -2531,7 +2531,7 @@ static int accel_remap_huge_pages(void *start, size_t size, const char *name,
si
                        PROT_READ | PROT_WRITE | PROT_EXEC,
                        MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
                        -1, 0);
-           if (-1 == madvise(start, size, MADV_HUGEPAGE)) {
+         if (ret == MAP_FAILED || -1 == madvise(start, size, MADV_HUGEPAGE)) {
                        munmap(mem, size);
                        return -1;
                }

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=70973


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


Thread (6 messages)

« previous php.bugs (#197470) next »