summaryrefslogtreecommitdiff
path: root/Zend/zend_alloc.c
Commit message (Collapse)AuthorAgeFilesLines
* Use VM_MAKE_TAG for macos memory tagDavid CARLIER2021-02-151-1/+2
| | | | | | In case Apple changes the meaning of the macro in the future. Closes GH-6687.
* Replace zend_bool uses with boolNikita Popov2021-01-151-2/+2
| | | | | | | We're starting to see a mix between uses of zend_bool and bool. Replace all usages with the standard bool type everywhere. Of course, zend_bool is retained as an alias.
* Fix ubsan error on MacLevi Morrison2020-12-161-1/+1
| | | | | Fixes this error: > Zend/zend_alloc.c:473:73: runtime error: left shift of 250 by 24 places cannot be represented in type 'int'
* Improve type declarations for Zend APIsGeorge Peter Banyard2020-08-281-9/+8
| | | | | | | | | Voidification of Zend API which always succeeded Use bool argument types instead of int for boolean arguments Use bool return type for functions which return true/false (1/0) Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics Closes GH-6002
* Fix tracked_reallocNikita Popov2020-08-281-9/+21
| | | | | We should only drop the information about the old allocation after checking the memory limit. This makes the code a bit more awkward...
* Enforce memory limit in tracked allocation modeNikita Popov2020-08-271-16/+43
| | | | | | | A very basic limit (for single allocations) was already enforced. This extends it to count the total memory allocations. This is useful to avoid out of memory conditions while fuzzing.
* Drop the unneeded pointer castingtangl1632020-08-031-2/+2
| | | | | | | | | | | The standard says that "A pointer to void may be converted to or from a pointer to any object type". So the casting is unneeded. REF: * c11: http://port70.net/~nsz/c/c11/n1570.html#6.3.2.3p1 * c99: http://port70.net/~nsz/c/c99/n1256.html Closes GH-5916
* Add crude memory limit to tracked allocNikita Popov2020-04-211-1/+17
| | | | | | | Check whether the requested allocation size exceeds limit (rather than the cumulative size). This is useful to prevent allocations triggering OOM during fuzzing.
* Merge branch 'PHP-7.4'Dmitry Stogov2020-02-271-0/+1
|\ | | | | | | | | * PHP-7.4: Fixed incorrect behavior of internal memory debugger
| * Merge branch 'PHP-7.3' into PHP-7.4Dmitry Stogov2020-02-271-0/+1
| |\ | | | | | | | | | | | | * PHP-7.3: Fixed incorrect behavior of internal memory debugger
| | * Fixed incorrect behavior of internal memory debuggerDmitry Stogov2020-02-271-0/+1
| | |
| * | Reverting push to wrong repoRasmus Lerdorf2019-10-231-27/+6
| | |
| * | Update alloc patchRasmus Lerdorf2019-10-231-6/+27
| | |
* | | Fix miscellaneous typos in docs and error messagesTyson Andre2019-10-281-1/+1
|/ / | | | | | | Closes GH-4863.
* | Merge branch 'PHP-7.3' into PHP-7.4Christoph M. Becker2019-10-041-2/+7
|\ \ | |/ | | | | | | * PHP-7.3: Fix #78620: Out of memory error
| * Merge branch 'PHP-7.2' into PHP-7.3Christoph M. Becker2019-10-041-2/+7
| |\ | | | | | | | | | | | | * PHP-7.2: Fix #78620: Out of memory error
| | * Fix #78620: Out of memory errorChristoph M. Becker2019-10-041-2/+7
| | | | | | | | | | | | | | | The integer addition in `ZEND_MM_ALIGNED_SIZE_EX` can overflow, what we have to catch early.
* | | Merge branch 'PHP-7.3' into PHP-7.4Christoph M. Becker2019-10-021-5/+0
|\ \ \ | |/ / | | | | | | | | | * PHP-7.3: Revert "Fix #78620: Out of memory error"
| * | Merge branch 'PHP-7.2' into PHP-7.3Christoph M. Becker2019-10-021-5/+0
| |\ \ | | |/ | | | | | | | | | * PHP-7.2: Revert "Fix #78620: Out of memory error"
| | * Revert "Fix #78620: Out of memory error"Christoph M. Becker2019-10-021-5/+0
| | | | | | | | | | | | | | | | | | This reverts commit 8ce04df7e0108a10f7b782a28204e9384ab1129c. Cf. <https://github.com/php/php-src/pull/4766#discussion_r330658679>.
* | | Merge branch 'PHP-7.3' into PHP-7.4Christoph M. Becker2019-10-021-0/+5
|\ \ \ | |/ / | | | | | | | | | * PHP-7.3: Fix #78620: Out of memory error
| * | Merge branch 'PHP-7.2' into PHP-7.3Christoph M. Becker2019-10-021-0/+5
| |\ \ | | |/ | | | | | | | | | * PHP-7.2: Fix #78620: Out of memory error
| | * Fix #78620: Out of memory errorChristoph M. Becker2019-10-021-0/+5
| | | | | | | | | | | | | | | If the integer addition in `ZEND_MM_ALIGNED_SIZE_EX` overflows, the macro evaluates to `0`, what we should catch early.
* | | Monitoring anonymous pages on mac via vmmap tagDavid Carlier2019-09-171-2/+11
| | |
* | | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-08-261-5/+5
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2019-08-261-5/+5
| |\ \ | | |/
| | * Fix overflow in memory limit checksNikita Popov2019-08-261-5/+5
| | | | | | | | | | | | | | | | | | Due to overflows in the memory limit checks, we were missing cases where the allocation size was close to the address space size, and caused an OOM condition rather than a memory limit error.
* | | Fix custom heap freeNikita Popov2019-06-281-1/+7
| | | | | | | | | | | | | | | This seems to be designed around the use-case where the custom allocator is a wrapper around ZMM.
* | | Add tracked allocator modeNikita Popov2019-06-271-11/+71
| | | | | | | | | | | | | | | | | | | | | | | | In this case we will use the system allocator, but still remember all allocations and free them the same way that Zend MM does. This allows us to accurately model leak behavior. Enabled using USE_ZEND_ALLOC=0 USE_TRACKED_ALLOC=1.
* | | Fix shift UB in constantsNikita Popov2019-06-191-1/+1
| | | | | | | | | | | | We were shifting out the top bit of a signed integer.
* | | Fix conditional compilationAnatol Belski2019-05-291-3/+5
| | | | | | | | | | | | | | | The new symbols are shared and don't need to depend on the availability of __builtin_constant_p.
* | | Avoid cold code duplicationDmitry Stogov2019-05-291-30/+34
| | |
* | | Remove unused functionsPeter Kokot2019-05-081-44/+0
| | | | | | | | | | | | | | | | | | | | | - zend_mm_bitset_find_zero - zend_mm_bitset_find_one - zend_mm_bitset_find_zero_and_set - zend_is_by_ref_func_arg_fetch
* | | Remove HAVE_SIGNAL_HPeter Kokot2019-04-071-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `<signal.h>` header file is part of the standard C89 headers [1] and on current systems can be included unconditionally. Since file requires at least C89 or greater, the `HAVE_SIGNAL_H` symbol defined by Autoconf in Zend.m4 [2] can be ommitted and simplifed. The bundled libmagic (file) also ommits the usage of HAVE_SIGNAL_H since 5.35 however current version in PHP is very modified 5.34 version and will be refactored separately. Check for HAVE_SIGNAL_H is therefore still done in the configure.ac. Refs: [1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2 [2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
* | | Remove HAVE_LIMITS_HPeter Kokot2019-04-071-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `<limits.h>` header file is part of the standard C89 headers [1] and on current systems can be included unconditionally. Since PHP requires at least C89 or greater, the `HAVE_LIMITS_H` symbol defined by Autoconf in configure.ac [2] can be ommitted and simplifed however due to bundled file library (libmagic) and timelib still using it, the removal there was omitted and done only in Zend.m4 file. Current bundled libraries libtime, oniguruma, and libmagic still include partial `HAVE_LIMITS_H` usage and will be more refactored when this is possible. Refs: [1] https://port70.net/~nsz/c/c89/c89-draft.html#4.1.2 [2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4
* | | Implemented a faster way to access predefined TSRM resources - CG(), EG(), etc.Dmitry Stogov2019-03-141-2/+10
| | |
* | | Avoid reinitailization of ZTS cache pointer. Initialize it once in TSRM.cDmitry Stogov2019-03-121-1/+0
| | |
* | | Fix shifting signed values too farStanislav Malyshev2019-03-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Signed shift of 31 for int and 63 for long is flagged as undefined behavior by UBSan (-fsanitize=undefined) and seems to be indeed so according to the standard. The patch converts such cases to use unsigned.
* | | Unused parameterDmitry Stogov2019-03-011-5/+5
| | |
* | | Keep original debug infoDmitry Stogov2019-03-011-3/+3
| | |
* | | Fix typos in code comments in Zend/ [skip ci]Tyson Andre2019-02-181-2/+2
| | |
* | | Merge branch 'PHP-7.3' into PHP-7.4Nikita Popov2019-02-181-8/+7
|\ \ \ | |/ /
| * | Merge branch 'PHP-7.2' into PHP-7.3Nikita Popov2019-02-181-8/+7
| |\ \ | | |/
| | * Make MADV_HUGEPAGE conditional on USE_ZEND_ALLOC_HUGE_PAGESNikita Popov2019-02-181-7/+8
| | | | | | | | | | | | | | | | | | There have been multiple reports of large slowdowns due to the use of MADV_HUGEPAGE, so make it conditional on USE_ZEND_ALLOC_HUGE_PAGES, just like MAP_HUGETLB already is.
| | * year++Xinchen Hui2018-01-021-1/+1
| | |
| * | Future-proof email addressesZeev Suraski2018-11-011-3/+3
| | |
* | | Use mremap in zend_mm_chunk_extend if availableNikita Popov2019-02-181-6/+18
| | | | | | | | | | | | | | | As suggested by https://twitter.com/grsecurity. This saves an mmap+munmap cycle in case the mapping cannot be extended in-place.
* | | Remove local variablesPeter Kokot2019-02-031-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes the so called local variables defined per file basis for certain editors to properly show tab width, and similar settings. These are mainly used by Vim and Emacs editors yet with recent changes the once working definitions don't work anymore in Vim without custom plugins or additional configuration. Neither are these settings synced across the PHP code base. A simpler and better approach is EditorConfig and fixing code using some code style fixing tools in the future instead. This patch also removes the so called modelines for Vim. Modelines allow Vim editor specifically to set some editor configuration such as syntax highlighting, indentation style and tab width to be set in the first line or the last 5 lines per file basis. Since the php test files have syntax highlighting already set in most editors properly and EditorConfig takes care of the indentation settings, this patch removes these as well for the Vim 6.0 and newer versions. With the removal of local variables for certain editors such as Emacs and Vim, the footer is also probably not needed anymore when creating extensions using ext_skel.php script. Additionally, Vim modelines for setting php syntax and some editor settings has been removed from some *.phpt files. All these are mostly not relevant for phpt files neither work properly in the middle of the file.
* | | Adios, yearly copyright rangesZeev Suraski2019-01-301-1/+1
| | |
* | | Don't hide real peak usage.Dmitry Stogov2019-01-251-4/+0
| | |