Recent

Author Topic: Heaptrc shows a line that does not exist  (Read 3616 times)

simone

  • Hero Member
  • *****
  • Posts: 573
Heaptrc shows a line that does not exist
« on: October 15, 2018, 06:20:32 pm »
Dear all, I have a strange problem with Heaptrc, that shows a line that does not exist (i.e. the line number is greater than the number of lines in my unit)

How is it possible? is there a possible explanation? Thanks in advance.
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: Heaptrc shows a line that does not exist
« Reply #1 on: October 16, 2018, 09:05:55 am »
If the program is linked against libraries that do not contain line info. (like the rtl and provided packages)
If you are sure you do not use external - meaning non-native pascal - libraries, you can build the rtl and packages with lineinfo.
Specialize a type, not a var.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Heaptrc shows a line that does not exist
« Reply #2 on: October 16, 2018, 12:12:00 pm »
Seems strange...

You don't by any change use external debug info, and have an old outdated debug info file (*.dbg) around?

You should also have the address? then you can try and use gdb, to map the address to line info. Maybe that gets a better result?

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Heaptrc shows a line that does not exist
« Reply #3 on: October 16, 2018, 03:37:06 pm »
Thanks to all. I don't use external library. 

I'm working on Windows with Lazarus 1.8.4+FPC 3.0.4. The problem
arises with Lazarus for 64bits. Using the same version for 32 bits the heap
trace is correct and thus I have been able to find the leak.

 
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: Heaptrc shows a line that does not exist
« Reply #4 on: October 16, 2018, 04:19:10 pm »
That is strange. Can you share what it was?
Specialize a type, not a var.

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Heaptrc shows a line that does not exist
« Reply #5 on: October 16, 2018, 04:53:09 pm »
The problem arises in a personal medium-sized project. I will try ro reproduce it in a smaller piece of code.

For now I can show the trace, although I think it is useless for a diagnosis (see attached heap.trc).
(UGraphData.pas unit has n. 545 lines. In the trace appear lines n. 959, 997).

I'm really grateful for the support.
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Heaptrc shows a line that does not exist
« Reply #6 on: October 16, 2018, 07:29:04 pm »
Well load the app in question in gdb

Code: Pascal  [Select][+][-]
  1. gdb yourapp.exe
then
Code: Pascal  [Select][+][-]
  1. info line *0x012345678
with whatever address is on the bad line.

You can also try to use dwarf vs stabs as symbol info type (project options / debugging // but also for each package)

There are various things that can be wrong.
- the actual line info written by fpc to your app
- the line info reader that fpc adds to your app (unit lineinfo (stabs) or  lnfodwrf (dwarf))

there are tools like objdump that may be able to decompile the line info, if you want to go that way.

For a bug report, it would be real important to know where the error is. (And also if released/older fpc has the problem too)

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Heaptrc shows a line that does not exist
« Reply #7 on: October 16, 2018, 07:34:18 pm »
Dear all, I have been able to isolate the problem of heap trace in a smaller piece of code.
(see attached zip).

In the file heap.trc the line 959 of UGraphData.pas does not exist.

PS: The attached code has no meaning. It is the result of successive eliminations
starting from the original one, for the sole purpose of reproducing the problem.
I hope this can be useful.
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Akira1364

  • Hero Member
  • *****
  • Posts: 561
Re: Heaptrc shows a line that does not exist
« Reply #8 on: October 19, 2018, 06:49:19 am »
Something's up with your FPC installation, I think. Building your program with native-64-bit trunk FPC on Windows 10 gives me this:

Code: Pascal  [Select][+][-]
  1. 78 memory blocks allocated : 3372/3584
  2. 77 memory blocks freed     : 3324/3536
  3. 1 unfreed memory blocks : 48
  4. True heap size : 229376 (160 used in System startup)
  5. True free heap : 228960
  6. Should be : 228976
  7. Call trace for block $0000000000101390 size 48
  8.   $000000010000B972
  9.   $00000001000090AA
  10.   $0000000100031C5D  CREATE,  line 1009 of fgl.pp
  11.   $0000000100031D95  CREATE,  line 27 of Ugenerator.pas
  12.   $0000000100001B61  COMPILE,  line 82 of MyGraphCompiler.lpr
  13.   $00000001000018C1  DORUN,  line 57 of MyGraphCompiler.lpr
  14.   $0000000100030DB5
  15.   $0000000100001C19  main,  line 92 of MyGraphCompiler.lpr
  16.   $0000000100001C46
  17.   $0000000100010B60
  18.   $0000000100001740
  19.   $00007FFA3BE88102
  20.   $00007FFA3C6AC5B4

which appears to be the correct output.
« Last Edit: October 19, 2018, 06:52:00 am by Akira1364 »

simone

  • Hero Member
  • *****
  • Posts: 573
Re: Heaptrc shows a line that does not exist
« Reply #9 on: October 19, 2018, 08:04:50 am »
Thanks Akira. The problem appears with Lazarus 1.8.4+FPC 3.0.4 32 bits on Windows 7. I will reinstall Lazarus to see what happens.
Microsoft Windows 10 64 bit - Lazarus 3.0 FPC 3.2.2 x86_64-win64-win32/win64

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9791
  • Debugger - SynEdit - and more
    • wiki
Re: Heaptrc shows a line that does not exist
« Reply #10 on: October 22, 2018, 01:20:33 am »
I had a quick look at it. Line 959 is actually in fgl.
But because you specialize the generic in UGraphData, it is incorrectly placed in that unit. (I can reproduce with 3.0.2 and 3.0.4)

I tested with trunk, and with 3.2-beta: Both of them correctly report the line in fgl. So the issue is fixed in upcoming code.

Until then, check any specialized generic.

 

TinyPortal © 2005-2018