Jump to content
PaulM117

64-bit debugger confirmed broken on 11.1 when using TypeInfo(T) for generic structs

Recommended Posts

My past posts here or elsewhere (can't remember) complained about the quality of Delphi 11.1 where I faced a constant onslaught of F2048 errors, compiler freezes, and a frustrating peculiarity where the 64-bit debugger simply would not work - breakpoints were blank as if release mode - when the 32bit worked fine, and a 64-bit empty project worked fine. I absolutely knew it was a legitimate Delphi 11.1 bug and not my fault of configuration, and I even had now-proven-true inklings it related to usage of modern language features.

 

It got so horrible with Delphi, having to do a full rebuild of source for even the smallest source edits or else face an IDE hang, that I had to restart my project (2014--2023 codebase) from scratch and start rebuilding from square one.

 

The 64-bit debugger worked fine on the empty project, so I knew I would find the culprit eventually.

 

I have now isolated two code snippets that repeatably determine whether the 64-bit debugger is nuked. It's from merely including the otherwise very useful TypeInfo() compile-time special magic object. Please let me know if a workaround for this because Delphi truly and sadly lacks C++'s compile-time and static polymorphism/record type initialization features, and TypeInfo() was the closest one could get.

 

The following code causes Delphi 11.1 to have a completely dysfunctional Win64 debugger:

procedure TStackListWordMaxLength<T>.Erase(const N: Word);
begin
  const Pos = N*NumFields;
  const WriteAddr: NativeInt = NativeInt(Data)+SizeOf(T)*Pos;
  if TypeInfo(T) = TypeInfo(Byte) then PByte(WriteAddr)^ := FreeElement
  else if TypeInfo(T) = TypeInfo(Word) then PWord(WriteAddr)^ := FreeElement
  else if TypeInfo(T) = TypeInfo(Integer) then PInteger(WriteAddr)^ := FreeElement;
  FreeElement := N;
end;

 

The following identical code with mere 3 lines commented-out (i.e., made completely dysfunctional) restores the 64-bit debugger to normalcy:

 

procedure TStackListWordMaxLength<T>.Erase(const N: Word);
begin
  const Pos = N*NumFields;
  const WriteAddr: NativeInt = NativeInt(Data)+SizeOf(T)*Pos;
  //if TypeInfo(T) = TypeInfo(Byte) then PByte(WriteAddr)^ := FreeElement
  .//else if TypeInfo(T) = TypeInfo(Word) then PWord(WriteAddr)^ := FreeElement
  //else if TypeInfo(T) = TypeInfo(Integer) then PInteger(WriteAddr)^ := FreeElement;
  FreeElement := N;
end;

 

Nobody ever mentioned this bug as far as I've seen. Is it previously known? How else am I supposed to implement a generic stack-memory-allocating-first list of various ordinal size, without manually copying different versions of a non-generic struct, and also have a working Win64 debugger?

Edited by PaulM117

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×