winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
January 2010
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
3 participants
615 discussions
Start a n
N
ew thread
Alexandre Julliard : ntdll: Fill the tail of large blocks too for tail checking.
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: dedabe9d543331acb6b26b21f4da1eb54cf7bf9d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=dedabe9d543331acb6b26b21f…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 26 16:04:45 2010 +0100 ntdll: Fill the tail of large blocks too for tail checking. --- dlls/ntdll/heap.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index b68af25..e112031 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -692,6 +692,7 @@ static void *allocate_large_block( HEAP *heap, DWORD flags, SIZE_T size ) arena->block_size = block_size; arena->size = ARENA_LARGE_SIZE; arena->magic = ARENA_LARGE_MAGIC; + mark_block_tail( (char *)(arena + 1) + size, block_size - sizeof(*arena) - size, flags ); list_add_tail( &heap->large_list, &arena->entry ); notify_alloc( arena + 1, size, flags & HEAP_ZERO_MEMORY ); return arena + 1; @@ -722,9 +723,13 @@ static void *realloc_large_block( HEAP *heap, DWORD flags, void *ptr, SIZE_T siz if (arena->block_size - sizeof(*arena) >= size) { + SIZE_T unused = arena->block_size - sizeof(*arena) - size; + /* FIXME: we could remap zero-pages instead */ - if ((flags & HEAP_ZERO_MEMORY) && size > arena->data_size) - memset( (char *)ptr + arena->data_size, 0, size - arena->data_size ); + if (size > arena->data_size) + initialize_block( (char *)ptr + arena->data_size, size - arena->data_size, unused, flags ); + else + mark_block_tail( (char *)ptr + size, unused, flags ); arena->data_size = size; return ptr; }
1
0
0
0
Alexandre Julliard : ntdll: Move alloc notification closer to the allocation for large blocks.
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: cb2a5f7ef9d5ca55c27d3cb53b017c0c3c655f2a URL:
http://source.winehq.org/git/wine.git/?a=commit;h=cb2a5f7ef9d5ca55c27d3cb53…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 26 16:03:07 2010 +0100 ntdll: Move alloc notification closer to the allocation for large blocks. --- dlls/ntdll/heap.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 72a0069..b68af25 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -693,6 +693,7 @@ static void *allocate_large_block( HEAP *heap, DWORD flags, SIZE_T size ) arena->size = ARENA_LARGE_SIZE; arena->magic = ARENA_LARGE_MAGIC; list_add_tail( &heap->large_list, &arena->entry ); + notify_alloc( arena + 1, size, flags & HEAP_ZERO_MEMORY ); return arena + 1; } @@ -1518,7 +1519,6 @@ PVOID WINAPI RtlAllocateHeap( HANDLE heap, ULONG flags, SIZE_T size ) void *ret = allocate_large_block( heap, flags, size ); if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection ); if (!ret && (flags & HEAP_GENERATE_EXCEPTIONS)) RtlRaiseStatus( STATUS_NO_MEMORY ); - notify_alloc( ret, size, flags & HEAP_ZERO_MEMORY ); TRACE("(%p,%08x,%08lx): returning %p\n", heap, flags, size, ret ); return ret; } @@ -1675,7 +1675,6 @@ PVOID WINAPI RtlReAllocateHeap( HANDLE heap, ULONG flags, PVOID ptr, SIZE_T size if (!find_large_block( heapPtr, ptr )) goto error; if (!(ret = realloc_large_block( heapPtr, flags, ptr, size ))) goto oom; notify_free( ptr ); - notify_alloc( ret, size, flags & HEAP_ZERO_MEMORY ); goto done; } if ((char *)pArena < (char *)subheap->base + subheap->headerSize) goto error; @@ -1693,7 +1692,6 @@ PVOID WINAPI RtlReAllocateHeap( HANDLE heap, ULONG flags, PVOID ptr, SIZE_T size { if (flags & HEAP_REALLOC_IN_PLACE_ONLY) goto oom; if (!(ret = allocate_large_block( heapPtr, flags, size ))) goto oom; - notify_alloc( ret, size, flags & HEAP_ZERO_MEMORY ); memcpy( ret, pArena + 1, oldActualSize ); notify_free( pArena + 1 ); HEAP_MakeInUseBlockFree( subheap, pArena );
1
0
0
0
Alexandre Julliard : kernel32/tests: Add tests for heap tail and free block checking.
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: b1c9ce44dd64596d176c9ee265e73511c5cad2f0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=b1c9ce44dd64596d176c9ee26…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 26 14:35:46 2010 +0100 kernel32/tests: Add tests for heap tail and free block checking. --- dlls/kernel32/tests/heap.c | 139 +++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 131 insertions(+), 8 deletions(-) diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c index b213339..11a11a5 100644 --- a/dlls/kernel32/tests/heap.c +++ b/dlls/kernel32/tests/heap.c @@ -31,6 +31,12 @@ #define MAGIC_DEAD 0xdeadbeef +/* some undocumented flags (names are made up) */ +#define HEAP_PAGE_ALLOCS 0x01000000 +#define HEAP_VALIDATE 0x10000000 +#define HEAP_VALIDATE_ALL 0x20000000 +#define HEAP_VALIDATE_PARAMS 0x40000000 + static BOOL (WINAPI *pHeapQueryInformation)(HANDLE, HEAP_INFORMATION_CLASS, PVOID, SIZE_T, PSIZE_T); static ULONG (WINAPI *pRtlGetNtGlobalFlags)(void); @@ -478,6 +484,119 @@ static void test_HeapQueryInformation(void) ok(info == 0 || info == 1 || info == 2, "expected 0, 1 or 2, got %u\n", info); } +static void test_heap_checks( DWORD flags ) +{ + BYTE old, *p, *p2; + BOOL ret; + SIZE_T size; + + if (flags & HEAP_PAGE_ALLOCS) return; /* no tests for that case yet */ + trace( "testing heap flags %08x\n", flags ); + + p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 17 ); + ok( p != NULL, "HeapAlloc failed\n" ); + + ret = HeapValidate( GetProcessHeap(), 0, p ); + ok( ret, "HeapValidate failed\n" ); + + size = HeapSize( GetProcessHeap(), 0, p ); + ok( size == 17, "Wrong size %lu\n", size ); + + ok( p[14] == 0, "wrong data %x\n", p[14] ); + ok( p[15] == 0, "wrong data %x\n", p[15] ); + ok( p[16] == 0, "wrong data %x\n", p[16] ); + + if (flags & HEAP_TAIL_CHECKING_ENABLED) + { + ok( p[17] == 0xab, "wrong padding %x\n", p[17] ); + ok( p[18] == 0xab, "wrong padding %x\n", p[18] ); + ok( p[19] == 0xab, "wrong padding %x\n", p[19] ); + } + + p2 = HeapReAlloc( GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, p, 14 ); + if (p2 == p) + { + if (flags & HEAP_TAIL_CHECKING_ENABLED) + { + ok( p[14] == 0xab, "wrong padding %x\n", p[14] ); + ok( p[15] == 0xab, "wrong padding %x\n", p[15] ); + ok( p[16] == 0xab, "wrong padding %x\n", p[16] ); + } + else + { + ok( p[14] == 0, "wrong padding %x\n", p[14] ); + ok( p[15] == 0, "wrong padding %x\n", p[15] ); + ok( p[16] == 0, "wrong padding %x\n", p[16] ); + } + } + else skip( "realloc in place failed\n "); + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( ret, "HeapFree failed\n" ); + + p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 17 ); + ok( p != NULL, "HeapAlloc failed\n" ); + old = p[17]; + p[17] = 0xcc; + + if (flags & HEAP_TAIL_CHECKING_ENABLED) + { + ret = HeapValidate( GetProcessHeap(), 0, p ); + ok( !ret, "HeapValidate succeeded\n" ); + + /* other calls only check when HEAP_VALIDATE is set */ + if (flags & HEAP_VALIDATE) + { + size = HeapSize( GetProcessHeap(), 0, p ); + ok( size == ~(SIZE_T)0, "Wrong size %lu\n", size ); + + p2 = HeapReAlloc( GetProcessHeap(), 0, p, 14 ); + ok( p2 == NULL, "HeapReAlloc succeeded\n" ); + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( !ret, "HeapFree succeeded\n" ); + } + + p[17] = old; + size = HeapSize( GetProcessHeap(), 0, p ); + ok( size == 17, "Wrong size %lu\n", size ); + + p2 = HeapReAlloc( GetProcessHeap(), 0, p, 14 ); + ok( p2 != NULL, "HeapReAlloc failed\n" ); + p = p2; + } + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( ret, "HeapFree failed\n" ); + + p = HeapAlloc( GetProcessHeap(), 0, 37 ); + ok( p != NULL, "HeapAlloc failed\n" ); + memset( p, 0xcc, 37 ); + + ret = HeapFree( GetProcessHeap(), 0, p ); + ok( ret, "HeapFree failed\n" ); + + if (flags & HEAP_FREE_CHECKING_ENABLED) + { + ok( p[16] == 0xee, "wrong data %x\n", p[16] ); + ok( p[17] == 0xfe, "wrong data %x\n", p[17] ); + ok( p[18] == 0xee, "wrong data %x\n", p[18] ); + ok( p[19] == 0xfe, "wrong data %x\n", p[19] ); + + ret = HeapValidate( GetProcessHeap(), 0, NULL ); + ok( ret, "HeapValidate failed\n" ); + + old = p[16]; + p[16] = 0xcc; + ret = HeapValidate( GetProcessHeap(), 0, NULL ); + ok( !ret, "HeapValidate succeeded\n" ); + + p[16] = old; + ret = HeapValidate( GetProcessHeap(), 0, NULL ); + ok( ret, "HeapValidate failed\n" ); + } +} + static void test_debug_heap( const char *argv0, DWORD flags ) { char keyname[MAX_PATH]; @@ -531,13 +650,13 @@ static DWORD heap_flags_from_global_flag( DWORD flag ) if (flag & FLG_HEAP_ENABLE_FREE_CHECK) ret |= HEAP_FREE_CHECKING_ENABLED; if (flag & FLG_HEAP_VALIDATE_PARAMETERS) - ret |= 0x50000000 | HEAP_TAIL_CHECKING_ENABLED | HEAP_FREE_CHECKING_ENABLED; + ret |= HEAP_VALIDATE_PARAMS | HEAP_VALIDATE | HEAP_TAIL_CHECKING_ENABLED | HEAP_FREE_CHECKING_ENABLED; if (flag & FLG_HEAP_VALIDATE_ALL) - ret |= 0x30000000 | HEAP_TAIL_CHECKING_ENABLED | HEAP_FREE_CHECKING_ENABLED; + ret |= HEAP_VALIDATE_ALL | HEAP_VALIDATE | HEAP_TAIL_CHECKING_ENABLED | HEAP_FREE_CHECKING_ENABLED; if (flag & FLG_HEAP_DISABLE_COALESCING) ret |= HEAP_DISABLE_COALESCE_ON_FREE; if (flag & FLG_HEAP_PAGE_ALLOCS) - ret |= 0x01000000 | HEAP_GROWABLE; + ret |= HEAP_PAGE_ALLOCS | HEAP_GROWABLE; return ret; } @@ -545,6 +664,7 @@ static void test_child_heap( const char *arg ) { struct heap_layout *heap = GetProcessHeap(); DWORD expected = strtoul( arg, 0, 16 ); + DWORD expect_heap; if (expected == 0xdeadbeef) /* expected value comes from Session Manager global flags */ { @@ -572,6 +692,8 @@ static void test_child_heap( const char *arg ) ok( pRtlGetNtGlobalFlags() == expected, "%s: got global flags %08x expected %08x\n", arg, pRtlGetNtGlobalFlags(), expected ); + expect_heap = heap_flags_from_global_flag( expected ); + if (!(heap->flags & HEAP_GROWABLE) || heap->flags == 0xeeeeeeee) /* vista layout */ { if (expected & FLG_HEAP_PAGE_ALLOCS) @@ -582,12 +704,13 @@ static void test_child_heap( const char *arg ) } else { - expected = heap_flags_from_global_flag( expected ); - ok( heap->flags == (expected | HEAP_GROWABLE), - "%s: got heap flags %08x expected %08x\n", arg, heap->flags, expected ); - ok( heap->force_flags == (expected & ~0x18000080), - "%s: got heap force flags %08x expected %08x\n", arg, heap->force_flags, expected ); + ok( heap->flags == (expect_heap | HEAP_GROWABLE), + "%s: got heap flags %08x expected %08x\n", arg, heap->flags, expect_heap ); + ok( heap->force_flags == (expect_heap & ~0x18000080), + "%s: got heap force flags %08x expected %08x\n", arg, heap->force_flags, expect_heap ); } + + test_heap_checks( expect_heap ); } START_TEST(heap)
1
0
0
0
Alexandre Julliard : ntdll: Verify free block contents when validating the heap.
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: 6864777a107268ad1f05ebbe408be8dd38e7219e URL:
http://source.winehq.org/git/wine.git/?a=commit;h=6864777a107268ad1f05ebbe4…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 26 14:35:08 2010 +0100 ntdll: Verify free block contents when validating the heap. --- dlls/ntdll/heap.c | 35 ++++++++++++++++++++++++++--------- 1 files changed, 26 insertions(+), 9 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 9a80116..72a0069 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -1005,6 +1005,8 @@ static BOOL HEAP_IsValidArenaPtr( const HEAP *heap, const ARENA_FREE *ptr ) */ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) { + DWORD flags = subheap->heap->flags; + SIZE_T size; ARENA_FREE *prev, *next; char *heapEnd = (char *)subheap->base + subheap->size; @@ -1030,10 +1032,10 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) return FALSE; } /* Check arena size */ - if ((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) > heapEnd) + size = pArena->size & ARENA_SIZE_MASK; + if ((char *)(pArena + 1) + size > heapEnd) { - ERR("Heap %p: bad size %08x for free arena %p\n", - subheap->heap, pArena->size & ARENA_SIZE_MASK, pArena ); + ERR("Heap %p: bad size %08lx for free arena %p\n", subheap->heap, size, pArena ); return FALSE; } /* Check that next pointer is valid */ @@ -1069,25 +1071,40 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) return FALSE; } /* Check that next block has PREV_FREE flag */ - if ((char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd) + if ((char *)(pArena + 1) + size < heapEnd) { - if (!(*(DWORD *)((char *)(pArena + 1) + - (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE)) + if (!(*(DWORD *)((char *)(pArena + 1) + size) & ARENA_FLAG_PREV_FREE)) { ERR("Heap %p: free arena %p next block has no PREV_FREE flag\n", subheap->heap, pArena ); return FALSE; } /* Check next block back pointer */ - if (*((ARENA_FREE **)((char *)(pArena + 1) + - (pArena->size & ARENA_SIZE_MASK)) - 1) != pArena) + if (*((ARENA_FREE **)((char *)(pArena + 1) + size) - 1) != pArena) { ERR("Heap %p: arena %p has wrong back ptr %p\n", subheap->heap, pArena, - *((ARENA_FREE **)((char *)(pArena+1) + (pArena->size & ARENA_SIZE_MASK)) - 1)); + *((ARENA_FREE **)((char *)(pArena+1) + size) - 1)); return FALSE; } } + if (flags & HEAP_FREE_CHECKING_ENABLED) + { + DWORD *ptr = (DWORD *)(pArena + 1); + char *end = (char *)(pArena + 1) + size; + + if (end >= heapEnd) end = (char *)subheap->base + subheap->commitSize; + while (ptr < (DWORD *)end - 1) + { + if (*ptr != ARENA_FREE_FILLER) + { + ERR("Heap %p: free block %p overwritten at %p by %08x\n", + subheap->heap, (ARENA_INUSE *)pArena + 1, ptr, *ptr ); + return FALSE; + } + ptr++; + } + } return TRUE; }
1
0
0
0
Alexandre Julliard : ntdll: Verify the tail contents when validating an in-use block with tail checking enabled .
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: c0abf594f8e57d9947ab1b203f4125c3f81cc61d URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c0abf594f8e57d9947ab1b203…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 26 14:34:31 2010 +0100 ntdll: Verify the tail contents when validating an in-use block with tail checking enabled. --- dlls/ntdll/heap.c | 43 ++++++++++++++++++++++++++++++++++--------- 1 files changed, 34 insertions(+), 9 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 9d020ee..9a80116 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -429,8 +429,11 @@ static HEAP *HEAP_GetPtr( } if ((heapPtr->flags & HEAP_VALIDATE_ALL) && !HEAP_IsRealArena( heapPtr, 0, NULL, NOISY )) { - HEAP_Dump( heapPtr ); - assert( FALSE ); + if (TRACE_ON(heap)) + { + HEAP_Dump( heapPtr ); + assert( FALSE ); + } return NULL; } return heapPtr; @@ -1094,6 +1097,8 @@ static BOOL HEAP_ValidateFreeArena( SUBHEAP *subheap, ARENA_FREE *pArena ) */ static BOOL HEAP_ValidateInUseArena( const SUBHEAP *subheap, const ARENA_INUSE *pArena, BOOL quiet ) { + SIZE_T size; + DWORD i, flags = subheap->heap->flags; const char *heapEnd = (const char *)subheap->base + subheap->size; /* Check for unaligned pointers */ @@ -1136,18 +1141,19 @@ static BOOL HEAP_ValidateInUseArena( const SUBHEAP *subheap, const ARENA_INUSE * return FALSE; } /* Check arena size */ - if ((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) > heapEnd) + size = pArena->size & ARENA_SIZE_MASK; + if ((const char *)(pArena + 1) + size > heapEnd || + (const char *)(pArena + 1) + size < (const char *)(pArena + 1)) { - ERR("Heap %p: bad size %08x for in-use arena %p\n", - subheap->heap, pArena->size & ARENA_SIZE_MASK, pArena ); + ERR("Heap %p: bad size %08lx for in-use arena %p\n", subheap->heap, size, pArena ); return FALSE; } /* Check next arena PREV_FREE flag */ - if (((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK) < heapEnd) && - (*(const DWORD *)((const char *)(pArena + 1) + (pArena->size & ARENA_SIZE_MASK)) & ARENA_FLAG_PREV_FREE)) + if (((const char *)(pArena + 1) + size < heapEnd) && + (*(const DWORD *)((const char *)(pArena + 1) + size) & ARENA_FLAG_PREV_FREE)) { - ERR("Heap %p: in-use arena %p next block has PREV_FREE flag\n", - subheap->heap, pArena ); + ERR("Heap %p: in-use arena %p next block %p has PREV_FREE flag %x\n", + subheap->heap, pArena, (const char *)(pArena + 1) + size,*(const DWORD *)((const char *)(pArena + 1) + size) ); return FALSE; } /* Check prev free arena */ @@ -1177,6 +1183,25 @@ static BOOL HEAP_ValidateInUseArena( const SUBHEAP *subheap, const ARENA_INUSE * return FALSE; } } + /* Check unused size */ + if (pArena->unused_bytes > size) + { + ERR("Heap %p: invalid unused size %08x/%08lx\n", subheap->heap, pArena->unused_bytes, size ); + return FALSE; + } + /* Check unused bytes */ + if (flags & HEAP_TAIL_CHECKING_ENABLED) + { + const unsigned char *data = (const unsigned char *)(pArena + 1) + size - pArena->unused_bytes; + + for (i = 0; i < pArena->unused_bytes; i++) + { + if (data[i] == ARENA_TAIL_FILLER) continue; + ERR("Heap %p: block %p tail overwritten at %p (byte %u/%u == 0x%02x)\n", + subheap->heap, pArena + 1, data + i, i, pArena->unused_bytes, data[i] ); + return FALSE; + } + } return TRUE; }
1
0
0
0
Alexandre Julliard : ntdll: Fill existing tail and free blocks when the debug flags are changed after heap creation .
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: a19269509910b95ae20247608010638a4832bd75 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=a19269509910b95ae20247608…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 26 14:31:22 2010 +0100 ntdll: Fill existing tail and free blocks when the debug flags are changed after heap creation. --- dlls/ntdll/heap.c | 34 ++++++++++++++++++++++++++++++++-- 1 files changed, 32 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index d8291b8..9d020ee 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -1273,6 +1273,7 @@ void heap_set_debug_flags( HANDLE handle ) ULONG flags = 0; if (TRACE_ON(heap)) global_flags |= FLG_HEAP_VALIDATE_ALL; + if (WARN_ON(heap)) global_flags |= FLG_HEAP_VALIDATE_PARAMETERS; if (global_flags & FLG_HEAP_ENABLE_TAIL_CHECK) flags |= HEAP_TAIL_CHECKING_ENABLED; if (global_flags & FLG_HEAP_ENABLE_FREE_CHECK) flags |= HEAP_FREE_CHECKING_ENABLED; @@ -1286,10 +1287,39 @@ void heap_set_debug_flags( HANDLE handle ) flags |= HEAP_VALIDATE | HEAP_VALIDATE_ALL | HEAP_TAIL_CHECKING_ENABLED | HEAP_FREE_CHECKING_ENABLED; - if (WARN_ON(heap)) flags |= HEAP_VALIDATE | HEAP_VALIDATE_PARAMS | HEAP_FREE_CHECKING_ENABLED; - heap->flags |= flags; heap->force_flags |= flags & ~(HEAP_VALIDATE | HEAP_DISABLE_COALESCE_ON_FREE); + + if (flags & (HEAP_FREE_CHECKING_ENABLED | HEAP_TAIL_CHECKING_ENABLED)) /* fix existing blocks */ + { + SUBHEAP *subheap; + + LIST_FOR_EACH_ENTRY( subheap, &heap->subheap_list, SUBHEAP, entry ) + { + char *ptr = (char *)subheap->base + subheap->headerSize; + char *end = (char *)subheap->base + subheap->commitSize; + while (ptr < end) + { + ARENA_INUSE *arena = (ARENA_INUSE *)ptr; + SIZE_T size = arena->size & ARENA_SIZE_MASK; + if (arena->size & ARENA_FLAG_FREE) + { + SIZE_T count = size; + + ptr += sizeof(ARENA_FREE) + size; + if (ptr > end) count = end - (char *)((ARENA_FREE *)arena + 1); + else count -= sizeof(DWORD); + mark_block_free( (ARENA_FREE *)arena + 1, count, flags ); + } + else + { + mark_block_tail( (char *)(arena + 1) + size - arena->unused_bytes, + arena->unused_bytes, flags ); + ptr += sizeof(ARENA_INUSE) + size; + } + } + } + } }
1
0
0
0
Alexandre Julliard : ntdll: Use the same value as Windows for filling free heap blocks.
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: c15660054f70c69d8b4f72a4ad98d4bd59301023 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=c15660054f70c69d8b4f72a4a…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 26 14:30:25 2010 +0100 ntdll: Use the same value as Windows for filling free heap blocks. --- dlls/ntdll/heap.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 2f45943..d8291b8 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -85,7 +85,7 @@ typedef struct #define ARENA_INUSE_FILLER 0x55 #define ARENA_TAIL_FILLER 0xab -#define ARENA_FREE_FILLER 0xaa +#define ARENA_FREE_FILLER 0xfeeefeee /* everything is aligned on 8 byte boundaries (16 for Win64) */ #define ALIGNMENT (2*sizeof(void*)) @@ -169,7 +169,11 @@ static BOOL HEAP_IsRealArena( HEAP *heapPtr, DWORD flags, LPCVOID block, BOOL qu /* 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) memset( ptr, ARENA_FREE_FILLER, 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)
1
0
0
0
Alexandre Julliard : ntdll: Fill the tail of heap blocks when HEAP_TAIL_CHECKING_ENABLED is set.
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: 5cd254d7292224e0ac116e7ba2a28417229557be URL:
http://source.winehq.org/git/wine.git/?a=commit;h=5cd254d7292224e0ac116e7ba…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Jan 26 14:29:51 2010 +0100 ntdll: Fill the tail of heap blocks when HEAP_TAIL_CHECKING_ENABLED is set. --- dlls/ntdll/heap.c | 69 +++++++++++++++++++++++++++++----------------------- 1 files changed, 38 insertions(+), 31 deletions(-) diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index cbabe4e..2f45943 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -84,6 +84,7 @@ typedef struct #define ARENA_LARGE_MAGIC 0x6752614c #define ARENA_INUSE_FILLER 0x55 +#define ARENA_TAIL_FILLER 0xab #define ARENA_FREE_FILLER 0xaa /* everything is aligned on 8 byte boundaries (16 for Win64) */ @@ -187,30 +188,49 @@ static inline void mark_block_initialized( void *ptr, SIZE_T size ) } /* mark a block of memory as uninitialized for debugging purposes */ -static inline void mark_block_uninitialized( void *ptr, SIZE_T size, DWORD flags ) +static inline void mark_block_uninitialized( void *ptr, SIZE_T size ) { #if defined(VALGRIND_MAKE_MEM_UNDEFINED) VALGRIND_DISCARD( VALGRIND_MAKE_MEM_UNDEFINED( ptr, size )); #elif defined(VALGRIND_MAKE_WRITABLE) VALGRIND_DISCARD( VALGRIND_MAKE_WRITABLE( ptr, size )); #endif - if (flags & HEAP_FREE_CHECKING_ENABLED) +} + +/* mark a block of memory as a tail block */ +static inline void mark_block_tail( void *ptr, SIZE_T size, DWORD flags ) +{ + mark_block_uninitialized( ptr, size ); + if (flags & HEAP_TAIL_CHECKING_ENABLED) { - memset( ptr, ARENA_INUSE_FILLER, size ); -#if defined(VALGRIND_MAKE_MEM_UNDEFINED) - VALGRIND_DISCARD( VALGRIND_MAKE_MEM_UNDEFINED( ptr, size )); -#elif defined(VALGRIND_MAKE_WRITABLE) - /* make it uninitialized to valgrind again */ - VALGRIND_DISCARD( 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 } } -/* clear contents of a block of memory */ -static inline void clear_block( void *ptr, SIZE_T size ) +/* initialize contents of a newly created block of memory */ +static inline void initialize_block( void *ptr, SIZE_T size, SIZE_T unused, DWORD flags ) { - mark_block_initialized( ptr, size ); - memset( ptr, 0, size ); + if (flags & HEAP_ZERO_MEMORY) + { + mark_block_initialized( ptr, size ); + memset( ptr, 0, size ); + } + else + { + mark_block_uninitialized( ptr, size ); + if (flags & HEAP_FREE_CHECKING_ENABLED) + { + memset( ptr, ARENA_INUSE_FILLER, size ); + mark_block_uninitialized( ptr, size ); + } + } + + mark_block_tail( (char *)ptr + size, unused, flags ); } /* notify that a new block of memory has been allocated for debugging purposes */ @@ -527,7 +547,7 @@ static void HEAP_CreateFreeBlock( SUBHEAP *subheap, void *ptr, SIZE_T size ) DWORD flags = subheap->heap->flags; /* Create a free arena */ - mark_block_uninitialized( ptr, sizeof(ARENA_FREE), flags ); + mark_block_uninitialized( ptr, sizeof(ARENA_FREE) ); pFree = ptr; pFree->magic = ARENA_FREE_MAGIC; @@ -1457,14 +1477,7 @@ PVOID WINAPI RtlAllocateHeap( HANDLE heap, ULONG flags, SIZE_T size ) pInUse->unused_bytes = (pInUse->size & ARENA_SIZE_MASK) - size; notify_alloc( pInUse + 1, size, flags & HEAP_ZERO_MEMORY ); - - if (flags & HEAP_ZERO_MEMORY) - { - clear_block( pInUse + 1, size ); - mark_block_uninitialized( (char *)(pInUse + 1) + size, pInUse->unused_bytes, flags ); - } - else - mark_block_uninitialized( pInUse + 1, pInUse->size & ARENA_SIZE_MASK, flags ); + initialize_block( pInUse + 1, size, pInUse->unused_bytes, flags ); if (!(flags & HEAP_NO_SERIALIZE)) RtlLeaveCriticalSection( &heapPtr->critSection ); @@ -1671,16 +1684,10 @@ PVOID WINAPI RtlReAllocateHeap( HANDLE heap, ULONG flags, PVOID ptr, SIZE_T size /* Clear the extra bytes if needed */ if (size > oldActualSize) - { - if (flags & HEAP_ZERO_MEMORY) - { - clear_block( (char *)(pArena + 1) + oldActualSize, size - oldActualSize ); - mark_block_uninitialized( (char *)(pArena + 1) + size, pArena->unused_bytes, flags ); - } - else - mark_block_uninitialized( (char *)(pArena + 1) + oldActualSize, - (pArena->size & ARENA_SIZE_MASK) - oldActualSize, flags ); - } + initialize_block( (char *)(pArena + 1) + oldActualSize, size - oldActualSize, + pArena->unused_bytes, flags ); + else + mark_block_tail( (char *)(pArena + 1) + size, pArena->unused_bytes, flags ); /* Return the new arena */
1
0
0
0
Erich Hoover : hhctrl.ocx: Find node attributes in a case-insensitive way.
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: 39f485ac18cf9eaccc80d991242f4212b71c68f0 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=39f485ac18cf9eaccc80d9912…
Author: Erich Hoover <ehoover(a)mines.edu> Date: Mon Jan 25 09:06:02 2010 -0700 hhctrl.ocx: Find node attributes in a case-insensitive way. --- dlls/hhctrl.ocx/content.c | 46 +++++++++++++++++++++++++++++++++++--------- 1 files changed, 36 insertions(+), 10 deletions(-) diff --git a/dlls/hhctrl.ocx/content.c b/dlls/hhctrl.ocx/content.c index 4fc0176..39be04b 100644 --- a/dlls/hhctrl.ocx/content.c +++ b/dlls/hhctrl.ocx/content.c @@ -151,31 +151,57 @@ static BOOL next_node(stream_t *stream, strbuf_t *buf) return TRUE; } +/* + * Find the value of a named HTML attribute. + * + * Note: Attribute names are case insensitive, so it is necessary to + * put both the node text and the attribute name in the same case + * before attempting a string search. + */ static const char *get_attr(const char *node, const char *name, int *len) { const char *ptr, *ptr2; + int name_len, node_len; char name_buf[32]; - int nlen; + char *node_buf; + int i; - nlen = strlen(name); - memcpy(name_buf, name, nlen); - name_buf[nlen++] = '='; - name_buf[nlen++] = '\"'; - name_buf[nlen] = 0; - - ptr = strstr(node, name_buf); + /* Create a lower case copy of the node */ + node_len = strlen(node)+1; + node_buf = heap_alloc(node_len*sizeof(char)); + if(!node_buf) + return NULL; + memcpy(node_buf, node, node_len); + for(i=0;i<node_len;i++) + node_buf[i] = tolower(node_buf[i]); + /* Create a lower case copy of the attribute name (search string) */ + name_len = strlen(name); + memcpy(name_buf, name, name_len); + for(i=0;i<name_len;i++) + name_buf[i] = tolower(name_buf[i]); + name_buf[name_len++] = '='; + name_buf[name_len++] = '\"'; + name_buf[name_len] = 0; + + ptr = strstr(node_buf, name_buf); if(!ptr) { WARN("name not found\n"); + heap_free(name_buf); return NULL; } - ptr += nlen; + ptr += name_len; ptr2 = strchr(ptr, '\"'); if(!ptr2) + { + heap_free(name_buf); return NULL; + } *len = ptr2-ptr; - return ptr; + heap_free(name_buf); + /* Return the pointer offset within the original string */ + return node+(ptr-node_buf); } static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text)
1
0
0
0
Stefan Dösinger : wined3d: Put the APPLE_flush_buffer_range code into the right branch.
by Alexandre Julliard
26 Jan '10
26 Jan '10
Module: wine Branch: master Commit: ee720f05d1b925aae5f6530b3b1d3e32c520bc43 URL:
http://source.winehq.org/git/wine.git/?a=commit;h=ee720f05d1b925aae5f6530b3…
Author: Stefan Dösinger <stefan(a)codeweavers.com> Date: Mon Jan 25 23:39:43 2010 +0100 wined3d: Put the APPLE_flush_buffer_range code into the right branch. --- dlls/wined3d/buffer.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 024aab5..e38a861 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -145,11 +145,6 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This) { TRACE("Gl usage = GL_STREAM_DRAW_ARB\n"); gl_usage = GL_STREAM_DRAW_ARB; - } - else - { - TRACE("Gl usage = GL_DYNAMIC_DRAW_ARB\n"); - gl_usage = GL_DYNAMIC_DRAW_ARB; if(gl_info->supported[APPLE_FLUSH_BUFFER_RANGE]) { @@ -158,6 +153,11 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This) This->flags |= WINED3D_BUFFER_FLUSH; } } + else + { + TRACE("Gl usage = GL_DYNAMIC_DRAW_ARB\n"); + gl_usage = GL_DYNAMIC_DRAW_ARB; + } /* Reserve memory for the buffer. The amount of data won't change * so we are safe with calling glBufferData once and
1
0
0
0
← Newer
1
...
11
12
13
14
15
16
17
...
62
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
Results per page:
10
25
50
100
200