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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
49 - 4 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Mar 28 10:01:26 2024 UTC