1
0
mirror of https://github.com/php/php-src.git synced 2026-04-20 22:41:20 +02:00
Commit Graph

62 Commits

Author SHA1 Message Date
Christoph M. Becker
f547412cba Fix #79177: FFI doesn't handle well PHP exceptions within callback
We have to error on unhandled exceptions in FFI callbacks, to avoid
passing back undefined values.

This has been discussed and agreed upon in a previous PR[1].

[1] <https://github.com/php/php-src/pull/5120>

Closes GH-6366.
2020-10-28 13:34:56 +01:00
Dmitry Stogov
583093844e Fixed hex char parsing 2020-09-30 11:00:25 +03:00
George Peter Banyard
a1cee97de1 Fixed incorrect logical conditions 2020-09-30 08:21:46 +03:00
Christoph M. Becker
d5300873c5 Fix #79571: FFI: var_dumping unions may segfault
We must not attempt to access arbitrary union members when retrieving
debug info, because that may not be valid.  Therefore we do no longer
dereference pointer types inside of unions, but report their address as
string in `%p` format instead.
2020-05-11 16:24:46 +02:00
Dmitry Stogov
fee614f66b Export FFI::__BIGGEST_ALIGNMENT__ 2020-03-12 11:43:01 +03:00
Dmitry Stogov
ecdaf83f5f Allow to fetch function address 2020-03-12 11:40:48 +03:00
Xinchen Hui
22c83454d6 Folder mark missed 2020-03-12 15:43:15 +08:00
Dmitry Stogov
c45552e32b Export FFI::__BIGGEST_ALIGNMENT__ 2020-03-11 15:29:58 +03:00
Dmitry Stogov
e902e4acd9 Allow to fetch function address 2020-03-11 15:13:27 +03:00
Dmitry Stogov
54ecf57fe2 Disable instantiation of zero size FFI\CData objects 2020-02-17 12:48:55 +03:00
Christoph M. Becker
05f3cd23ed Fix #79096: FFI Struct Segfault
We must not assume that the size of a function's return value is at
most `sizeof(ffi_arg)`, but rather have to use the size which already
has been determined for the return type if it is larger than
`sizeof(ffi_arg)`.

To be able to have a regression test, we export the required test
function from the zend-test extension, and make sure that the test
can be run on different platforms regardless of whether zend-tests was
built statically or dynamically.
2020-01-14 16:46:58 +01:00
Christoph M. Becker
0055f1e3dc Fix #78761: Zend memory heap corruption with preload and casting
We have to reset `FFI_G(persistent)` back to zero when preloading has
finished.
2019-10-30 19:49:39 +01:00
Christoph M. Becker
1e2d3d58a8 Fix #78762: Failing FFI::cast() may leak memory
We have to release objects when we're done with them.
2019-10-30 17:21:58 +01:00
Christoph M. Becker
bedbecf56d Implement #78270: Support __vectorcall convention with FFI
To work around the limitation of the current rudimentary vectorcall
support in our patched libffi, we forbid yet unsupported declarations,
i.e. float/double parameters at certain positions (SIMD vector types
and HVA types are not supported anyway).
2019-10-29 08:57:43 +01:00
Dmitry Stogov
fea8c5481b Added suppot for glob() wildcard matching in ffi.preload directive 2019-10-24 07:40:07 +02:00
Dmitry Stogov
c744531fff Ignore ZEND_FFI_TYPE_OWNED flag 2019-10-23 19:50:58 +03:00
Remi Collet
dcd772325d add new ffi.preload option in php.ini and display ini entries in MINFO 2019-10-23 07:49:13 +02:00
Christoph M. Becker
598bf7f5d5 Fix typo 2019-10-22 17:53:34 +02:00
Dmitry Stogov
1417352dda Allow loading FFI bindings through ffi.preload directive 2019-10-22 17:52:56 +03:00
Christoph M. Becker
1c9bfcb6a7 Fix #78716: Function name mangling is wrong for some parameter types
We have to cater to function parameter alignment when calculating the
parameter size.
2019-10-22 11:38:58 +02:00
Dmitry Stogov
21c3cdf668 NEWS entry, test and minor cleanup for FFI::isNull() 2019-09-10 11:23:12 +03:00
Philip Hofstetter
f6ff7eb335 add FFI::isNull() to check whether a FFI\CData is a null pointer 2019-09-10 11:03:51 +03:00
Dmitry Stogov
ea92b9b655 Stop after exceptions 2019-09-10 11:01:36 +03:00
Dmitry Stogov
1db0bad6a7 Fixed bug #78488 (OOB in ZEND_FUNCTION(ffi_trampoline)). 2019-09-04 12:16:12 +03:00
Christoph M. Becker
1ed9ebdea5 Support calling convention specific function name mangling
On Windows certain calling conventions cause C function names to be
mangled, so to import them we have to use the properly mangled names.
2019-08-04 12:14:11 +02:00
Peter Kokot
81fd1c5206 Fix typos in FFI
Closes GH-4438
2019-07-19 23:07:04 +02:00
Nikita Popov
0f3ca15bb7 FFI: Perform bitfield operations byte-wise
Otherwise we may perform reads/writes outside the allocation, as
already happens in 032.phpt.
2019-06-25 14:28:58 +02:00
Nikita Popov
f127d77eef FFI: Use signed arithmetic for pointer offset
offset can be negative here, using signed arithmetic avoids ubsan
warnings.
2019-06-20 16:22:26 +02:00
Dmitry Stogov
eda916cc98 Avoid uninitilized field access 2019-06-17 14:53:44 +03:00
Dmitry Stogov
1e0b0467b6 Fixed memory leaks in ext/ffi/tests/100.phpt on Mac OSX 2019-06-17 14:40:19 +03:00
Dmitry Stogov
83804519df Replace ZVAL_COPY() and ZVAL_COPY_VALUE() for IS_OBJECT by cheaper macros 2019-05-28 20:10:02 +03:00
Dmitry Stogov
6738241aec Avoid usage of internal get/set object handlers. They are going to be removed in PHP-8.
Scalar FFI values now should be accessed through special "cdata" property.

    $x = FFI::new("int");
    $x = 42;

    should be changed into

    $x = FFI::new("int");
    $x->cdata = 42;
