Sign in Join

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

Mailing lists / fpc-devel / 2009-04

function StabBackTraceStr(addr:Pointer):shortstring; - problem with subsequent back traces

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

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

Bogusław Brandys

There is a problem with this function. To avoid recursion there is a hack there to point BackTraceStrFunc to system implementation (which only shows addresses in hex).Long back trace which mostly ends with incorrect frame address as I suppose (OpenStabs is returning false for nil address) - thus function pointer is not returned back to lineinfo stabs processing method and next back trace contains only addresses .

This problem is minor if program crashes with exception and stack trace but in other cases , like in bigger program (any Lazarus ones) , ONLY first back trace has useful information (source,line number) attached to it. That eliminates any useful logging like multilog for example. And nobody really is able to know correct stack frames length before calling any of such functions to obtain back trace (that would resolve problem).

How we could fix it ? Is this recursion still a subject here ?

I have one idea, probably not perfect.

How about  a function to initialize
  BackTraceStrFunc  : TBackTraceStrFunc;

The only way now is to set :

BackTraceStrFunc := @SysBackTraceStr; (displays only hex of addresses)

Something generic is needed, able to set to StabBackTraceStr if lineinfo unit (option -gl) is used and only to SysBackTraceStr in other case. It might be used also to set to user defined function.

That way in any such functions in lcl
(DumpExceptionBackTrace,GetStackTrace) or external package (like multilog), we could initialize BackTraceStrFunc to point again to correct function before obtaining stack trace.

Boguslaw Brandys

Reply by email