php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57249 Sutdown bug with runkit_import on a function-static variable
Submitted: 2006-09-20 06:26 UTC Modified: 2013-02-25 03:10 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nicolas dot legland at free dot fr Assigned: pollita (profile)
Status: Closed Package: runkit (PECL)
PHP Version: 5.1.6 OS: Windows 2K/XP
Private report: No CVE-ID: None
 [2006-09-20 06:26 UTC] nicolas dot legland at free dot fr
Description:
------------
Using :
- Windows 2K or XP
- PHP CLI 5.1.6.6 from binary package
- PHP_RUNKIT.DLL 5.1.2.2 from PECL4Win binary package 2006-09-19 06:09:15 for php-5.1.2 (branch 5_1)

Reproduce code:
---------------
FROM MAIN "BUG.PHP"
<?php

	// Import buggy method using runkit
	runkit_import('bug.inc', RUNKIT_IMPORT_CLASS_METHODS);

	// Create buggy class object
	$g_oBuggyObject = new cBuggyClass();

	// Try to trigger the bug once
	$g_oBuggyObject->mBuggyMethod();

	// Buggy class initial definition
	class cBuggyClass
	{
	}

?>



FROM INCLUDED FILE "BUG.INC"
<?php

	// Add a method to cBuggyclass
	class cBuggyClass
	{
		// Member function using a static cache
		public function mBuggyMethod()
		{
			// CRASH WITH THIS LINE UNCOMMENTED
			static $ls_a_iCache;

			// Debug trace
			echo 'mBuggyMethod();'.PHP_EOL;
		}
	}

?>

Expected result:
----------------
"mBuggyMethod();"

Actual result:
--------------
"mBuggyMethod();"

and then a Windows error popup

"Instruction at 0x784ad989 reference memoty 0x178e6ba. The memory cannot be written."

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-09-20 06:36 UTC] nicolas dot legland at free dot fr
In fact, you don't actually need to instanciate the cBuggyClass, nor to invocate the mBuggyMethod. On the other hand, as soon as you remove the initial class definition, everything works fine. This is so far what I found to be stricly enough to trigger the error :

// In bug.php
runkit_import('bug.inc', RUNKIT_IMPORT_CLASS_METHODS);
class cBuggyClass
{
}

// In bug.inc
class cBuggyClass
{
	public function mBuggyMethod()
	{
		static $ls_Whatever;
	}
}
 [2006-09-20 12:08 UTC] nicolas dot legland at free dot fr
Fixed typo in summary
 [2006-09-20 12:08 UTC] pollita@php.net
Yeah, property importing is still a bit wonky...
 [2013-02-25 03:10 UTC] pollita@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

The importing, along with a number of assumptions were indeed, a bit wonky.

https://github.com/php/pecl-php-
runkit/commit/658dcbaf935d7745b12fd6f886039c5cb2f98665
 [2013-02-25 03:10 UTC] pollita@php.net
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: pollita
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat May 08 19:01:24 2021 UTC