php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73870 php.exe crash in service context
Submitted: 2017-01-05 10:49 UTC Modified: 2017-01-08 20:22 UTC
From: jean-baptiste at nahan dot fr Assigned: ab (profile)
Status: Closed Package: Reproducible crash
PHP Version: 7.1.0 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jean-baptiste at nahan dot fr
New email:
PHP Version: OS:

 

 [2017-01-05 10:49 UTC] jean-baptiste at nahan dot fr
Description:
------------
Requirements : win32service extension. Available here https://github.com/InExtenso/win32service/tree/php-7.0

This script work fine with php-7.0.x but not with PHP-7.1.

On windows system the context of service execution is not a console. php.exe crash in the service context when he get the Codepage.
With the patch, the service can started with use php.exe or php-win.exe.

An issue is open on the win32service extension. The link is: https://github.com/InExtenso/win32service/issues/6
This issue contains build information and other results tests.

Test script:
---------------
<?php
/**
 * File : sample.php
 * This file is part of win32service extension package.
 * This file install or uninstall the "dummyphp" service.
 *
 * Requirements : PHP 7+
 *
 * Usage :
 *
 * php sample.php install
 * net start dummyphp
 * net stop dummyphp
 * php sample.php uninstall
 */

 if (!extension_loaded('win32service')) {
	throw new \Exception('The php_win32service.dll extension is not loaded ! Please configure it into your php configuration file.');
}
 
if ($argv[1] == 'install') {
	$x = win32_create_service(array(
		'service' => 'dummyphp',
		'display' => 'sample dummy PHP service',
		'params' => __FILE__ . ' run',
	));
	debug_zval_dump($x);
	exit;
} else if ($argv[1] == 'uninstall') {
	$x = win32_delete_service('dummyphp');
	debug_zval_dump($x);
	exit;
} else if ($argv[1] != 'run') {
	die("bogus args");
}

$x = win32_start_service_ctrl_dispatcher('dummyphp');

win32_set_service_status(WIN32_SERVICE_RUNNING);

while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) {
	usleep(250000);
}


Expected result:
----------------
Service do start.

Actual result:
--------------
php.exe crash:

Message:
Une exception non gérée a été levée : violation d'accès en lecture.
__imp__php_win32_cp_get_orig(...) retournée nullptr.


Stack:
>	php.exe!main(int argc, char * * argv) Ligne 1358	C
 	[Code externe]

Patches

fix_get_codepage (last revision 2017-01-05 10:49 UTC by jean-baptiste at nahan dot fr)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-05 14:41 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2017-01-05 14:41 UTC] ab@php.net
Thanks for the patch. Could you please check the current 7.1 dev tree? Several improvements went in since 7.1.0, so i guess the patch won't apply in the form there and this issue might be even fixed already. You can just fetch the latest snapshot from windows.php.net, no need to compile yourself. Or use 7.1.1RC1 which is coming out soon.

Thanks.
 [2017-01-05 15:17 UTC] jean-baptiste at nahan dot fr
The test from PHP 7.1.1-dev on branch PHP-7.1 work fine.

How to add error alert if the extension is loaded on PHP 7.1.0 ?

Thanks.
 [2017-01-06 16:07 UTC] ab@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: ab
 [2017-01-06 16:07 UTC] ab@php.net
I don't think it'll be possible to catch this in the extension. I'd also wonder a bit, as it should have been explicitly excluded from php-win.exe. Maybe it was done not a correct way, as i actually had not much to test it. 

Closing this one now, as the issue looks resolved.

Thanks.
 [2017-01-08 20:22 UTC] ab@php.net
@jean-baptiste by the way - would it be something meaningful for you to propose a patch for the PECL package, or join it even? As issues like bug #73733 will for sure hit back. If so, please write to Richard and CC the PECL dev lists.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 14:01:29 2024 UTC