andremussche / scalemm

Fast scaling memory manager for Delphi
https://code.google.com/p/scalemm/
Other
98 stars 22 forks source link

ScaleMM2 fails on MS application verifier TLS-test (Win32) #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Testing a simple empty application with ScaleMM2 fails with MS application 
verifier. 
MS application verifier is important for Windows compability check and logo 
program.

Failure message is:

VERIFIER STOP 0000000000000013: pid 0x4D0: first chance access violation for 
current stack trace 

    000000007F688CF8 : Invalid address being accessed
    00000000004120AC : Code performing invalid access
    000000000008E9F0 : Exception record. Use .exr to display it.
    000000000008E500 : Context record. Use .cxr to display it.

program fails on line in ScalemMM2.pas:

function GetThreadMemManager: PThreadMemManager;
asm
{$IFDEF SCALE_INJECT_OFFSET}
  mov eax,123456789        // dummy value: calc once and inject at runtime
{$ELSE}
  mov eax,GOwnTlsOffset    // 2% slower, so we default use injected offset
{$ENDIF}
  mov ecx,fs:[$00000018]
  mov eax,[ecx+eax]      // +++ Fails here +++
  or eax,eax
  jz CreateMemoryManager
end;

Steps to reproduce:

Create empty Win32 Delphi application. Insert ScaleMM2 in first line of dpr.
Add program in Application verifier and choose basic tests (TLS test seems to 
be the test which fails) See screen shots

Best regards
Dirk

Original issue reported on code.google.com by dirk.car...@gmail.com on 8 Dec 2014 at 9:08

Attachments:

GoogleCodeExporter commented 9 years ago
What if you undefine "SCALE_INJECT_OFFSET" so it uses the normal TLS 
determination?

Original comment by andre.mussche on 8 Dec 2014 at 2:06

GoogleCodeExporter commented 9 years ago
Hi Andre,
Compile without "SCALE_INJECT_OFFSET" doesn't help. See screenshot. 

Best regards
Dirk

Original comment by dirk.car...@gmail.com on 8 Dec 2014 at 2:19

Attachments:

GoogleCodeExporter commented 9 years ago
And if you use the define "PURE_PASCAL"? (I have used 2 low level assembly 
tricks to make it faster, pure_pascal should be the normal delphi way)

Original comment by andre.mussche on 8 Dec 2014 at 2:33

GoogleCodeExporter commented 9 years ago
Hi Andre,

yes with "PURE_PASCAL" defined the exception does not occour. Only few warnings 
(see screenshot).

Does "PURE_PASCAL" makes the memory manager slower? I would use ScaleMM2 
because it does scaler a lot better than FastMM4. But MS application verifier 
should be fine also.. Any suggestions?

Best regards
Dirk

Original comment by dirk.car...@gmail.com on 8 Dec 2014 at 2:45

Attachments:

GoogleCodeExporter commented 9 years ago
for the warnings you can use/include the unit ScaleMM2 in smmSmallMemory.pas 
too, then the compiler warning will go away.

Pure pascal is 2% slower (maybe more) in very tight loops, but you will 
probably not detect it in normal situations.

Thanks for testing!

Original comment by andre.mussche on 8 Dec 2014 at 2:57

GoogleCodeExporter commented 9 years ago
Andre, thanks & best regards
Dirk

Original comment by dirk.car...@gmail.com on 8 Dec 2014 at 3:06