Commit Graph

448 Commits

Author SHA1 Message Date
Nikita Popov
70fa4715a4 Fix custom heap free
This seems to be designed around the use-case where the custom
allocator is a wrapper around ZMM.
2019-06-28 09:13:45 +02:00
Nikita Popov
cfeda978df Add tracked allocator mode
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.
2019-06-27 14:19:48 +02:00
Nikita Popov
3d4298697b Fix shift UB in constants
We were shifting out the top bit of a signed integer.
2019-06-19 15:09:00 +02:00
Anatol Belski
08a0030b33 Fix conditional compilation
The new symbols are shared and don't need to depend on the availability
of __builtin_constant_p.
2019-05-29 02:40:09 +02:00
Dmitry Stogov
8c0b0c6a1e Avoid cold code duplication 2019-05-29 01:43:27 +03:00
Peter Kokot
3c92b79ea0 Remove unused functions
- zend_mm_bitset_find_zero
- zend_mm_bitset_find_one
- zend_mm_bitset_find_zero_and_set
- zend_is_by_ref_func_arg_fetch
2019-05-08 22:02:39 +02:00
Peter Kokot
5f8915786f Remove HAVE_SIGNAL_H
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
2019-04-07 15:55:34 +02:00
Peter Kokot
fd1ad1e25a Remove HAVE_LIMITS_H
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
2019-04-07 15:20:02 +02:00
Dmitry Stogov
9499484ed2 Implemented a faster way to access predefined TSRM resources - CG(), EG(), etc. 2019-03-14 03:01:01 +03:00
Dmitry Stogov
04b67bac32 Avoid reinitailization of ZTS cache pointer. Initialize it once in TSRM.c 2019-03-12 17:35:50 +03:00
Stanislav Malyshev
db777e9199 Fix shifting signed values too far
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.
2019-03-06 00:50:09 -08:00
Dmitry Stogov
c896b3ea48 Unused parameter 2019-03-01 14:34:17 +03:00
Dmitry Stogov
a1109b28f4 Keep original debug info 2019-03-01 14:11:37 +03:00
Tyson Andre
da3316ff0f Fix typos in code comments in Zend/ [skip ci] 2019-02-18 17:56:28 +01:00
Nikita Popov
709b8aaf9f Merge branch 'PHP-7.3' into PHP-7.4 2019-02-18 14:04:30 +01:00
Nikita Popov
3b3fafa637 Merge branch 'PHP-7.2' into PHP-7.3 2019-02-18 14:04:15 +01:00
Nikita Popov
928c42211f Make MADV_HUGEPAGE conditional on USE_ZEND_ALLOC_HUGE_PAGES
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.
2019-02-18 14:03:07 +01:00
Nikita Popov
7d0d94e230 Use mremap in zend_mm_chunk_extend if available
As suggested by https://twitter.com/grsecurity. This saves an
mmap+munmap cycle in case the mapping cannot be extended in-place.
2019-02-18 12:06:59 +01:00
Peter Kokot
92ac598aab Remove local variables
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.
2019-02-03 21:03:00 +01:00
Zeev Suraski
a81202ac49 Adios, yearly copyright ranges 2019-01-30 11:48:28 +01:00
Dmitry Stogov
662243cb30 Don't hide real peak usage. 2019-01-25 13:36:32 +03:00
Dmitry Stogov
bf774d4d75 Reduce amount of updated memory 2019-01-24 18:01:24 +03:00
Dmitry Stogov
4d0a2f68a9 Provide is_zend_ptr() function to check if a pointer lays in Zend MM heap. 2018-12-12 13:02:28 +03:00
David Carlier
5d4938956a Support huge pages on FreeBSD
FreeBSD provides MAP_ALIGNED_SUPER for a similar purpose as
MAP_HUGETLB on Linux, so add it as an alias.

Huge pages still have to be explicitly enabled through the
USE_ZEND_ALLOC_HUGE_PAGES environment variable.
2018-11-27 19:48:24 +01:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02:00
Zeev Suraski
54dc07f3dc Update email addresses. We're still @Zend, but future proofing it... 2018-11-01 17:20:07 +02:00
Dmitry Stogov
1154f6f70a Merge branch 'PHP-7.3'
* PHP-7.3:
  Allow switching back to Zend MM heap.
