StackTrace() doesn't work in Win64?

delphi package - automated exception handling
Post Reply
Gerben Abbink
Posts: 3
Joined: Wed Apr 16, 2014 2:48 pm

StackTrace() doesn't work in Win64?

Post by Gerben Abbink »

Hi,

When i call StackTrace() in my Win64 application, i get:

00000000 ???

When i recompile the application in Win32 mode i get a normal strack trace (as a string).

What am i doing wrong? Should madExcept work under Win64?

- Gerben Abbink
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: StackTrace() doesn't work in Win64?

Post by madshi »

It seems that the APIs madExcept is using only properly work for crashes. You could work around the issue by doing this:

Code: Select all

try
  raise Exception.Create("dummy");
except
  strVar := GetCrashStackTrace();
end;
Not very nice, but it should work.
Gerben Abbink
Posts: 3
Joined: Wed Apr 16, 2014 2:48 pm

Re: StackTrace() doesn't work in Win64?

Post by Gerben Abbink »

Hi,

No, that doesn't work either.

Still only question marks.
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: StackTrace() doesn't work in Win64?

Post by madshi »

Just tried this with XE5 in Windows 8.1 x64:

Code: Select all

uses madExcept;

procedure TForm1.Button1Click(Sender: TObject);
begin
  try
    raise Exception.Create('dummy');
  except
    MessageBox(0, PWideChar(GetCrashStackTrace()), 'stack trace', 0);
  end;
end;
Works just fine here. Also tried this:

Code: Select all

uses madExcept;

procedure TForm1.Button1Click(Sender: TObject);
begin
  MessageBox(0, PWideChar(GetThreadStackTrace()), 'stack trace', 0);
end;
Surprisingly this works just fine, too. Some time ago this didn't work, which is why I suggested to raise a dummy exception. Not sure why it didn't work when I last tested it. Maybe it depends on the OS.

Is madExcept fully enabled for your project? Which Delphi version and which madExcept version are you using?
Gerben Abbink
Posts: 3
Joined: Wed Apr 16, 2014 2:48 pm

Re: StackTrace() doesn't work in Win64?

Post by Gerben Abbink »

I have made a very small demo (see attachment) with just a button and this code:

MessageBox(0, PWideChar(GetThreadStackTrace()), 'stack trace', 0);

I see no stack trace in Win64. I also tried:

try
raise Exception.Create('');
except
MessageBox(0, PWideChar(GetThreadStackTrace()), 'stack trace', 0);
end;

also, no stack trace. I does work in Win32.

Is use version MadExcept 4.0.9, Delphi XE5 on Windows 7 64-bit. I compile against MadExcept's source code that i bought.
Attachments
MadExcept64.rar
(57.92 KiB) Downloaded 250 times
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Re: StackTrace() doesn't work in Win64?

Post by madshi »

Sorry for the delay in replying.

That's strange, today GetThreadStackTrace() doesn't seem to work for me, either. When writing my last reply, it did work. But anyway, the reason why your sample project doesn't work is that you used GetThreadStackTrace() in that try..except block. My suggestion was to use GetCrashStackTrace() in the try..except block, and that does work for you in your sample project, too. It makes no sense to raise a dummy exception if you're not going to use GetCrashStackTrace() instead of GetThreadStackTrace().
Post Reply