#1 2016-09-18 11:37:05

jaclas
Member
Registered: 2014-09-12
Posts: 215

SynCommon except on initialize application

I use SynCrypto unit, it works ok. But when I enabled MadExcept to trace some memory leaks then Application raise AV on start, see callstack:

date/time          : 2016-09-18, 13:30:43, 480ms
operating system   : Windows 10 x64 build 14393
system language    : Polish
system up time     : 3 hours 15 minutes
program up time    : 575 milliseconds
processors         : 8x Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
physical memory    : 8647/16323 MB (free/total)
free disk space    : (C:) 315,53 GB (D:) 222,00 GB
display mode       : 1920x1200, 32 bit
process id         : $2a48
allocated memory   : 240,97 MB
largest free block : 769,83 MB
executable         : JPKSender.exe
exec. date/time    : 2016-09-18 13:30
version            : 1.0.0.0
compiled with      : Delphi 10.1 Berlin
madExcept version  : 4.0.15
callstack crc      : $3a9974cc, $a6b50739, $a6b50739
exception number   : 1
exception class    : EAccessViolation
exception message  : Access violation at address 00864ABC in module 'JPKSender.exe'. Read of address 0A1C3000.

main thread ($33a8):
00864abc +008 JPKSender.exe SynCommons 23250  +5 StrCompSSE42
00868899 +031 JPKSender.exe SynCommons 32958  +5 FastFindPUTF8CharSorted
0086bdb0 +02c JPKSender.exe SynCommons 36327  +3 TJSONCustomParserRTTI.TypeNameToSimpleRTTIType
0086de39 +045 JPKSender.exe SynCommons 37008  +2 GetNextFieldType
0086dfe1 +145 JPKSender.exe SynCommons 37047 +29 TJSONRecordTextDefinition.Parse
0086dca0 +090 JPKSender.exe SynCommons 36991  +7 TJSONRecordTextDefinition.Create
0086dbec +070 JPKSender.exe SynCommons 36976  +8 TJSONRecordTextDefinition.FromCache
0086aff2 +06e JPKSender.exe SynCommons 35937  +6 TJSONCustomParsers.RegisterFromText
0087e37a +01a JPKSender.exe SynCommons 45053  +1 TTextWriter.RegisterCustomJSONSerializerFromText
00bdc438 +08c JPKSender.exe SynCommons 59135 +25 initialization
0040a186 +042 JPKSender.exe System     22279 +18 InitUnits
0040a1ef +03f JPKSender.exe System     22351 +14 @StartExe
004119a2 +042 JPKSender.exe SysInit     1419 +11 @InitExe
00bddf73 +00b JPKSender.exe JPKSender     58  +0 initialization
740862c2 +022 KERNEL32.DLL                       BaseThreadInitThunk

thread $2530:
740862c2 +22 KERNEL32.DLL  BaseThreadInitThunk

thread $18f0:
740862c2 +22 KERNEL32.DLL  BaseThreadInitThunk


cpu registers:
eax = f66a8cc0
ebx = 00000000
ecx = 0a1c2ff8
edx = 0a1c2ff8
esi = 00bdc3ac
edi = 000001f6
eip = 00864abc
esp = 0019fd54
ebp = 0019fd70

