Groups > Microsoft > WinDbg > Re: Enabled page heap and !heap




Re: Enabled page heap and !heap

Re: Enabled page heap and !heap
Tue, 11 Mar 2008 08:18:38 -070
And, even in that case, the corruption would not have
been detected on the spot unless you had been using the `/unligned` option.

There is an inherent conflic between the alignment
requirements of heap allocations and the tail of one allocation.
For examle, with alignment of 8 bytes, typical of x86 architecture,
if you allocate 1 byte, you have 7 bytes of cushion.
Any corruption happening there cannot be detected till free.

With the `/unaligned` option you make the
allocations NOT to be 8 bytes aligned, and, you catch the corruption sooner,
at the expense of breaking possibly some components that relay on alignment.

-- 

-- 
This posting is provided "AS IS" with no warranties, and confers no
rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


"Marc Sherman" <masherman1970@yahoo.com> wrote in message 
news:ePTBf73gIHA.4724@TK2MSFTNGP02.phx.gbl...
> "jaj" <a.yukhanov@gmail.com> wrote in message 
> news:OeJxXQ2gIHA.1944@TK2MSFTNGP02.phx.gbl...
>> Hi,
>> I have launch the following test application with page heap enabled
>>
>> int main()
>> {
>>    char* str = (char*)malloc(5);
>>    strcpy(str, "12345");
>>    __asm int 3;
>>    free(str);  /// <- will crash here
>> }
>>
>> I wonder how can I use WinDbg to find the heap corruption before
free()? 
>> I tried "!heap -p -a 16c6ff8". It shows all information about
allocation 
>> but doesn't say anything about the heap was corrupted :-(. "!heap
-a -v" 
>> doesn't work either.
>
> Try with *full* page heap enabled.
>
> Marc
> 

Post Reply
Re: Enabled page heap and !heap
Tue, 11 Mar 2008 09:50:25 -040
"jaj" <a.yukhanov@gmail.com> wrote in message 
news:OeJxXQ2gIHA.1944@TK2MSFTNGP02.phx.gbl...
> Hi,
> I have launch the following test application with page heap enabled
>
> int main()
> {
>    char* str = (char*)malloc(5);
>    strcpy(str, "12345");
>    __asm int 3;
>    free(str);  /// <- will crash here
> }
>
> I wonder how can I use WinDbg to find the heap corruption before free()? I

> tried "!heap -p -a 16c6ff8". It shows all information about
allocation but 
> doesn't say anything about the heap was corrupted :-(. "!heap -a
-v" 
> doesn't work either.

Try with *full* page heap enabled.

Marc 

Post Reply
Enabled page heap and !heap
Tue, 11 Mar 2008 13:40:26 +030
Hi,
I have launch the following test application with page heap enabled

int main()
{
    char* str = (char*)malloc(5);
    strcpy(str, "12345");
    __asm int 3;
    free(str);  /// <- will crash here
}

I wonder how can I use WinDbg to find the heap corruption before free()? I 
tried "!heap -p -a 16c6ff8". It shows all information about allocation
but 
doesn't say anything about the heap was corrupted :-(. "!heap -a -v"
doesn't 
work either.
Thanks

Post Reply
Re: Enabled page heap and !heap
Thu, 13 Mar 2008 00:41:22 +030
Thanks
"Ivan Brugiolo [MSFT]" <ivanbrug@online.microsoft.com>
сообщил/сообщила в 
новостях следующее: news:%239iivs4gIHA.4712@TK2MSFTNGP04.phx.gbl...
> And, even in that case, the corruption would not have
> been detected on the spot unless you had been using the `/unligned` 
> option.
>
> There is an inherent conflic between the alignment
> requirements of heap allocations and the tail of one allocation.
> For examle, with alignment of 8 bytes, typical of x86 architecture,
> if you allocate 1 byte, you have 7 bytes of cushion.
> Any corruption happening there cannot be detected till free.
>
> With the `/unaligned` option you make the
> allocations NOT to be 8 bytes aligned, and, you catch the corruption 
> sooner,
> at the expense of breaking possibly some components that relay on 
> alignment.
>
> -- 
>
> -- 
> This posting is provided "AS IS" with no warranties, and confers
no 
> rights.
> Use of any included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
>
> "Marc Sherman" <masherman1970@yahoo.com> wrote in message 
> news:ePTBf73gIHA.4724@TK2MSFTNGP02.phx.gbl...
>> "jaj" <a.yukhanov@gmail.com> wrote in message 
>> news:OeJxXQ2gIHA.1944@TK2MSFTNGP02.phx.gbl...
>>> Hi,
>>> I have launch the following test application with page heap
enabled
>>>
>>> int main()
>>> {
>>>    char* str = (char*)malloc(5);
>>>    strcpy(str, "12345");
>>>    __asm int 3;
>>>    free(str);  /// <- will crash here
>>> }
>>>
>>> I wonder how can I use WinDbg to find the heap corruption before
free()? 
>>> I tried "!heap -p -a 16c6ff8". It shows all information
about allocation 
>>> but doesn't say anything about the heap was corrupted :-(.
"!heap -a -v" 
>>> doesn't work either.
>>
>> Try with *full* page heap enabled.
>>
>> Marc
>>
>
> 

Post Reply
about | contact