Skip to content

Commit 81e4100

Browse files
shivammathurgithub-actions[bot]
authored andcommitted
Use ITIMER_REAL for timeout handling on MacOS / Apple Silicon system
setitimer(ITIMER_PROF) fires too early on MacOS 14 when running on Apple Silicon. See https://openradar.appspot.com/radar?id=5583058442911744. Fixes GH-12814 Closes GH-13567
1 parent 4e7e936 commit 81e4100

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Zend/zend_execute_API.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,9 @@ void zend_set_timeout(long seconds, int reset_signals) /* {{{ */
12961296
t_r.it_value.tv_sec = seconds;
12971297
t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0;
12981298

1299-
# ifdef __CYGWIN__
1299+
# if defined(__CYGWIN__) || (defined(__aarch64__) && defined(__APPLE__))
1300+
// ITIMER_PROF is broken in Apple Silicon system with MacOS >= 14
1301+
// See https://openradar.appspot.com/radar?id=5583058442911744.
13001302
setitimer(ITIMER_REAL, &t_r, NULL);
13011303
}
13021304
signo = SIGALRM;
@@ -1344,7 +1346,7 @@ void zend_unset_timeout(TSRMLS_D) /* {{{ */
13441346

13451347
no_timeout.it_value.tv_sec = no_timeout.it_value.tv_usec = no_timeout.it_interval.tv_sec = no_timeout.it_interval.tv_usec = 0;
13461348

1347-
#ifdef __CYGWIN__
1349+
#if defined(__CYGWIN__) || (defined(__aarch64__) && defined(__APPLE__))
13481350
setitimer(ITIMER_REAL, &no_timeout, NULL);
13491351
#else
13501352
setitimer(ITIMER_PROF, &no_timeout, NULL);

0 commit comments

Comments
 (0)