[PHP-CVS] [php-src] master: Tests: Fixes leaked System V shared-memory segments in tests (#22911)

[email protected] (NickSdot via GitHub) Wed, 29 Jul 2026 18:05:36 +0000
Newsgroups php.cvs
Message-ID <[email protected]>
Author: NickSdot (NickSdot)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-07-30T02:05:33+08:00

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

 Tests: Fixes leaked System V shared-memory segments in tests (#22911)

The two tests leave System V IPC segments behind after successful execution.
Repeated test-suite runs can exhaust IPC limits and cause unrelated SHMOP/SysV
tests to fail.

Changed paths:
  M  ext/shmop/tests/shmop_open_private.phpt
  M  ext/sysvshm/tests/gh16591.phpt


Diff:

diff --git a/ext/shmop/tests/shmop_open_private.phpt b/ext/shmop/tests/shmop_open_private.phpt
index 8757de0a6334..0ba74e5af65c 100644
--- a/ext/shmop/tests/shmop_open_private.phpt
+++ b/ext/shmop/tests/shmop_open_private.phpt
@@ -13,6 +13,8 @@ $shm2 = shmop_open(0, 'c', 0777, 1024);
 $read = shmop_read($shm2, 0, 4);
 
 var_dump(is_string($read) && $read !== $write);
+shmop_delete($shm1);
+shmop_delete($shm2);
 ?>
 --EXPECT--
 bool(true)
diff --git a/ext/sysvshm/tests/gh16591.phpt b/ext/sysvshm/tests/gh16591.phpt
index d3ece7cd796a..fb1c58168f57 100644
--- a/ext/sysvshm/tests/gh16591.phpt
+++ b/ext/sysvshm/tests/gh16591.phpt
@@ -13,11 +13,15 @@ class C {
     }
 }
 
-$mem = shm_attach(1);
+$key = ftok(__FILE__, 't');
+$mem = shm_attach($key);
+$cleanup = shm_attach($key);
 try {
     shm_put_var($mem, 1, new C);
 } catch (Error $e) {
     echo $e->getMessage(), "\n";
+} finally {
+    shm_remove($cleanup);
 }
 
 ?>