Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r90571:e1aafbb1ad9c Date: 2017-03-05 19:12 +0100 http://bitbucket.org/pypy/pypy/changeset/e1aafbb1ad9c/
Log: Add an explicit check with a clear error message in case memory corruption creates an object "bigger than the nursery" in the nursery diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -2124,7 +2124,8 @@ def _malloc_out_of_nursery(self, totalsize): """Allocate non-movable memory for an object of the given 'totalsize' that lives so far in the nursery.""" - if raw_malloc_usage(totalsize) <= self.small_request_threshold: + if (r_uint(raw_malloc_usage(totalsize)) <= + r_uint(self.small_request_threshold)): # most common path return self.ac.malloc(totalsize) else: @@ -2133,6 +2134,9 @@ _malloc_out_of_nursery._always_inline_ = True def _malloc_out_of_nursery_nonsmall(self, totalsize): + if r_uint(raw_malloc_usage(totalsize)) > r_uint(self.nursery_size): + out_of_memory("memory corruption: bad size for object in the " + "nursery") # 'totalsize' should be aligned. ll_assert(raw_malloc_usage(totalsize) & (WORD-1) == 0, "misaligned totalsize in _malloc_out_of_nursery_nonsmall") _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit