[php-src] master: `abort()` in OOM case

Florian Engelhardt via Arnaud Le Blanc <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Florian Engelhardt (realFlowControl)
Committer: Arnaud Le Blanc (arnaud-lb)
Date: 2026-07-13T12:41:56+02:00

Commit: https://github.com/php/php-src/commit/cf3c803b506709c2af84c2be84e7746a97868a3e
Raw diff: https://github.com/php/php-src/commit/cf3c803b506709c2af84c2be84e7746a97868a3e.diff

`abort()` in OOM case

Closes GH-22637

Changed paths:
  M  NEWS
  M  UPGRADING
  M  Zend/zend_alloc.c


Diff:

diff --git a/NEWS b/NEWS
index b2544cb5abdf..2fa31ab34fde 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ PHP                                                                        NEWS
     iterator). (iliaal)
   . Lock unmodified readonly properties for modification after clone-with.
     (NickSdot)
+  . abort() instead of exit() on hard OOM. (realFlowControl)
 
 - Calendar:
   . Fixed bug GH-22602 (gregoriantojd() and juliantojd() integer overflow with
diff --git a/UPGRADING b/UPGRADING
index a809687d1961..729dfed0363e 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -533,6 +533,10 @@ PHP 8.6 UPGRADE NOTES
 13. Other Changes
 ========================================
 
+- Core:
+  . In case of a hard OOM PHP now calls abort() instead of exit(1), changing
+    the exit code to 134 and possibly creating a core dump.
+
 ========================================
 14. Performance Improvements
 ========================================
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 0b040743abf1..5ff2860d8223 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -2974,7 +2974,7 @@ ZEND_API void refresh_memory_manager(void)
 static ZEND_COLD ZEND_NORETURN void zend_out_of_memory(void)
 {
 	fprintf(stderr, "Out of memory\n");
-	exit(1);
+	abort();
 }
 
 #if ZEND_MM_CUSTOM
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.