You are not logged in.
Pages: 1
I get this error when I run the testprogram and even this short program gets the same error:
program SizeCheck;
{$APPTYPE CONSOLE}
uses
Windows,
mormot.core.os,
mormot.core.datetime;
begin
Writeln('SizeOf(TRWLightLock) = ', SizeOf(TRWLightLock));
Writeln('SizeOf(Windows.TSystemTime) = ', SizeOf(Windows.TSystemTime));
Writeln('SizeOf(mormot.core.os.TSystemTime) = ', SizeOf(mormot.core.os.TSystemTime));
Readln;
end.Project SizeCheck.exe raised exception class EAssertionFailed with message 'Assertion failure (e:\devlib\mormot2\src\core\mormot.core.datetime.pas, line 4561)'.
Tested with both Delphi 12.2 and Delphi13.
The code that breakes is:
assert(SizeOf(GlobalTime) = 128); and sits in the initializeUnit procedure.
If I check what "SizeOf(GlobalTime)" reports I get: 120.
I also made a program that just took the declaration of "GlobalTime" from mormot.core.datetime and checked the size and I got 128.
Where are the size changed?
Last edited by larand54 (Yesterday 07:52:11)
Delphi-11, WIN10 and Win11
Offline
It worked ok here, on Delphi 13.1, and the latest mORMot 2: 4, 16, 16 were the results
Last edited by Prometeus (2026-08-30 22:26:16)
Offline
I also tested a program that not use mormot which worked and produced the following result:
USERECORDWITHMETHODS is NOT defined
SizeOf(TRWLightLockTest) = 4 (förväntat: 4)
SizeOf(Windows.TSystemTime) = 16 (förväntat: 16)The program looks like this:
program IsolatedSizeTest;
{$APPTYPE CONSOLE}
uses
Windows;
type
{$ifdef USERECORDWITHMETHODS}
TRWLightLockTest = record
{$else}
TRWLightLockTest = object
{$endif}
private
Flags: cardinal;
public
procedure Init;
end;
procedure TRWLightLockTest.Init;
begin
Flags := 0;
end;
begin
{$ifdef USERECORDWITHMETHODS}
Writeln('USERECORDWITHMETHODS is DEFINED');
{$else}
Writeln('USERECORDWITHMETHODS is NOT defined');
{$endif}
Writeln('SizeOf(TRWLightLockTest) = ', SizeOf(TRWLightLockTest), ' (förväntat: 4)');
Writeln('SizeOf(Windows.TSystemTime) = ', SizeOf(Windows.TSystemTime), ' (förväntat: 16)');
Readln;
end.Last edited by larand54 (Yesterday 06:58:55)
Delphi-11, WIN10 and Win11
Offline
on delphi 12.3 and win11, your first SizeCheck program returns and no exception triggered.
SizeOf(TRWLightLock) = 4
SizeOf(Windows.TSystemTime) = 16
SizeOf(mormot.core.os.TSystemTime) = 16Offline
I hardcoded a part of the "GlobalTime" declaration and the the error dissappear:
var
// GlobalTime[LocalTime] thread-safe cache, each one taking one L1 cache line
GlobalTime: array[boolean] of packed record
safe: TRWLightLock;
clock: cardinal; // avoid slower API call with 16ms loss of precision
time: TSystemTime;
// _pad: array[1 .. 64 - SizeOf(TLightLock) - SizeOf(TSystemTime) - 4] of byte;
_pad: array[1 .. 64 - 4 - 16 - 4] of Byte;
end;Delphi-11, WIN10 and Win11
Offline
Ooh! Now I see whats wrong or at least whats cause it is. GlobalTime has safe declared as TRWLightLock, wich size is 4, but the calculation of _pad size uses TLightLock wich size is 8.
Therefore the size of GlobalTime will be 120 and not 128 as the assertion use.
Whats wrong, TRWLightLock or TLightLock I don't know but at least it should be one of them . No matter which one you choose, just they are the same.
So... this should be a bug or ?
Delphi-11, WIN10 and Win11
Offline
I don't understand. I guess I did fix it with https://github.com/synopse/mORMot2/commit/68c567e395f
Currently
GlobalTime: array[boolean] of packed record
safe: TRWLightLock;
clock: cardinal; // avoid slower API call with 16ms loss of precision
time: TSystemTime;
_pad: array[1 .. 64 - SizeOf(TRWLightLock) - SizeOf(TSystemTime) - 4] of byte;
end;seems correct to me?
Offline
Yes, you did. I pulled the latest some minutes later after my discovery and found that the correction was already done.
I try to run the mormot2Test program but I'm getting error again but I don't think it's mormot who cause it.
In mormot.net.ldap i Get this: [dcc64 Error] Project1.dpr(6): E2008 Incompatible types
at:
type
/// define only one part of a Distinguished Name content e.g. for DNToCN()
TNormalizeDN = set of (dnCN, dnOU, dnDC);
const
/// define all parts of a Distinguished Name content
DN_ALL = [low(TNormalizeDN) .. high(TNormalizeDN)];I tested a short program and got the same error.
program LowHighSetTest;
{$APPTYPE CONSOLE}
type
TTestSet = set of (aX, aY, aZ);
const
ALL_TEST: TTestSet = [low(TTestSet) .. high(TTestSet)];
begin
Writeln('Compiled OK, count = ', Ord(high(TTestSet)) - Ord(low(TTestSet)) + 1);
Readln;
end.Any idea?
Delphi-11, WIN10 and Win11
Offline
Ah... FPC had no problem with this syntax.
Delphi can't understand it.
Please try with
https://github.com/synopse/mORMot2/commit/63b43ba0a
Offline
Worked with 64 bit but not with 32bit.
First chance exception at $7665A2B4. Exception class EHttpMultiPart with message 'THttpMultiPartDecoderStream.Read: malformed or truncated multipart content'. Process mormot2tests.exe (29744)
function THttpMultiPartDecoderStream.Read(var Buffer; Count: Longint): Longint;
begin
result := fOwner.PartRead(Buffer, Count);
if result > 0 then
begin
inc(fPosition, result);
inc(fSize, result); // Size = content length seen so far
end
else if fOwner.fState = mpdsError then
// never mistake a truncated section for a complete one
EHttpMultiPart.RaiseUtf8(
'%.Read: malformed or truncated multipart content', [self]);
end;Not my day today ![]()
Delphi-11, WIN10 and Win11
Offline
Well the test run without error just that it stopped at all thrown exception. I must have some settings wrong or..?
Delphi-11, WIN10 and Win11
Offline
Pages: 1