|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-03-07 13:24 UTC] ircmaxell@php.net
-Assigned To:
+Assigned To: dmitry
[2019-03-11 10:28 UTC] dmitry@php.net
[2019-03-11 10:28 UTC] dmitry@php.net
-Status: Assigned
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
Description: ------------ When using FFI, very little useful debugging information is provided when type checking arguments for function calls/etc. In the test script, the syntax for fprintf is FILE*, const char*, ... I made a "mistake" by passing a number for the second argument. FFI gave me no indication as to which parameter was incorrect, leading to either trial-and-error debugging, or breaking out GDB to see which argument was the problem. Test script: --------------- <?php $header = ' typedef struct _IO_FILE FILE; extern FILE *stdout; extern FILE *stdin; extern FILE *stderr; int fprintf(FILE *, const char *, ...); '; $ffi = FFI::cdef($header, 'libc.so.6'); $ffi->fprintf($ffi->stdout, 123, "Hello %s\n", "World"); Expected result: ---------------- Fatal error: Uncaught FFI\Exception: Passing incompatible pointer to argument 2 of function fprintf, expecting const char*, found long long in /.../test.php:14 Stack trace: #0 /.../test.php(14): FFI->fprintf(Object(FFI\CData:<struct>*), 123, 'Hello %s\n', 'World') #1 {main} thrown in /.../test.php on line 14 Actual result: -------------- Fatal error: Uncaught FFI\Exception: Passing incompatible pointer in /.../test.php:14 Stack trace: #0 /.../test.php(14): FFI->fprintf(Object(FFI\CData:<struct>*), 123, 'Hello %s\n', 'World') #1 {main} thrown in /.../test.php on line 14