Author Topic: HeapAlloc boundary issue with variablelength records ??  (Read 290 times)

mikeburr

  • Member
  • **
  • Posts: 60
HeapAlloc boundary issue with variablelength records ??
« 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

jj2007

  • Member
  • *****
  • Posts: 9462
  • Assembler is fun ;-)
    • MasmBasic
Re: HeapAlloc boundary issue with variablelength records ??
« Reply #1 on: April 22, 2019, 09:31:17 PM »
Post complete code, and we'll show you where the bug is 8)

mikeburr

  • Member
  • **
  • Posts: 60
Re: HeapAlloc boundary issue with variablelength records ??
« Reply #2 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 

jj2007

  • Member
  • *****
  • Posts: 9462
  • Assembler is fun ;-)
    • MasmBasic
Re: HeapAlloc boundary issue with variablelength records ??
« Reply #3 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?

mikeburr

  • Member
  • **
  • Posts: 60
Re: HeapAlloc boundary issue with variablelength records ??
« Reply #4 on: April 23, 2019, 02:53:24 AM »
yep......thats why i asked

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 6331
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: HeapAlloc boundary issue with variablelength records ??
« Reply #5 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Tedd

  • Member
  • ***
  • Posts: 377
  • Procrastinor Extraordinaire
Re: HeapAlloc boundary issue with variablelength records ??
« Reply #6 on: April 25, 2019, 02:01:17 AM »
Post a working example so this 'bug' can be confirmed (or refuted.)
Potato2