php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77517 SHMOP crashes Apache
Submitted: 2019-01-24 19:00 UTC Modified: 2019-02-03 04:22 UTC
From: truxoft at gmail dot com Assigned: cmb (profile)
Status: No Feedback Package: *Extensibility Functions
PHP Version: 5.6.40 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: truxoft at gmail dot com
New email:
PHP Version: OS:

 

 [2019-01-24 19:00 UTC] truxoft at gmail dot com
Description:
------------
When opening a SHMOP (shared memory) block more than once, Apache shuts down without any error message and without any traces in the error log even with debug log level activated. 

In my script, I open a SHMOP block for writing to it in a long loop, and opening a second instance of the same block in a background task, polling the shared memory block in a read access mode. In around half of the cases, it crashes the Apache server when attempting to close the memory block (which happens automatically at the end of the script anyway).

I tested also the reversed order of closing the first and the second SHMOP instance, with no difference in the outcome.

The simple script below demonstrates this behaviour in a minimalized way. It merges both accesses in the same script, although in the true application they are independent processes. It still results in an Apache crash in around half of the cases (not always though). When invoking the script from the command line (bypassing Apache), I did not observe any errors or crashes - unlike in Apache, the expected results is always given back.

This issue might be perhaps related to https://bugs.php.net/bug.php?id=55070
I use the last available Windows build of PHP 5.6.40 on Apache 2.4.38 with mod₋php, both thread-safe, 32bits. In my application I cannot use v7, but if there is any interest, I might try installing it, and attempting to simulate the bug with v7 too.

I am attaching a backtrace, too. Please do not hesitate to ask for more details or backtraces.

Test script:
---------------
<?php

$smid1 = shmop_open(1, "c", 0600, 64);
$smid2 = shmop_open(1, "a", 0, 0);

shmop_write($smid1, "Test Test", 0);
echo "SHMOP READ = ".shmop_read($smid2, 0, 4);

shmop_delete($smid1);
shmop_close($smid1);
shmop_close($smid2);

?>


Expected result:
----------------
SHMOP READ = Test

Actual result:
--------------
[24/01/2019 19:06:48]
  C:\WINDOWS\SysWOW64\napinsp.dll loaded at 0x6cb00000
  C:\WINDOWS\SysWOW64\pnrpnsp.dll loaded at 0x6cae0000
  C:\WINDOWS\SysWOW64\NLAapi.dll loaded at 0x6bae0000
  C:\WINDOWS\SysWOW64\winrnr.dll loaded at 0x6bad0000
  C:\WINDOWS\SysWOW64\wshbth.dll loaded at 0x6bab0000
  C:\Windows\SysWOW64\rasadhlp.dll loaded at 0x68660000
  C:\WINDOWS\SysWOW64\fwpuclnt.dll loaded at 0x64680000
  Thread created. New thread - System ID: 264
[24/01/2019 19:06:51]
  Exception 0XC0000005 on thread 18552. DetailID = 1
[24/01/2019 19:07:00]
  Second chance exception - 0XC0000005 caused by thread with System ID: 18552 DetailID = 1
  Thread exited. Exiting thread - System ID: 2408. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 11328. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 4148. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 18780. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 17364. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 12004. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 3620. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 2708. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 8236. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 3392. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 20500. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 8096. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 3240. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 20588. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 14088. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 9540. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 8456. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 20376. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 13840. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 7624. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 7312. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 9928. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 12328. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 17048. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 20936. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 16204. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 19728. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 4748. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 19392. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 15492. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 14056. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 8040. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 11192. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 9808. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 10716. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 16624. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 18448. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 12660. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 19760. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 20640. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 19148. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 140. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 12392. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 15920. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 3888. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 3472. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 21428. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 17624. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 2000. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 16972. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 264. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 19792. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 8016. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 4172. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 11136. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 16392. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 3116. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 1864. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 9020. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 9668. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 13084. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 6356. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 1708. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 4100. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 21060. Exit code - 0xffffffff
  Thread exited. Exiting thread - System ID: 18552. Exit code - 0xffffffff
  Process exited. Exit code - 0xffffffff

***********************
*  EXCEPTION DETAILS  *
***********************

DetailID = 1
	Count:    2
	Exception #:  0XC0000005
	Stack:        





***********************
*  EXCEPTION SUMMARY  *
***********************

	|--------------------|
	| Count | Exception  |
	|--------------------|
	| 2     | 0XC0000005 |
	|--------------------|

Debugging Overhead Cost:
	Total Elapsed Ticks = 61984 (100%)
	Total Ticks Spent in Debugger Engine = 9281 (15%)
	Total Ticks Spent in Crash Rule Script = 451 (1%)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-24 19:12 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2019-01-24 19:12 UTC] cmb@php.net
PHP 5.6 is no longer supported[1].  Unless PHP 7.2 or later are
affected by this issue as well, it won't be fixed.

[1] <http://php.net/supported-versions.php>
 [2019-02-03 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Dec 05 07:03:37 2021 UTC