The MASM Forum

General => The Workshop => Topic started by: mikeburr on April 22, 2019, 09:08:34 PM

Title: HeapAlloc boundary issue with variablelength records ??
Post by: mikeburr on April 22, 2019, 09:08:34 PM
i wonder if anyone has experienced a problem with Heap Allocation using Variable length records.
the code is something like HeapAlloc,handle,Heap Zero Memory, length of data...
this would probably usually be used with a data mask or structure eg sizeof Some data structure
Generally This work fine
but failed rather oddly one one data length
I have a data header of N bytes followed by variable length data , 
and when N+data = 16 bytes [ie fell on some sort of boundary the allocation bombed ... i tried multiples of 16 + data length eg header = 12... data lengths 4,20,36,etc but strangely
this didnt fail ...
also it might be a first time issue in the operating system as i recall[though i cant be sure now !!]  it didnt do this if the second item fell on a boundary
to resolve the issue
i added a byte to the estimated length, as if it had a terminating zero, and didnt get the problem subsequently with any data length
[i should add that the data is irrelevant in this discussion where it is processed as hex ]
i didnt have the time to use Olly to see just where this was occurring in the op sys but will prob do so at some point .. regards mike b
Title: Re: HeapAlloc boundary issue with variablelength records ??
Post by: jj2007 on April 22, 2019, 09:31:17 PM
Post complete code, and we'll show you where the bug is 8)
Title: Re: HeapAlloc boundary issue with variablelength records ??
Post by: mikeburr on April 22, 2019, 09:49:36 PM
no point jj theres no bug in the code its in the heap allocation
regards mike b 
Title: Re: HeapAlloc boundary issue with variablelength records ??
Post by: jj2007 on April 22, 2019, 11:07:30 PM
Do you seriously think HeapAlloc is buggy? Do you have a vague idea how many Millions of lines of code use HeapAlloc?
Title: Re: HeapAlloc boundary issue with variablelength records ??
Post by: mikeburr on April 23, 2019, 02:53:24 AM
yep......thats why i asked
Title: Re: HeapAlloc boundary issue with variablelength records ??
Post by: hutch-- on April 23, 2019, 07:42:26 AM
> no point jj theres no bug in the code its in the heap allocation

It has been ,my experience that such claims end up being a bug in the code rather than the API function that was used in the code. If you think you have found a bug in the API function you would report it to Microsoft with a "please fix" note complete with a working example but as you have said that you don't have the time to debug it yourself and the problem in your code is so badly described, I don't see how anyone can help you.
Title: Re: HeapAlloc boundary issue with variablelength records ??
Post by: Tedd on April 25, 2019, 02:01:17 AM
Post a working example so this 'bug' can be confirmed (or refuted.)