Re-raising a caught exception explicitly (i.e. passing the exception as an argument) causes a double free, as Delphi does not know that the re-raised exception is the original one and frees it at the end of the exception handler.
In these situations, a bare raise should be used. This correctly indicates that the
current exception should be re-raised.
Replace the raise X statement with a simple raise:
try
DoSomething;
except
on E: Exception do begin
Log.Debug('Exception message = ' + E.Message);
raise E;
end;
end;
try
DoSomething;
except
on E: Exception do begin
Log.Debug('Exception message = ' + E.Message);
raise;
end;
end;