summaryrefslogtreecommitdiffstats
path: root/Objects/obmalloc.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-18835: Cleanup pymalloc (#4200)Victor Stinner2017-10-311-472/+533
| | | | | | | | | | | | | | | | | | | | | | | | | | | Cleanup pymalloc: * Rename _PyObject_Alloc() to pymalloc_alloc() * Rename _PyObject_FreeImpl() to pymalloc_free() * Rename _PyObject_Realloc() to pymalloc_realloc() * pymalloc_alloc() and pymalloc_realloc() don't fallback on the raw allocator anymore, it now must be done by the caller * Add "success" and "failed" labels to pymalloc_alloc() and pymalloc_free() * pymalloc_alloc() and pymalloc_free() don't update num_allocated_blocks anymore: it should be done in the caller * _PyObject_Calloc() is now responsible to fill the memory block allocated by pymalloc with zeros * Simplify pymalloc_alloc() prototype * _PyObject_Realloc() now calls _PyObject_Malloc() rather than calling directly pymalloc_alloc() _PyMem_DebugRawAlloc() and _PyMem_DebugRawRealloc(): * document the layout of a memory block * don't increase the serial number if the allocation failed * check for integer overflow before computing the total size * add a 'data' variable to make the code easiler to follow test_setallocators() of _testcapimodule.c now test also the context.
* bpo-31626: Fixed a bug in debug memory allocator. (#3844)Serhiy Storchaka2017-10-311-11/+2
| | | | Removed a code that incorrectly detected in-place resizing in realloc() and wrote to freed memory.
* bpo-30860: Fix deadcode in obmalloc.c (#3499)Victor Stinner2017-09-141-2/+2
| | | | | | Fix Coverity CID 1417587: _PyMem_Initialize() contains code which is never executed. Replace the runtime check with a build assertion.
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-614/+160
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-2/+0
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* Revert "bpo-30860: Consolidate stateful runtime globals." (#3379)Eric Snow2017-09-061-158/+614
| | | Windows buildbots started failing due to include-related errors.
* bpo-30860: Consolidate stateful runtime globals. (#2594)Eric Snow2017-09-061-614/+158
| | | | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* Fix spurious MemoryError introduced by PR #886. (#930)T. Wouters2017-03-311-4/+4
| | | Fix MemoryError caused by moving around code in PR #886; nbytes was sometimes used unitinitalized (in non-debug builds, when use_calloc was false and elsize was 0).
* bpo-29941: Assert fixes (#886)T. Wouters2017-03-311-3/+3
| | | | | | | | Make a non-Py_DEBUG, asserts-enabled build of CPython possible. This means making sure helper functions are defined when NDEBUG is not defined, not just when Py_DEBUG is defined. Also fix a division-by-zero in obmalloc.c that went unnoticed because in Py_DEBUG mode, elsize is never zero.
* correct silly spelling problemBenjamin Peterson2016-09-191-9/+9
|
* replace obmalloc's homegrown uptr and uchar types with standard onesBenjamin Peterson2016-09-191-42/+31
|
* improvements to code that checks whether Python (obmalloc) allocated an addressBenjamin Peterson2016-09-191-76/+22
| | | | | | | | | | | | | | - Rename Py_ADDRESS_IN_RANGE to address_in_range and make it a static function instead of macro. Any compiler worth its salt will inline this function. - Remove the duplicated function version of Py_ADDRESS_IN_RANGE used when memory analysis was active. Instead, we can simply mark address_in_range as allergic to dynamic memory checking. We can now remove the __attribute__((no_address_safety_analysis)) from _PyObject_Free and _PyObject_Realloc. All the badness is contained in address_in_range now. - Fix the code that tried to only read pool->arenaindex once. Putting something in a variable is no guarantee that it won't be read multiple times. We must use volatile for that.
* replace PY_SIZE_MAX with SIZE_MAXBenjamin Peterson2016-09-071-1/+1
|
* replace Py_(u)intptr_t with the c99 standard typesBenjamin Peterson2016-09-061-1/+1
|
* Issue #26249: Try test_capi on WindowsVictor Stinner2016-04-221-6/+7
|
* PyMem_Malloc() now uses the fast pymalloc allocatorVictor Stinner2016-04-221-3/+3
| | | | | | | Issue #26249: PyMem_Malloc() allocator family now uses the pymalloc allocator rather than system malloc(). Applications calling PyMem_Malloc() without holding the GIL can now crash: use PYTHONMALLOC=debug environment variable to validate the usage of memory allocators in your application.
* Don't define _PyMem_PymallocEnabled() if pymalloc is disabledVictor Stinner2016-04-191-1/+1
| | | | Isse #26516.
* _PyMem_DebugFree(): fix compiler warning on WindowsVictor Stinner2016-03-231-1/+1
| | | | Don't return a void value.
* Fail if PyMem_Malloc() is called without holding the GILVictor Stinner2016-03-161-7/+7
| | | | | Issue #26563: Debug hooks on Python memory allocators now raise a fatal error if functions of the PyMem_Malloc() family are called without holding the GIL.
* On memory error, dump the memory block tracebackVictor Stinner2016-03-151-0/+9
| | | | | | Issue #26564: _PyObject_DebugDumpAddress() now dumps the traceback where a memory block was allocated on memory block. Use the tracemalloc module to get the traceback.
* Check the GIL in PyObject_Malloc()Victor Stinner2016-03-141-22/+70
| | | | | Issue #26558: The debug hook of PyObject_Malloc() now checks that the GIL is held when the function is called.
* Add PYTHONMALLOC env varVictor Stinner2016-03-141-59/+132
| | | | | | | | | | | | | Issue #26516: * Add PYTHONMALLOC environment variable to set the Python memory allocators and/or install debug hooks. * PyMem_SetupDebugHooks() can now also be used on Python compiled in release mode. * The PYTHONMALLOCSTATS environment variable can now also be used on Python compiled in release mode. It now has no effect if set to an empty string. * In debug mode, debug hooks are now also installed on Python memory allocators when Python is configured without pymalloc.
* Issue #23450: Fixed possible integer overflows.Serhiy Storchaka2015-02-161-1/+1
|
* Issue #22335: Fix crash when trying to enlarge a bytearray to 0x7fffffff ↵Antoine Pitrou2014-11-021-4/+4
|\ | | | | | | bytes on a 32-bit platform.
| * Issue #22335: Fix crash when trying to enlarge a bytearray to 0x7fffffff ↵Antoine Pitrou2014-11-021-4/+4
| | | | | | | | bytes on a 32-bit platform.
* | Issue #21233: Rename the C structure "PyMemAllocator" to "PyMemAllocatorEx" toVictor Stinner2014-06-021-7/+7
| | | | | | | | | | make sure that the code using it will be adapted for the new "calloc" field (instead of crashing).
* | Issue #21233: Fix _PyObject_Alloc() when compiled with WITH_VALGRIND definedVictor Stinner2014-05-061-3/+3
| |
* | Issue #21233: Oops, Fix _PyObject_Alloc(): initialize nbytes before going toVictor Stinner2014-05-021-3/+3
| | | | | | | | redirect.
* | Issue #21233: Add new C functions: PyMem_RawCalloc(), PyMem_Calloc(),Victor Stinner2014-05-021-17/+109
|/ | | | | | PyObject_Calloc(), _PyObject_GC_Calloc(). bytes(int) and bytearray(int) are now using ``calloc()`` instead of ``malloc()`` for large objects which is faster and use less memory (until the bytearray buffer is filled with data).
* Issue #18874: _PyObject_Malloc/Realloc/Free() now falls back onVictor Stinner2013-10-101-17/+19
| | | | | | _PyMem_RawMalloc/Realloc/Free, instead of _PyMem_Malloc/Realloc/Free. So it becomes possible to use the fast pymalloc allocator for the PYMEM_DOMAIN_MEM domain (PyMem_Malloc/Realloc/Free functions).
* Close #18596: Support address sanity checking in clang/GCCNick Coghlan2013-09-281-0/+20
| | | | | | This patch appropriately marks known false alarms in the small object allocator when address sanity checking is enabled (patch contributed by Dhiru Kholia).
* Fix minor typo.Georg Brandl2013-09-251-1/+1
|
* Update internal comments to say _something_ about the "API ID".Tim Peters2013-09-201-1/+3
| | | | Best I can tell, the possible values for this aren't documented anywhere.
* Nerge 3.3 into default.Tim Peters2013-09-061-1/+1
|\ | | | | | | | | | | | | | | Issue #18942: sys._debugmallocstats() output was damaged on Windows. _PyDebugAllocatorStats() called PyOS_snprintf() with a %zd format code, but MS doesn't support that code. Interpolated PY_FORMAT_SIZE_T in place of the "z".
| * Issue #18942: sys._debugmallocstats() output was damaged on Windows.Tim Peters2013-09-061-1/+1
| | | | | | | | | | | | _PyDebugAllocatorStats() called PyOS_snprintf() with a %zd format code, but MS doesn't support that code. Interpolated PY_FORMAT_SIZE_T in place of the "z".
* | Issue #18408: Fix _PyMem_DebugRealloc()Victor Stinner2013-07-081-6/+8
| | | | | | | | | | | | | | | | Don't mark old extra memory dead before calling realloc(). realloc() can fail and realloc() must not touch the original buffer on failure. So mark old extra memory dead only on success if the new buffer did not move (has the same address).
* | Issue #18203: Add _PyMem_RawStrdup() and _PyMem_Strdup()Victor Stinner2013-07-071-0/+28
| | | | | | | | | | Replace strdup() with _PyMem_RawStrdup() or _PyMem_Strdup(), depending if the GIL is held or not.
* | Issue #3329: Fix _PyObject_ArenaVirtualFree()Victor Stinner2013-07-071-1/+1
| | | | | | | | | | According to VirtualFree() documentation, the size must be zero if the "free type" is MEM_RELEASE.
* | Issue #3329: Implement the PEP 445Victor Stinner2013-07-071-149/+355
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add new enum: * PyMemAllocatorDomain Add new structures: * PyMemAllocator * PyObjectArenaAllocator Add new functions: * PyMem_RawMalloc(), PyMem_RawRealloc(), PyMem_RawFree() * PyMem_GetAllocator(), PyMem_SetAllocator() * PyObject_GetArenaAllocator(), PyObject_SetArenaAllocator() * PyMem_SetupDebugHooks() Changes: * PyMem_Malloc()/PyObject_Realloc() now always call malloc()/realloc(), instead of calling PyObject_Malloc()/PyObject_Realloc() in debug mode. * PyObject_Malloc()/PyObject_Realloc() now falls back to PyMem_Malloc()/PyMem_Realloc() for allocations larger than 512 bytes. * Redesign debug checks on memory block allocators as hooks, instead of using C macros
* | Issue #13483: Use VirtualAlloc in obmalloc on Windows.Martin v. Löwis2013-06-271-2/+12
| |
* | Revert changeset 6661a8154eb3: Issue #3329: Add new APIs to customize memory ↵Victor Stinner2013-06-151-364/+137
| | | | | | | | | | | | allocators The new API require more discussion.
* | Issue #3329: Add new APIs to customize memory allocatorsVictor Stinner2013-06-141-137/+364
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add a new PyMemAllocators structure * New functions: - PyMem_RawMalloc(), PyMem_RawRealloc(), PyMem_RawFree(): GIL-free memory allocator functions - PyMem_GetRawAllocators(), PyMem_SetRawAllocators() - PyMem_GetAllocators(), PyMem_SetAllocators() - PyMem_SetupDebugHooks() - _PyObject_GetArenaAllocators(), _PyObject_SetArenaAllocators() * Add unit test for PyMem_Malloc(0) and PyObject_Malloc(0) * Add unit test for new get/set allocators functions * PyObject_Malloc() now falls back on PyMem_Malloc() instead of malloc() if size is bigger than SMALL_REQUEST_THRESHOLD, and PyObject_Realloc() falls back on PyMem_Realloc() instead of realloc() * PyMem_Malloc() and PyMem_Realloc() now always call malloc() and realloc(), instead of calling PyObject_Malloc() and PyObject_Realloc() in debug mode
* | Issue #17469: Fix _Py_GetAllocatedBlocks() and sys.getallocatedblocks() when ↵Antoine Pitrou2013-04-051-3/+5
| | | | | | | | running on valgrind.
* | merge 3.3 (#17228)Benjamin Peterson2013-02-201-1/+1
|\ \ | |/
| * fix building without pymalloc (closes #17228)Benjamin Peterson2013-02-201-1/+1
| |
* | Following issue #13390, fix compilation --without-pymalloc, and make ↵Antoine Pitrou2012-12-171-0/+7
| | | | | | | | sys.getallocatedblocks() return 0 in that situation.
* | Issue #13390: New function :func:`sys.getallocatedblocks()` returns the ↵Antoine Pitrou2012-12-091-1/+20
|/ | | | | | number of memory blocks currently allocated. Also, the ``-R`` option to regrtest uses this function to guard against memory allocation leaks.
* Issue #15144: Fix possible integer overflow when handling pointers as ↵Antoine Pitrou2012-09-201-5/+2
| | | | | | integer values, by using Py_uintptr_t instead of size_t. Patch by Serhiy Storchaka.
* Issue #14785: Add sys._debugmallocstats() to help debug low-level memory ↵David Malcolm2012-06-221-33/+48
| | | | allocation issues
* Close #14232: catch mmap() failure in new_arena() of obmallocVictor Stinner2012-03-091-3/+8
|