php / php/php-src

opcache/zend_shared_alloc.c: needed but ineffective pre-processor instructions

Aperta
#16,567 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Bug Extension: opcache Status: Verified
Lingua principale
C
Stelle
40.4k
Fork
8.1k
Merge medio
2g 13h
PR unite (30g)
96

Descrizione

Description

_GNU_SOURCE enabled sys/mman.h is needed for memfd_create and MFD_CLOEXEC, yet the needed pre-processor instructions at the top of zend_shared_alloc.c are useless since they are wrapped with ifdef HAVE_MEMFD_CREATE, which is defined in a *config.h not yet included.

See https://github.com/php/php-src/blob/master/ext/opcache/zend_shared_alloc.c#L22-L27

As a consequence, the build failed for me on Ubuntu-24.04 with GCC-13.

'./configure' \
'--disable-all' \
'--enable-debug' \
'--enable-cli' \
'--enable-opcache' 
make -j
/bin/bash /home/mike/src/php-src/libtool --silent --preserve-dup-deps --tag=CC --mode=compile cc -Iext/opcache/ -I/home/mike/src/php-src/ext/opcache/ -I/home/mike/src/php-src/main -I/home/mike/src/php-src -I/home/mike/src/php-src/ext/date/lib -I/home/mike/src/php-src/ext/raphf/src -I/home/mike/src/php-src/ext/raphf -I/home/mike/src/php-src/ext/http/src -I/home/mike/src/php-src/TSRM -I/home/mike/src/php-src/Zend    -fno-common -Wstrict-prototypes -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -g -ffp-contract=off -fvisibility=hidden -O0 -Wno-strict-prototypes -Wimplicit-fallthrough=1 -DZEND_SIGNALS    -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -Iext/opcache/jit/ir -DIR_TARGET_X64 -DIR_PHP -DIR_DEBUG -DZEND_COMPILE_DL_EXT=1 -c /home/mike/src/php-src/ext/opcache/zend_shared_alloc.c -o ext/opcache/zend_shared_alloc.lo  -MMD -MF ext/opcache/zend_shared_alloc.dep -MT ext/opcache/zend_shared_alloc.lo
In file included from /home/mike/src/php-src/Zend/zend.h:454,
                 from /home/mike/src/php-src/Zend/zend_objects.h:23,
                 from /home/mike/src/php-src/Zend/zend_globals.h:35,
                 from /home/mike/src/php-src/Zend/zend_compile.h:843,
                 from /home/mike/src/php-src/Zend/zend_extensions.h:23,
                 from /home/mike/src/php-src/ext/opcache/ZendAccelerator.h:51,
                 from /home/mike/src/php-src/ext/opcache/zend_shared_alloc.c:30:
/home/mike/src/php-src/Zend/zend_operators.h: In function ‘zend_memrchr’:
/home/mike/src/php-src/Zend/zend_operators.h:221:29: warning: implicit declaration of function ‘memrchr’; did you mean ‘memchr’? [-Wimplicit-function-declaration]
  221 |         return (const void*)memrchr(s, c, n);
      |                             ^~~~~~~
      |                             memchr
/home/mike/src/php-src/Zend/zend_operators.h:221:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
  221 |         return (const void*)memrchr(s, c, n);
      |                ^
/home/mike/src/php-src/ext/opcache/zend_shared_alloc.c: In function ‘zend_shared_alloc_create_lock’:
/home/mike/src/php-src/ext/opcache/zend_shared_alloc.c:98:21: warning: implicit declaration of function ‘memfd_create’; did you mean ‘timer_create’? [-Wimplicit-function-declaration]
   98 |         lock_file = memfd_create("opcache_lock", MFD_CLOEXEC);
      |                     ^~~~~~~~~~~~
      |                     timer_create
/home/mike/src/php-src/ext/opcache/zend_shared_alloc.c:98:50: error: ‘MFD_CLOEXEC’ undeclared (first use in this function); did you mean ‘FD_CLOEXEC’?
   98 |         lock_file = memfd_create("opcache_lock", MFD_CLOEXEC);
      |                                                  ^~~~~~~~~~~
      |                                                  FD_CLOEXEC
/home/mike/src/php-src/ext/opcache/zend_shared_alloc.c:98:50: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Makefile:794: ext/opcache/zend_shared_alloc.lo] Error 1
PHP Version

master

Operating System

Ubuntu 24.04

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Il file interessato è ext/opcache/zend_shared_alloc.c, con il blocco del preprocessore vicino alle righe 22-27. Riproduci il problema con le opzioni di configure indicate e make -j su Ubuntu 24.04, quindi conferma che la compilazione di opcache venga completata senza gli errori memfd_create/MFD_CLOEXEC.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
c, php
Ambito
build-system
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.