Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
e4e8cabf
Commit
e4e8cabf
authored
May 30, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
May 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Split valgrind memory access control to separate helpers.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
parent
75f2af28
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
32 deletions
+30
-32
heap.c
dlls/ntdll/heap.c
+30
-32
No files found.
dlls/ntdll/heap.c
View file @
e4e8cabf
...
...
@@ -307,54 +307,56 @@ static inline BOOL check_subheap( const SUBHEAP *subheap )
static
BOOL
heap_validate
(
const
HEAP
*
heap
);
/* mark a block of memory as
fre
e for debugging purposes */
static
inline
void
mark_block_free
(
void
*
ptr
,
SIZE_T
size
,
DWORD
flags
)
/* mark a block of memory as
innacessibl
e for debugging purposes */
static
inline
void
valgrind_make_noaccess
(
void
const
*
ptr
,
SIZE_T
size
)
{
if
(
flags
&
HEAP_FREE_CHECKING_ENABLED
)
{
SIZE_T
i
;
for
(
i
=
0
;
i
<
size
/
sizeof
(
DWORD
);
i
++
)
((
DWORD
*
)
ptr
)[
i
]
=
ARENA_FREE_FILLER
;
}
#if defined(VALGRIND_MAKE_MEM_NOACCESS)
VALGRIND_DISCARD
(
VALGRIND_MAKE_MEM_NOACCESS
(
ptr
,
size
));
#elif defined(
VALGRIND_MAKE_NOACCESS)
VALGRIND_DISCARD
(
VALGRIND_MAKE_NOACCESS
(
ptr
,
size
));
VALGRIND_DISCARD
(
VALGRIND_MAKE_MEM_NOACCESS
(
ptr
,
size
)
);
#elif defined(VALGRIND_MAKE_NOACCESS)
VALGRIND_DISCARD
(
VALGRIND_MAKE_NOACCESS
(
ptr
,
size
)
);
#endif
}
/* mark a block of memory as initialized for debugging purposes */
static
inline
void
mark_block_initialized
(
void
*
ptr
,
SIZE_T
size
)
static
inline
void
valgrind_make_readable
(
void
const
*
ptr
,
SIZE_T
size
)
{
#if defined(VALGRIND_MAKE_MEM_DEFINED)
VALGRIND_DISCARD
(
VALGRIND_MAKE_MEM_DEFINED
(
ptr
,
size
));
VALGRIND_DISCARD
(
VALGRIND_MAKE_MEM_DEFINED
(
ptr
,
size
)
);
#elif defined(VALGRIND_MAKE_READABLE)
VALGRIND_DISCARD
(
VALGRIND_MAKE_READABLE
(
ptr
,
size
));
VALGRIND_DISCARD
(
VALGRIND_MAKE_READABLE
(
ptr
,
size
)
);
#endif
}
/* mark a block of memory as uninitialized for debugging purposes */
static
inline
void
mark_block_uninitialized
(
void
*
ptr
,
SIZE_T
size
)
static
inline
void
valgrind_make_writable
(
void
const
*
ptr
,
SIZE_T
size
)
{
#if defined(VALGRIND_MAKE_MEM_UNDEFINED)
VALGRIND_DISCARD
(
VALGRIND_MAKE_MEM_UNDEFINED
(
ptr
,
size
));
VALGRIND_DISCARD
(
VALGRIND_MAKE_MEM_UNDEFINED
(
ptr
,
size
)
);
#elif defined(VALGRIND_MAKE_WRITABLE)
VALGRIND_DISCARD
(
VALGRIND_MAKE_WRITABLE
(
ptr
,
size
));
VALGRIND_DISCARD
(
VALGRIND_MAKE_WRITABLE
(
ptr
,
size
)
);
#endif
}
/* mark a block of memory as free for debugging purposes */
static
inline
void
mark_block_free
(
void
*
ptr
,
SIZE_T
size
,
DWORD
flags
)
{
if
(
flags
&
HEAP_FREE_CHECKING_ENABLED
)
{
SIZE_T
i
;
for
(
i
=
0
;
i
<
size
/
sizeof
(
DWORD
);
i
++
)
((
DWORD
*
)
ptr
)[
i
]
=
ARENA_FREE_FILLER
;
}
valgrind_make_noaccess
(
ptr
,
size
);
}
/* mark a block of memory as a tail block */
static
inline
void
mark_block_tail
(
void
*
ptr
,
SIZE_T
size
,
DWORD
flags
)
{
if
(
flags
&
HEAP_TAIL_CHECKING_ENABLED
)
{
mark_block_uninitialized
(
ptr
,
size
);
valgrind_make_writable
(
ptr
,
size
);
memset
(
ptr
,
ARENA_TAIL_FILLER
,
size
);
}
#if defined(VALGRIND_MAKE_MEM_NOACCESS)
VALGRIND_DISCARD
(
VALGRIND_MAKE_MEM_NOACCESS
(
ptr
,
size
));
#elif defined( VALGRIND_MAKE_NOACCESS)
VALGRIND_DISCARD
(
VALGRIND_MAKE_NOACCESS
(
ptr
,
size
));
#endif
valgrind_make_noaccess
(
ptr
,
size
);
}
/* initialize contents of a newly created block of memory */
...
...
@@ -362,17 +364,13 @@ static inline void initialize_block( void *ptr, SIZE_T size, SIZE_T unused, DWOR
{
if
(
flags
&
HEAP_ZERO_MEMORY
)
{
mark_block_initialized
(
ptr
,
size
);
valgrind_make_writable
(
ptr
,
size
);
memset
(
ptr
,
0
,
size
);
}
else
else
if
(
flags
&
HEAP_FREE_CHECKING_ENABLED
)
{
mark_block_uninitialized
(
ptr
,
size
);
if
(
flags
&
HEAP_FREE_CHECKING_ENABLED
)
{
memset
(
ptr
,
ARENA_INUSE_FILLER
,
size
);
mark_block_uninitialized
(
ptr
,
size
);
}
valgrind_make_writable
(
ptr
,
size
);
memset
(
ptr
,
ARENA_INUSE_FILLER
,
size
);
}
mark_block_tail
(
(
char
*
)
ptr
+
size
,
unused
,
flags
);
...
...
@@ -679,7 +677,7 @@ static void create_free_block( SUBHEAP *subheap, struct block *block, SIZE_T blo
DWORD
flags
=
heap
->
flags
;
struct
block
*
next
;
mark_block_uninitialized
(
block
,
sizeof
(
*
entry
)
);
valgrind_make_writable
(
block
,
sizeof
(
*
entry
)
);
block_set_type
(
block
,
ARENA_FREE_MAGIC
);
block_set_size
(
block
,
BLOCK_FLAG_FREE
,
block_size
);
...
...
@@ -702,7 +700,7 @@ static void create_free_block( SUBHEAP *subheap, struct block *block, SIZE_T blo
{
/* set the next block PREV_FREE flag and back pointer */
block_set_size
(
next
,
BLOCK_FLAG_PREV_FREE
,
block_get_size
(
next
)
);
mark_block_initialized
(
(
struct
block
**
)
next
-
1
,
sizeof
(
struct
block
*
)
);
valgrind_make_writable
(
(
struct
block
**
)
next
-
1
,
sizeof
(
struct
block
*
)
);
*
((
struct
block
**
)
next
-
1
)
=
block
;
}
...
...
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