Bug #79075 [NEW]: FFI header parser chokes on comments

From: Date: Tue, 07 Jan 2020 21:45:34 +0000
Subject: Bug #79075 [NEW]: FFI header parser chokes on comments
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224761@lists.php.net to get a copy of this message
From: larry at garfieldtech dot com Operating system: Ubuntu 19.10 PHP version: 7.4.1 Package: Unknown/Other Function Bug Type: Bug Bug description:FFI header parser chokes on comments Description: ------------ (I couldn't find an FFI section in the packages affected section; feel free to relocate this ticket to the right location.) When using FFI, If the .h file contains a comment that comes before a #define then the FFI::load() will fail with a Warning: cannot resolve C function. This does not seem to happen if the same .h file is used in FFI::cdef(). That is, the following header file works fine: ``` #define FFI_SCOPE "POINTS" #define FFI_LIB "./points.so" struct point { int x; int y; }; // Foo double distance(struct point first, struct point second); ``` But this version fails in FFI::load(), and works in FFI::cdef(): ``` #define FFI_SCOPE "POINTS" // Foo #define FFI_LIB "./points.so" struct point { int x; int y; }; double distance(struct point first, struct point second); ``` I have verified the same behavior regardless of whether // or /* */ comments are used. Test script: --------------- See: https://github.com/Crell/ffi-test/tree/476610f469aff116f41131948e58b0e27f9b9a57 That commit has a directory "points" with sample code. (It's fixed in more recent comments.) To demonstrate, change into that directory and run "make inline". That will work. Then run "make preload", which uses the preload-with-load() approach. It will fail. Then modify the points.h file to remove the comment between the #define statements. It will now work. (At least that's what I experienced.) -- Edit bug report at https://bugs.php.net/bug.php?id=79075&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79075&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79075&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79075&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79075&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79075&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79075&r=support Expected behavior: https://bugs.php.net/fix.php?id=79075&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79075&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79075&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79075&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79075&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79075&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79075&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79075&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79075&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79075&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79075&r=mysqlcfg

« previous php.bugs (#224761) next »