Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: Disable the alloc cache under address and memory sanitizers#29006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
charris merged 1 commit intonumpy:mainfromhawkinsp:asan
May 19, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletionsnumpy/_core/src/multiarray/alloc.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -99,6 +99,20 @@ indicate_hugepages(void *p, size_t size) {
}


/* Do not enable the alloc cache if the GIL is disabled, or if ASAN or MSAN
* instrumentation is enabled. The cache makes ASAN use-after-free or MSAN
* use-of-uninitialized-memory warnings less useful. */
#ifdef Py_GIL_DISABLED
#define USE_ALLOC_CACHE 0
#elif defined(__has_feature)
# if __has_feature(address_sanitizer) || __has_feature(memory_sanitizer)
# define USE_ALLOC_CACHE 0
# endif
#else
#define USE_ALLOC_CACHE 1
#endif


/* as the cache is managed in global variables verify the GIL is held */

/*
Expand All@@ -115,7 +129,7 @@ _npy_alloc_cache(npy_uintp nelem, npy_uintp esz, npy_uint msz,
assert((esz == 1 && cache == datacache) ||
(esz == sizeof(npy_intp) && cache == dimcache));
assert(PyGILState_Check());
#ifndef Py_GIL_DISABLED
#if USE_ALLOC_CACHE
if (nelem < msz) {
if (cache[nelem].available > 0) {
return cache[nelem].ptrs[--(cache[nelem].available)];
Expand All@@ -141,7 +155,7 @@ _npy_free_cache(void * p, npy_uintp nelem, npy_uint msz,
cache_bucket * cache, void (*dealloc)(void *))
{
assert(PyGILState_Check());
#ifndef Py_GIL_DISABLED
#if USE_ALLOC_CACHE
if (p != NULL && nelem < msz) {
if (cache[nelem].available < NCACHE) {
cache[nelem].ptrs[cache[nelem].available++] = p;
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp