Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-09

(no subject)

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner

Hi all,

Question 1:
I have a nasty bug: an unknown function is overwriting some memory. The bug appears later in other functions (destroyed heap and objects). For example: the GetMem allocates memory which partly was never freed. To find the evil function I want to check the complete heap (allocated mem) from time to time to see when the error appears. I think the heaptrc unit can add marks at the head and the tail of each allocated mem and do some little checks every time memory is allocated/freed. But how can I check ALL structures (allocated+freed memory blocks) at once?

I set:

initialization
  HeapTrc.QuickTrace:=true;
  HeapTrc.HaltOnError:=true;
  HeapTrc.KeepReleased:=false;
  HeapTrc.add_tail:=true;
  HeapTrc.UseCRC:=true;
writeln('heap tracing ...');
end.
Question 2:
If I set 'KeepReleased:=true' I got a Segmentation fault right before the 'writeln' statement. Why that?

Mattias Gaertner

Jonas Maebe
to Mattias Gaertner
Mattias Gaertner wrote 9 lines
Question 1: I have a nasty bug: an unknown function is overwriting some memory. The bug appears later in other functions (destroyed heap and objects). For example: the GetMem allocates memory which partly was never freed. To find the evil function I want to check the complete heap (allocated mem) from time to time to see when the error appears. I think the heaptrc unit can add marks at the head and the tail of each allocated mem and do some little checks every time memory is allocated/freed. But how can I check ALL structures (allocated+freed memory blocks) at once?

I think that if you recompile the heaptrc unit with -dEXTRA, this will happen every time you allocate/release memory.

BTW: I don't know about your second question, but you should "quicktrace" to false if you want more thorough debugging

Jonas

Mattias Gaertner
to Jonas Maebe
Show quoted text 18 lines
On dinsdag, september 18, 2001, at 01:01 , Mattias Gaertner wrote: > Question 1: > I have a nasty bug: an unknown function is overwriting some memory. The > bug appears later in other functions (destroyed heap and objects). For > example: the GetMem allocates memory which partly was never freed. > To find the evil function I want to check the complete heap (allocated > mem) from time to time to see when the error appears. I think the > heaptrc unit can add marks at the head and the tail of each allocated > mem and do some little checks every time memory is allocated/freed. But > how can I check ALL structures (allocated+freed memory blocks) at once? I think that if you recompile the heaptrc unit with -dEXTRA, this will happen every time you allocate/release memory. BTW: I don't know about your second question, but you should "quicktrace" to false if you want more thorough debugging

Thx, it works.
But it is far too slow because I have millions of mem blocks and thus it is not useful for debugging. If I have a single function to check all allocated/freed mem blocks at once I could binary search the bug.

Somebody knows of such a function?

Mattias

Peter Vreman
Show quoted text 18 lines
> > Question 1: > > I have a nasty bug: an unknown function is overwriting some memory. The > > bug appears later in other functions (destroyed heap and objects). For > > example: the GetMem allocates memory which partly was never freed. > > To find the evil function I want to check the complete heap (allocated > > mem) from time to time to see when the error appears. I think the > > heaptrc unit can add marks at the head and the tail of each allocated > > mem and do some little checks every time memory is allocated/freed. But > > how can I check ALL structures (allocated+freed memory blocks) at once? > > I think that if you recompile the heaptrc unit with -dEXTRA, this will > happen every time you allocate/release memory. > > BTW: I don't know about your second question, but you should > "quicktrace" to false if you want more thorough debugging Thx, it works. But it is far too slow because I have millions of mem blocks and thus it is not useful

for
debugging.

If I have a single function to check all allocated/freed mem blocks at once I could

binary
search the bug.

Somebody knows of such a function?

There is none yet. I know that the heaptrc unit can use some extensions like:
- Trace only from a start to end instead of everything
- Checking if the heap is still correct every X getmem calls