View Issue Details

IDProjectCategoryView StatusLast Update
0032775FPCRTLpublic2020-07-14 03:26
ReporterKarl-Michael Schindler Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformdarwinOSMac OS X 
Product Version3.0.2 
Summary0032775: The combination of -gh and -gl does not give line number information
DescriptionI tried with 3.0.4 and trunk on macOS, with 3.0.0 on WindowsXP and 3.0.2 on linux, but i never got the line number information as stated in chapter 19.3 HeapTrc Usage of the rtl docs as well as chapter 10.7 of the user docs. I tried the example from the rtl docs, but only got this (on macOS):

michael% ./heaptr
Marked memory at $000000010FDEC660 invalid
Wrong size : 128 allocated 64 freed
Call trace for block $000000010FDEC660 size 128
Heap dump by heaptrc unit of./heaptr
12 memory blocks allocated : 1412/1416
6 memory blocks freed : 708/712
6 unfreed memory blocks : 704
True heap size : 360448 (32 used in System startup)
True free heap : 358688
Should be : 358944
Call trace for block $000000010FDEC660 size 128
Call trace for block $000000010FDEC540 size 128
Call trace for block $000000010FDEC420 size 128
Call trace for block $000000010FDEC300 size 128
Call trace for block $000000010FDEC1E0 size 128
Call trace for block $000000010FDEC0C0 size 128
michael%

Does anyone have a working example or is anyone aware of another trick, how to enable this?

MiSchi
Steps To Reproduce> fpc -gl -gh heaptr.pp
> ./heaptr
Additional Informationheaptr.pp:

program heapex;

var
  p1: ^longint;
  p2: pointer;
  i : longint ;
begin
  new(p1);
  dispose(p1);
  for i := 1 to 10 do
  begin
    GetMem(p2, 128);
    if (i mod 2) = 0 then
      FreeMem(p2, 128);
  end;
  GetMem(p2, 128);
  FreeMem(p2, 64);
end.
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

Jonas Maebe

2017-12-05 21:02

manager   ~0104477

-gl is only supported for Stabs on Darwin right now, which is only supported on 32 bit platforms and only the default on PowerPC. A Dwarf reader for Darwin needs to be created to have backtrace symbolication on the other platforms.

Karl-Michael Schindler

2017-12-05 22:23

reporter   ~0104485

Thanks for your extremely clarifying note. I am still confused, as I tried

ppc386 -gs -gl -gh heaptr.pp

on VirtualBox 32 bit Ubuntu with fpc 3.0.2+dfsg-2 and still do not get symbolication.

Jonas Maebe

2017-12-05 22:28

manager   ~0104486

On linux, both stabs and dwarf should work (bar bugs).

Karl-Michael Schindler

2017-12-05 23:19

reporter   ~0104489

It does not seem to work on linux, but a third party confirmation would be nice to exclude errors in my setup.

David

2017-12-28 08:19

reporter   ~0105063

The sample code has two problems, firstly, drop the -gs and secondly apparently heaptrc cannot report fully on leaks in the main procedure.

Here is a very simple demonstration of the problem. Compile with fpc -glh MyTest.pas It will report line numbers on Linux but not the Mac (carbon or cocoa).

program MyTest;
{$mode objfpc}{$H+}

procedure BadProcedure();
var
    Ptr : ^longint;
begin
    new(Ptr);
end;
   
begin
    BadProcedure();
end.

Here is a modified version or origional, compile with fpc -glh heaptr2.pp. Again, reports line numbers under Linux, not under Max OSX

program heaptr2;
{$mode objfpc}{$H+}

procedure Leak();
var
  p1: ^longint;
  p2: pointer;
  i : longint ;
begin
  new(p1);
  dispose(p1);
  for i := 1 to 10 do
  begin
    GetMem(p2, 128);
    if (i mod 2) = 0 then
      FreeMem(p2, 128);
  end;
  GetMem(p2, 128);
  FreeMem(p2, 64);
end;

begin
    Leak();
end.

Thaddy de Koning

2017-12-28 16:22

reporter   ~0105070

Last edited: 2017-12-28 16:23

View 3 revisions

Can this be related to my recent report about -Xs always (independent of release or debug) being turned on in a bog standard fpc.cfg? 0032831

If you strip code, lineinfo is gone of course......

I provided a patch some days ago.

David

2017-12-28 23:08

reporter   ~0105078

"...related to my recent report about -Xs..."
No Thaddy, my MacOSX test platform is the one built with much help from yourself and others so that it does not strip.

Karl-Michael Schindler

2017-12-28 23:22

reporter   ~0105079

I checked with verbose logging 3.0.4 on macOS 10.13.2 and to the best of my knowledge no stripping is done. No line numbers.

Marco van de Voort

2018-02-24 22:12

manager   ~0106597

I just tried with trunk, and that seems to work:

Call trace for block $00007FE31779A540 size 128
  $000000000041E93E GETMEM, line 284 of ../inc/heap.inc
  $0000000000400277 main, line 12 of atest.pp
  $000000000042BCF0 SYSENTRY, line 129 of system.pp
Call trace for block $00007FE31779A420 size 128
  $000000000041E93E GETMEM, line 284 of ../inc/heap.inc
  $0000000000400277 main, line 12 of atest.pp
  $000000000042BCF0 SYSENTRY, line 129 of system.pp

Karl-Michael Schindler

2018-02-25 15:21

reporter   ~0106615

So, I have done something wrong on linux, but the dwarf reader for Darwin remains.

Issue History

Date Modified Username Field Change
2017-12-05 16:15 Karl-Michael Schindler New Issue
2017-12-05 21:02 Jonas Maebe Note Added: 0104477
2017-12-05 22:23 Karl-Michael Schindler Note Added: 0104485
2017-12-05 22:28 Jonas Maebe Note Added: 0104486
2017-12-05 23:19 Karl-Michael Schindler Note Added: 0104489
2017-12-28 08:19 David Note Added: 0105063
2017-12-28 16:22 Thaddy de Koning Note Added: 0105070
2017-12-28 16:22 Thaddy de Koning Note Edited: 0105070 View Revisions
2017-12-28 16:23 Thaddy de Koning Note Edited: 0105070 View Revisions
2017-12-28 23:08 David Note Added: 0105078
2017-12-28 23:22 Karl-Michael Schindler Note Added: 0105079
2018-02-24 22:12 Marco van de Voort Note Added: 0106597
2018-02-25 15:21 Karl-Michael Schindler Note Added: 0106615