GetCrashStackTrace/GetThreadStacktrace do not work in x64

delphi package - automated exception handling
Post Reply
car_hack89
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

GetCrashStackTrace/GetThreadStacktrace do not work in x64

Post by car_hack89 »

Hello,

The functions "madExcept.GetCrashStackTrace()" and "madExcept.GetThreadStacktrace()" do not return the callstack, return empty string.

My application is 64 bits, written in Delphi and developed in XE7. I am using the MadExcep 4.0.19 (Single Developer Edition).

If the application generates it in 32 bits, the functions work correctly returning the callstack.

Thanks in advance.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: GetCrashStackTrace/GetThreadStacktrace do not work in x6

Post by madshi »

Two questions:

1) GetCrashStackTrace() is only supposed to be called from within a try..except block. Is that how you've called it in x64?
2) Do you have madExcept fully enabled (in the "madExcept settings..." dialog) and compiled the EXE within the IDE?

GetThreadStacktrace() is problematic in x64, that's a known problem. I'm calling OS APIs in this case, and they don't seem to work well, for some reason I can't manage to figure out. You can workaround it by raising a dummy exception in a try..except block like this:

Code: Select all

try
  raise Exception.Create('dummy');
except
  currentThreadStackTrace := GetCrashStackTrace();
end;
car_hack89
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Re: GetCrashStackTrace/GetThreadStacktrace do not work in x6

Post by car_hack89 »

Hello,
1) GetCrashStackTrace() is only supposed to be called from within a try..except block. Is that how you've called it in x64?
GetCrashStackTrace/GetThreadStacktrace uses them without try..except, and in both x86 and x64 the code is the same.
2) Do you have madExcept fully enabled (in the "madExcept settings..." dialog) and compiled the EXE within the IDE?
I have full enabled madExcept, and my application compiled it with the IDE.

And yes for the moment I solved it with a fictitious exception:

Code: Select all

try
    raise Exception.Create ('Some error message');
except on E: Exception do
    sCurrentStackTrace: = E.StackTrace;
end;
This solution is not optimal, so I asked if there was any way.
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: GetCrashStackTrace/GetThreadStacktrace do not work in x6

Post by madshi »

Not atm.
Post Reply