2019-05-28 17:08:35 +03:00
Dmitry Stogov
49de3ce3ca Check for supported libffi ABI 2019-05-13 15:15:51 +03:00
Nikita Popov
645ebcdfbf Avoid some maybe uninitialized warnings in ffi
All false positives.
2019-05-07 15:44:22 +02:00
Peter Kokot
426bcdf021 Fix double incremenation in ffi
This removes the warning of:
`incremented both in the loop header and in the loop body` in the
compilation step.
2019-05-06 09:45:11 +03:00
Christoph M. Becker
30409d6753 Properly initialize variable
Not all code paths assign to `handle`, even though it may be used, so
we make sure that it is initialized to a sane value in the first place.
2019-05-05 17:49:54 +02:00
Christoph M. Becker
a760c79f1e Fix typo 2019-05-05 15:40:33 +02:00
Dmitry Stogov
a5e86d8264 Fixed ext/ffi/tests/044.phpt failure on 32-bit Linux 2019-04-09 16:12:13 +03:00
Anatol Belski
039500adb6 Fix handling and extend ext/ffi/tests/044.phpt 2019-03-30 12:53:32 +01:00
Dmitry Stogov
61ad294f26 Partial support for GCC mode attribute. 2019-03-29 17:28:57 +03:00
Dmitry Stogov
a2b39aa0de Fixed memory leaks 2019-03-29 14:33:49 +03:00
Dmitry Stogov
24fa2008dd Allow usage of incomplete types for external variables, function parameters and return values 2019-03-29 14:14:56 +03:00
Dmitry Stogov
745dd94e55 Added support for more GCC extensions: attributes, __extension__, __asm__ (ignored) 2019-03-29 02:36:55 +03:00
Dmitry Stogov
adf930c038 Ignore "__format__" attribute 2019-03-29 00:52:39 +03:00
Dmitry Stogov
94e3db64b2 Allow incomplete array variables - extern const char * const sys_errlist[] 2019-03-29 00:15:12 +03:00
Dmitry Stogov
a3e52afebe Fixed bug #77768 (FFI: Builtin Types Should Not Raise Error On Redeclaration) 2019-03-29 00:02:26 +03:00
Dmitry Stogov
363e8dd69d Support for __restrict and few GCC attributes 2019-03-28 03:01:20 +03:00
Dmitry Stogov
defd421c0f Improve white-space handling 2019-03-19 13:52:55 +03:00
Dmitry Stogov
e7f0a60d54 Reset fields 2019-03-11 15:38:49 +03:00
Dmitry Stogov
e623df650f Fixed bug #77707 (FFI loses type information for opaque types) 2019-03-11 14:26:17 +03:00