stack dump:
0019fd54  9f 88 86 00 59 57 86 00 - 00 00 00 00 0f 00 00 00  ....YW..........
0019fd64  f8 2f 1c 0a 1f 00 00 00 - 70 b9 be 00 8c fd 19 00  ./......p.......
0019fd74  b5 bd 86 00 e9 fd 00 00 - 06 70 88 00 06 00 00 00  .........p......
0019fd84  f8 2f 1c 0a 98 68 85 00 - b0 fd 19 00 3e de 86 00  ./...h......>...
0019fd94  0c fe 19 00 1e 29 86 00 - e9 fd 00 00 06 00 00 00  .....)..........
0019fda4  e8 c4 bd 00 0c fe 19 00 - 80 fe 19 00 34 fe 19 00  ............4...
0019fdb4  e6 df 86 00 34 fe 19 00 - 40 fe 19 00 24 9d 40 00  ....4...@...$.@.
0019fdc4  34 fe 19 00 bc b9 85 00 - 0c fe 19 00 cd 6f 40 00  4............o@.
0019fdd4  e8 fd 19 00 43 d1 40 00 - dc cf 1c 0a 04 00 00 00  ....C.@.........
0019fde4  e8 0f 1d 0a e8 8f 1c 0a - f0 8f 1c 0a 00 00 00 00  ................
0019fdf4  1c fe 19 00 00 00 00 00 - 28 a7 40 00 01 00 00 00  ........(.@.....
0019fe04  20 d3 4f 00 00 00 00 00 - 00 00 00 00 e6 d1 0c 00   .O.............
0019fe14  1c fe 19 00 e7 31 52 00 - be eb 58 00 00 00 00 00  .....1R...X.....
0019fe24  00 00 00 00 80 fe 19 00 - dc cf 1c 0a e8 2f 1d 0a  ............./..
0019fe34  90 fe 19 00 a5 dc 86 00 - 00 00 00 00 c0 fe 19 00  ................
0019fe44  03 9f 40 00 90 fe 19 00 - e8 2f 1d 0a 90 fe 19 00  ..@....../......
0019fe54  e6 d1 40 00 60 fe 19 00 - ed 6b 88 00 40 00 00 00  ..@.`....k..@...
0019fe64  40 00 00 00 00 8f 1d 0a - 40 00 00 00 00 00 00 00  @.......@.......
0019fe74  dc cf 1c 0a e8 0f 1d 0a - f6 01 00 01 f4 c4 bd 00  ................
0019fe84  f0 50 85 00 e8 c4 bd 01 - e8 2f 1d 0a b8 fe 19 00  .P......./......

Offline

#2 2016-09-18 21:16:46

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,503
Website

Re: SynCommon except on initialize application

Not enough information to reproduce it...

Offline

#3 2016-09-19 08:15:44

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: SynCommon except on initialize application

How can I help?

Screenshot before raised exception:
JpQe34ZF.png

Last edited by jaclas (2016-09-19 08:15:58)

Offline

#4 2016-09-19 17:54:04

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,503
Website

Re: SynCommon except on initialize application

Which version of Delphi?
Which build of the framework?  (from SynopseCommit.inc - current is 2966).

Offline

#5 2016-09-19 18:11:08

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: SynCommon except on initialize application

Delphi version from MadExcept report: Delphi 10.1 Berlin
Framework up to date.

Offline

#6 2016-09-20 15:39:10

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,503
Website

Re: SynCommon except on initialize application

I'm not able to reproduce this issue...

Offline

#7 2016-09-20 19:14:59

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: SynCommon except on initialize application

I search for except reason and.. I found. MadExcept cause this when option "Instantly crash on buffer overrun" is checked.

9VfKT9hE.png

Offline

#8 2016-09-20 19:25:34

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,503
Website

Re: SynCommon except on initialize application

As stated by the doc, sse42 fast strcmp may READ some bytes after the end of the string.
Reading is imho perfectly safe.
This option is paranoid.

Offline

#9 2016-09-20 20:55:02

jaclas
Member
Registered: 2014-09-12
Posts: 215

Re: SynCommon except on initialize application

Maybe paranoid, but useful when tracing mem leaks :-)
Thx for info about SSE 42.

Offline

#10 2016-09-20 21:53:27

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,503
Website

Re: SynCommon except on initialize application

I rather rely on Fastmm4 for this, in full debug mode of course...

Offline

#11 2017-12-29 03:18:37

rossmcm
Member
Registered: 2012-09-19
Posts: 9

Re: SynCommon except on initialize application

I can report this issue is also present with Delphi 2007, running Win10 x64 (and build 1.18.2194, not current).  Same conditions, i.e. MadExcept enabled, crash on buffer overrun enabled.

Dekhi 2007 Stack trace

Actually @Ab, I'm not sure I agree that the reading outside of a buffer is necessarily safe - the actual read is safe - i.e. it can't clobber memory like a write will - but the user might still like to know that they have read outside of a buffer, especially if they are planning on using the data they have read.

Maybe a conditional that would compile a (slower) version of SynCommons.StrCompSSE42 that was compatible with MadExcept?

Last edited by rossmcm (2017-12-29 10:15:50)

Offline

#12 2017-12-29 11:15:54

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 13,503
Website

Re: SynCommon except on initialize application

"especially if they are planning on using the data they have read" does not make any sense to me in this context, since the data is read but not used by the StrCompSSE42 function (it breaks using it at first encountered #0 char).

Anyway, main idea is - as documented - is to explicitly call StrCompFast (or StrLenPas) when you want to ensure that there is no read buffer overflow.

You can always write in the initialization section of one unit of your project:

    StrComp := @StrCompFast;

This will disable the StrCompSSE42 use for the whole project.

Offline

Board footer

Powered by FluxBB