Recent

Author Topic: Frustrating Error When using getmem to allocate memory and dare to ask  (Read 2721 times)

TYDQ

  • Full Member
  • ***
  • Posts: 176
Re: Frustrating Error When using getmem to allocate memory and dare to ask
« Reply #30 on: February 16, 2026, 02:49:15 pm »
If I take your sourcecode and put a break point on getmem , I get an exception at around line 2312 near a freemem. So before I get to the getmem.

And it is not the first time it passes by that line. I suspect the heap manager gets confused due to repeated freemems of random pointers.
Thanks to Rika in gitlab FPC,this problem is solved.

TYDQ

  • Full Member
  • ***
  • Posts: 176
Re: Frustrating Error When using getmem to allocate memory and dare to ask
« Reply #31 on: February 16, 2026, 02:50:02 pm »
If I take your sourcecode and put a break point on getmem , I get an exception at around line 2312 near a freemem. So before I get to the getmem.

And it is not the first time it passes by that line. I suspect the heap manager gets confused due to repeated freemems of random pointers.
Now that you mention it: Which Memory-Manager IS he using?
I think to remember, that using cmem AND HeapTrc at the same time leads to unexpected hiccups
Thanks to Rika in fpc gitlab,This problem is solved then.

jamie

  • Hero Member
  • *****
  • Posts: 7610
Re: Frustrating Error When using getmem to allocate memory and dare to ask
« Reply #32 on: February 18, 2026, 03:05:27 am »
I found something very interesting about the "assemply_string_To_Binary" which has many places that returns a Pointer.

Like
 Result.Content, which is a generic pointer that gets used back in the main code and where this is crashing btw.

Code: Pascal  [Select][+][-]
  1.          OperandEdit.Item8bit := Result.Content + (k - 1);  
  2.  
  3.  

 That is just an example of what I found.
 OperandEdit.Item8Bit is a Pbyte pointer, Result.Content is a generic pointer, (K is a index in the code - 1)
 
 This looks like translated code that went bad to me!

 Also, I found the compiler will allow this to compile and alters the Pointer value in Item8bit, basically does Pointer math on it.

 This code is peppered with miss deeds of pointer crashes, I can see how this can hammer the memory management!

 Did I miss something ?

 Jamie

The only true wisdom is knowing you know nothing

TYDQ

  • Full Member
  • ***
  • Posts: 176
Re: Frustrating Error When using getmem to allocate memory and dare to ask
« Reply #33 on: February 18, 2026, 08:24:52 am »
I found something very interesting about the "assemply_string_To_Binary" which has many places that returns a Pointer.

Like
 Result.Content, which is a generic pointer that gets used back in the main code and where this is crashing btw.

Code: Pascal  [Select][+][-]
  1.          OperandEdit.Item8bit := Result.Content + (k - 1);  
  2.  
  3.  

 That is just an example of what I found.
 OperandEdit.Item8Bit is a Pbyte pointer, Result.Content is a generic pointer, (K is a index in the code - 1)
 
 This looks like translated code that went bad to me!

 Also, I found the compiler will allow this to compile and alters the Pointer value in Item8bit, basically does Pointer math on it.

 This code is peppered with miss deeds of pointer crashes, I can see how this can hammer the memory management!

 Did I miss something ?

 Jamie
I send a no error unias pre-0.0.0 for you,you could look it up,due to the error really happens in between comment {Initially handle the file} and comment {Then Generate the Section Symbol}.

 

TinyPortal © 2005-2018