#1 2014-05-08 13:47:09

chapa
Member
Registered: 2012-04-30
Posts: 117

AV at mORMot.pas

Just updated the sources (was 2 months old).

Trying TServiceFactory.Get().Add(TObjectList) got:
Access violation at address 00000000009E139F in module '.exe'. Read of address FFFFFFFFFFFFFFFF

at mORMot.pas line 31130:
tkClass: begin
  Obj := pointer(GetOrdProp(Value,pointer(P)));  // works also for CPU64 <- AV here

It happens only on x64 build, 32bit works fine, and is due to something changed last few months (worked fine before source update).
Can debug further if needed.

Offline

#2 2014-05-08 13:49:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: AV at mORMot.pas

Have you some simple code to reproduce it?

We don't see this error on our side yet...

Offline

#3 2014-05-08 13:54:09

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: AV at mORMot.pas

Had to go out of the office now, tomorrow will isolate simple code, test data and figure out the problem, if still needed.

Offline

#4 2014-05-09 06:41:02

chapa
Member
Registered: 2012-04-30
Posts: 117

Re: AV at mORMot.pas

Multithreaded x64 debugging is so hard ... ide crashes at random

Anyway, trying to ObjectToJSON() an object, which contains TObjectList as a property.
The AV is on the next line 31130 at TJSONSerializer.WriteObject:

if (not TSQLRecord(Value).fFill.JoinedFields) and (P^.PropType^^.ClassSQLFieldType=sftID) then

here Value if of class TObjectList, recognized as Kind tkClass.
but why you try to cast this object as TSQLRecord and try to access a field of it (fFill in this case)? this definitely will lead to random AV ...

Simple fix works if compiler optimizations is turned on and exchange the if's AND statements like:

if (P^.PropType^^.ClassSQLFieldType=sftID) and (not TSQLRecord(Value).fFill.JoinedFields) then

At run-time first will be checked P^.PropType^^.ClassSQLFieldType which is sftUnknown and skip erroneous cast and go the else clause and finally return json without the AV

Hope my explanations are understandable and will help.

Offline

#5 2014-05-09 08:11:54

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,182
Website

Re: AV at mORMot.pas

Oups... this was just awful!
sad

Should be fixed by now.
See http://synopse.info/fossil/info/bebd8a2ce7

Thanks for the report.

Offline

Board footer

Powered by FluxBB