#1 2013-05-22 18:15:41

Kobe
Member
Registered: 2013-04-08
Posts: 38

Acess Violation

Hello,

Using mormort with ORM, sometimes happens a AV when Updating a object, and sometimes happens a 'Invalid pointer operation'. I don't know exactly how to get more information to see better what is causing this errors.

procedure TSQLRecord.GetJSONValues(W: TJSONSerializer);
var i,n: integer;
label txt,txt1;
begin
  (.....)
      Fields.List[i].GetJSONValues(Self,W); // Looks Like the AV  happens here
      W.Add(',');
    end;
  W.CancelLastComma; // cancel last ','
  if W.Expand then
    W.Add('}');
end;

the class in question:

  TEmpresa = class(TSQLRecord)
(...)
  published
    property IdMatriz: Integer read FIdMatriz write FIdMatriz;
    property RazaoSocial: RawUTF8 read FRazaoSocial write FRazaoSocial;
    property NomeFantasia: RawUTF8 read FNomeFantasia write FNomeFantasia;
    property CNPJ: RawUTF8 read FCNPJ write FCNPJ;
    property InscricaoEstadual: RawUTF8 read FInscricaoEstadual write FInscricaoEstadual;
    property InscricaoMunicipal: RawUTF8 read FInscricaoMunicipal write FInscricaoMunicipal;
    property CEP: RawUTF8 read FCEP write FCEP;
    property Endereco: RawUTF8 read FEndereco write FEndereco;
    property EnderecoNum: RawUTF8 read FEnderecoNum write FEnderecoNum;
    property Complemento: RawUTF8 read FComplemento write FComplemento;
    property Bairro: RawUTF8 read FBairro write FBairro;
    property Cidade: RawUTF8 read FCidade write FCidade;
    property UF: RawUTF8 read FUF write FUF;
    property IBGECidade: Integer read FIBGECidade write FIBGECidade;
    property Telefone: RawUTF8 read FTelefone write FTelefone;
    property Fax: RawUTF8 read FFax write FFax;
    property Site: RawUTF8 read FSite write FSite;
    property Email: RawUTF8 read FEmail write FEmail;
    property Logo: TSQLRawBlob read FLogo write FLogo;
    property CNAE: RawUTF8 read FCNAE write FCNAE;
    property RegimeTributario: RawUTF8 read FRegimeTributario write FRegimeTributario;
    property Filial: Boolean read FFilial write FFilial;
    property Excluido: Boolean read FExcluido write FExcluido;
    property DataCadastro: TCreateTime read FDataCadastro write FDataCadastro;
    property DataAlteracao: TModTime read FDataAlteracao write FDataAlteracao;
    property IDUsuarioCadastro: Integer read FIDUsuarioCadastro write FIDUsuarioCadastro;
  end;

Offline

#2 2013-05-22 18:26:14

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

Re: Acess Violation

For which field?

Offline

#3 2013-05-22 18:46:30

Kobe
Member
Registered: 2013-04-08
Posts: 38

Re: Acess Violation

When the error happens the variable "i" has the value of 3, so I guess is the fourth field "CNPJ", that is a RawUTF8 type.

Is there any problems if the property value is null on the database?

Offline

#4 2013-05-22 20:16:19

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

Re: Acess Violation

Which version of delphi?
What is the content of Cnpj here?
Which db?
Which revision of mormot?

Offline

#5 2013-05-23 11:28:43

Kobe
Member
Registered: 2013-04-08
Posts: 38

Re: Acess Violation

Answering your questions:

- XE2.

- Mostly numbers, sometimes letters, something like: "1321321-54".

- SQLite.

- The last version that I did the test was this one:
http://synopse.info/fossil/info/be91367e37

I don't know if helps, but the variables values are:

i=3
n=4

colnames of the w = ('"IdMatriz":', '"RazaoSocial":', '"NomeFantasia":', '"CNPJ":', '"InscricaoEstadual":', '"InscricaoMunicipal":', '"CEP":', '"Endereco":', '"EnderecoNum":', '"Complemento":', '"Bairro":', '"Cidade":', '"UF":', '"IBGECidade":', '"Telefone":', '"Fax":', '"Site":', '"Email":', '"CNAE":', '"RegimeTributario":', '"Filial":', '"Excluido":', '"DataAlteracao":', '"IDUsuarioCadastro":');

Last edited by Kobe (2013-05-23 11:34:52)

Offline

#6 2013-05-23 11:36:06

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

Re: Acess Violation

I'm not able to reproduce the issue.

Where does the AV occur exactly (even at asm level)?

Is Fields.List[ i ]=nil or is it within GetJSONValues(Self,W) method process?

Offline

#7 2013-05-24 11:13:14

Kobe
Member
Registered: 2013-04-08
Posts: 38

Re: Acess Violation

I don't know what was causing this error, but I took off the property CNPJ from this class, and put in a ancestor class that I created just for that.

Now it's working fine, no errors.

That's weird!! yikes

Last edited by Kobe (2013-05-24 11:14:17)

Offline

Board footer

Powered by FluxBB