StackTrace stops working with Win64 compile?

delphi package - automated exception handling
Post Reply
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

StackTrace stops working with Win64 compile?

Post by FredS »

Hi Mathias,

Code: Select all

  StackTrace(True, FALSE, FALSE, @stackArr);
Returns an empty array when project is recompiled in Win64.

What's the Trick?
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: StackTrace stops working with Win64 compile?

Post by madshi »

For stack tracing in x64 I'm using the OS APIs. Sometimes they fail, unfortunately, especially if you ask the call stack of your own thread. You can work around the issue by raising a dummy exception inside of a "try..except" block, and then in the except..end block call madExcept.GetCrashStackTrace. That usually works in both 32bit and 64bit. See for more information about GetCrashStackTrace:

http://help.madshi.net/madExceptUnit.ht ... StackTrace
FredS
Posts: 98
Joined: Mon May 11, 2015 9:42 pm

Re: StackTrace stops working with Win64 compile?

Post by FredS »

madshi wrote:Sometimes they fail, unfortunately, especially if you ask the call stack of your own thread. You can work around the issue by raising a dummy exception
I've been using this for detailed Log file entries without exceptions in Win32, are you saying this isn't working outside of raising an exception in Win64?
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: StackTrace stops working with Win64 compile?

Post by madshi »

I think it depends on the OS, but yes, on some OSs it won't work properly without raising a dummy exception. It's a "hidden" exception, though, because you catch it yourself in a try..except block. So while the debugger will stop and complain (which is annoying), at runtime it doesn't harm in any way. You could even check if you're running in a debugger and then skip the exception.
Post Reply