2018-09-17 20:21:05 +03:00
Dmitry Stogov
b25bc917ec Allow switching back to Zend MM heap. 2018-09-17 20:20:13 +03:00
Nikita Popov
ac03b15e3c Remove __USE_GNU defines
This is an internal glibc macro, it should not be necessary to use
it if we already define _GNU_SOURCE (we do through
AC_USE_SYSTEM_EXTENSIONS). Needing to use __USE_GNU generally
indicates an inclusion order problem (libc header included before
config.h).
2018-09-17 17:51:00 +02:00
Nikita Popov
5776b4453d Remove unused MREMAP_MAYMOVE compatibility define 2018-09-17 13:48:39 +02:00
Anatol Belski
321c0cc349 Fix localized error messages and memory leaks
The FormatMessage API needs to LocalFree the delivered error messages.
In cases where messages are delivered in non ASCII compatible encoding,
the messages might be unreadable. This aligns the error message encoding
with the encoding settings in PHP, the focus is UTF-8 as default.

Initialize error buffer

Avoid code duplication
2018-09-17 10:56:50 +02:00
Nikita Popov
100733f86b Merge branch 'PHP-7.3' 2018-09-07 12:10:15 +02:00
David Carlier
f7b573b4e9 Support fixed address mmap without replacement
Reapply changes for Zend fixed mapping but only for FreeBSD.
Other BSD might expose some day a similar flag (private
for OpenBSD for the moment for example).
The Linux's part could be brought back but not before 7.4,
at this time, distributions with kernel > 4.17 will be
more widely available.
2018-09-07 12:10:05 +02:00
Remi Collet
404a97dd57 Merge branch 'PHP-7.3'
* PHP-7.3:
  Revert "Support fixed address mmap without replacement"
  Revert "Don't report mmap failure if it is expected"
2018-08-29 14:41:27 +02:00
Remi Collet
a55bcaa14d Revert "Support fixed address mmap without replacement"
This reverts commit 0f68ff5c92.
2018-08-29 14:41:04 +02:00
Remi Collet
8cc7e2a2df Revert "Don't report mmap failure if it is expected"
This reverts commit 446b5b15d3.
2018-08-29 14:40:59 +02:00
Nikita Popov
406b57ed01 Merge branch 'PHP-7.3' 2018-08-22 11:22:23 +02:00
David Carlier
446b5b15d3 Don't report mmap failure if it is expected
When using mmap with MAP_FIXED_NOREPLACE or MAP_FIXED|MAP_EXCL
an mmap failure is not an error condition, so do not print an
error message in this case.
2018-08-22 11:19:52 +02:00
Nikita Popov
09b4b83753 Merge branch 'PHP-7.3' 2018-08-21 08:34:15 +02:00
David Carlier
0f68ff5c92 Support fixed address mmap without replacement
We did not use MAP_FIXED here, because it may replace an existing
mapping. This commit adds support for MAP_FIXED_NOREPLACE (available
on newer Linux kernels) and MAP_FIXED|MAP_EXCL (available on FreeBSD),
which avoid this issue.
2018-08-21 08:31:31 +02:00
Gabriel Caruso
84b195d9fc Fix some misspellings 2018-08-12 16:15:45 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Dmitry Stogov
18bc3afdcb Micro-optimizations 2018-06-06 01:57:19 +03:00
Dmitry Stogov
4ad9cf4605 Bit test optimization 2018-05-08 11:58:17 +03:00
Dmitry Stogov
880694952f micro optimisation 2018-05-07 22:29:16 +03:00
Dmitry Stogov
d5238b95a3 Added missing #if to allow compilation withput ZEND_MM_CUSTOM 2018-01-15 17:37:15 +03:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Dmitry Stogov
abd2120c4f Fixed inaccurate condition 2017-11-07 10:29:17 +03:00
Xinchen Hui
4da0bfc7d7 Unused var 2017-11-06 14:10:27 +08:00