Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
25931456
Commit
25931456
authored
Jun 06, 2004
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF bug 881641, make it easier to use valgrind
parent
91a90c86
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
4 deletions
+39
-4
Objects/obmalloc.c
Objects/obmalloc.c
+39
-4
No files found.
Objects/obmalloc.c
View file @
25931456
...
...
@@ -534,8 +534,32 @@ error:
* so the (I) < narenas must be false, saving us from trying to index into
* a NULL arenas.
*/
#define ADDRESS_IN_RANGE(P, I) \
((I) < narenas && (uptr)(P) - arenas[I] < (uptr)ARENA_SIZE)
#define Py_ADDRESS_IN_RANGE(P, POOL) \
((POOL)->arenaindex < narenas && \
(uptr)(P) - arenas[(POOL)->arenaindex] < (uptr)ARENA_SIZE)
/* This is only useful when running memory debuggers such as
* Purify or Valgrind. Uncomment to use.
*
*/
#define Py_USING_MEMORY_DEBUGGER
#ifdef Py_USING_MEMORY_DEBUGGER
/* Py_ADDRESS_IN_RANGE may access uninitialized memory by design
* This leads to thousands of spurious warnings when using
* Purify or Valgrind. By making a function, we can easily
* suppress the uninitialized memory reads in this one function.
* So we won't ignore real errors elsewhere.
*
* Disable the macro and use a function.
*/
#undef Py_ADDRESS_IN_RANGE
/* Don't make static, to ensure this isn't inlined. */
int
Py_ADDRESS_IN_RANGE
(
void
*
P
,
poolp
pool
);
#endif
/*==========================================================================*/
...
...
@@ -708,7 +732,7 @@ PyObject_Free(void *p)
return
;
pool
=
POOL_ADDR
(
p
);
if
(
ADDRESS_IN_RANGE
(
p
,
pool
->
arenaindex
))
{
if
(
Py_ADDRESS_IN_RANGE
(
p
,
pool
))
{
/* We allocated this address. */
LOCK
();
/*
...
...
@@ -791,7 +815,7 @@ PyObject_Realloc(void *p, size_t nbytes)
return
PyObject_Malloc
(
nbytes
);
pool
=
POOL_ADDR
(
p
);
if
(
ADDRESS_IN_RANGE
(
p
,
pool
->
arenaindex
))
{
if
(
Py_ADDRESS_IN_RANGE
(
p
,
pool
))
{
/* We're in charge of this block */
size
=
INDEX2SIZE
(
pool
->
szidx
);
if
(
nbytes
<=
size
)
{
...
...
@@ -1373,3 +1397,14 @@ _PyObject_DebugMallocStats(void)
}
#endif
/* PYMALLOC_DEBUG */
#ifdef Py_USING_MEMORY_DEBUGGER
/* Make this function last so gcc won't inline it
since the definition is after the reference. */
int
Py_ADDRESS_IN_RANGE
(
void
*
P
,
poolp
pool
)
{
return
((
pool
->
arenaindex
)
<
narenas
&&
(
uptr
)(
P
)
-
arenas
[
pool
->
arenaindex
]
<
(
uptr
)
ARENA_SIZE
);
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment