php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #56644 FFI crashes PHP when initing a bool return value
Submitted: 2005-11-14 02:29 UTC Modified: 2015-09-02 02:24 UTC
From: adam at ibrowsecoffee dot com Assigned:
Status: Suspended Package: ffi (PECL)
PHP Version: 5.0.5 OS: Windows XP
Private report: No CVE-ID: None
 [2005-11-14 02:29 UTC] adam at ibrowsecoffee dot com
Description:
------------
When attempting to init the Advapi32.dll with the FFI extension PHP crashes php.exe with the following windows crash report info.

AppName: php.exe AppVer: 5.0.5.5 ModName: php5ts.dll ModVer: 5.0.5.5 Offset: 0003c0ea

If you change the return type on the line with the Advapi32.dll FFI init in it to an "int" then the code runs until the 
"$result = $user->GetUserName($name, $len);" line and gives a PHP error of "PHP Fatal Error: Call to undefined method FFI:GetUserName()". Using a return type of "bool" or "boolean" returns same results.

All code is run using the CLI php.exe under the cmd shell window. No webservers are being used to test this code.

All other functions in the sample code run fine and operate properly using the FFI extension as expected.

The Windows API docs specify a "BOOL" type return value for the GetUserName function call.

Reproduce code:
---------------
define("MB_OK", 0);
$windows = new ffi ("[lib='user32.dll'] int MessageBoxA( int handle, char *text, char *caption, int type);");
echo $windows->MessageBoxA(0, "Message For You1", "Hello World", 1);
$api = new ffi("[lib='Kernel32.dll'] long GetTickCount();");
echo $windows->MessageBoxA(0, "Message For You2", "Hello World", 1);
$user = new ffi("[lib='Advapi32.dll'] bool GetUserName(string &username, int &size);");
echo $windows->MessageBoxA(0, "Message For You3", "Hello World", 1);
$len = 255;                  // set the length your variable should have
$name = str_repeat("\0", $len); // prepare an empty string
$result = $user->GetUserName($name, $len);
echo $windows->MessageBoxA(0, "Username1", $message, 1);
echo $windows->MessageBoxA(0, "Message For You4", "Hello World", 1);
***********************************************
Using Windows XP Pro SP2 all current updates on a clean install of WinXP and latest PHP 5.0.5 w/PECL/PEAR libraries.

Expected result:
----------------
Proper initialization of the Advapi32.dll and init of the GetUserName call without crashing PHP.

Actual result:
--------------
AppName: php.exe AppVer: 5.0.5.5 ModName: php5ts.dll ModVer: 5.0.5.5 Offset: 0003c0ea

If you change the return type on the line with the Advapi32.dll FFI init in it to an "int" then the code runs until the 
"$result = $user->GetUserName($name, $len);" line and gives a PHP error of "PHP Fatal Error: Call to undefined method FFI:GetUserName()". Using a return type of "bool" or "boolean" returns same results.

All code is run using the CLI php.exe under the cmd shell window. No webservers are being used to test this code.

All other functions in the sample code run fine and operate properly using the FFI extension as expected.

The Windows API docs specify a "BOOL" type return value for the GetUserName function call.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-14 02:31 UTC] adam at ibrowsecoffee dot com
Actual version of PHP was 5.0.5. Option not available in submittal form.
 [2015-09-02 02:24 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2015-09-02 02:24 UTC] cmb@php.net
Apparently, pecl/ffi is unmaintained since a very long time, so
I'm suspending this report.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC