#1 2026-07-09 18:30:06

RObyDP
Member
Registered: 2015-02-19
Posts: 65

delphi13.1 with windows heap

Hi,

I tested the latest mORMot benchmark with Delphi 13.1 (64-bit). Everything works fine except for one function.

When using the Windows heap manager directly (for example, https://github.com/RDP1974/DelphiMSHeap), the following test:

`procedure TTestCoreBase.Utf8Slow(Context: TObject);`

raises memory-related exceptions, such as:

`UTF-8TDynArray: #2421041 EAccessViolation`

Feel free to check the code and let me know if you find anything relevant.

Thank you.
R.

just for talk, win2025 server desktop requires 1m40secs, same vm win 2025 core requires 1m05secs

Last edited by RObyDP (2026-07-09 20:12:52)

Offline

#2 Yesterday 09:43:43

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,536
Website

Re: delphi13.1 with windows heap

Neither the Delphi MM, nor the FPC MM, nor both in debug/extended mode do trigger such error.
It is very likely that something is missing in your DelphiMSHeap logic, like handling of a nil pointer or a size <= 0.

Offline

#3 Yesterday 11:07:10

RObyDP
Member
Registered: 2015-02-19
Posts: 65

Re: delphi13.1 with windows heap

Sorry to bother you.

I checked all integer values for zero or negative numbers, as well as all pointers for "nil", but nothing was reported.

In Debug mode everything works fine. In Release mode the issue is intermittent: sometimes no error is reported, but quite often this function raises an "EAccessViolation".

best regards

Offline

#4 Yesterday 13:45:24

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,536
Website

Re: delphi13.1 with windows heap

In my custom RTL for Delphi 7 I used something like this for the Win heap usage:
https://gist.github.com/synopse/d7f6307 … 62b317c93c

Anyway, we need more info about how it happens.

Offline

#5 Yesterday 21:20:33

RObyDP
Member
Registered: 2015-02-19
Posts: 65

Re: delphi13.1 with windows heap

Hi,
I hope this helps.

With tbbmalloc (https://github.com/RDP1974/Delphi64RTL) (both 32-bit and 64-bit), all tests pass 100%.

Using Microsoft Heap API (https://github.com/RDP1974/DelphiMSHeap), the 32-bit version also passes 100% of the tests. However, the 64-bit version consistently fails in one function with an EAccessViolation in UTF8 TDynArray.

Best regards.
R.

btw. win64 1m05s, win32 1m45s (tbbmalloc)

Last edited by RObyDP (Yesterday 21:27:16)

Offline

#6 Today 05:38:22

Chaa
Member
Registered: 2011-03-26
Posts: 264

Re: delphi13.1 with windows heap

Line that fails:
https://github.com/synopse/mORMot2/blob … .pas#L6906
i.e. if I comment this line, all tests are passed.

I think that on invalid UTF-8 sequence function StrPosIReference may read past of string, at line:
https://github.com/synopse/mORMot2/blob … pas#L12324
and can raise EAccessViolation.

Error message from console:
EAccessViolation for 29[<8L$c3$a3$c3$8f4QJX+7awvq/Z$c3$abco~S<V$c3$af]25

Offline

#7 Today 12:08:37

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,536
Website

Re: delphi13.1 with windows heap

Please try with
https://github.com/synopse/mORMot2/commit/ebf12e975
Such invalid UTF-8 sequence should be detected now.

But the test code should not generate invalid UTF-8. And in fact, the value displayed seems fine.
Perhaps the test code itself is wrong. wink

Offline

Board footer

Powered by FluxBB