#1 2018-11-30 02:52:15

arvin
Member
Registered: 2017-08-31
Posts: 3

Database query error.

Hi ab,
I'm trying to use mORMot with SQL Server 2008,   get an error message after query the database multiple times.

code:

  ...
  fProps := TODBCConnectionProperties.Create('','DSN=LocalhostDB;UID=sa;PWD=123;APP=Enterprise;WSID=ARVIN-F;DATABASE=HIS;','',''); // The database link is correct
  Conn := fProps.ThreadSafeConnection;
  if not Conn.Connected then
    Conn.Connect;
  fServer := THttpApiServer.Create(false);
  fServer.AddUrl('root', '888', false, '+', true);
  fServer.RegisterCompress(CompressDeflate);
  fServer.OnRequest := Process;
  fServer.Clone(31);
  ...

function TJSONServer.Process(Ctxt: THttpServerRequest): cardinal;
begin
  try
    if length(Ctxt.InContent)<5 then
      raise ESynException.CreateUTF8('Invalid request % %',[Ctxt.Method,Ctxt.URL]);
    Ctxt.OutContentType := JSON_CONTENT_TYPE;
    Ctxt.OutContent := fProps.Execute(Ctxt.InContent,[]).FetchAllAsJSON(true);
    result := 200;
  except
    on E: Exception do begin
      Ctxt.OutContentType := TEXT_CONTENT_TYPE;
      Ctxt.OutContent := StringToUTF8(E.ClassName+': '+E.Message)+#13#10+Ctxt.InContent;
      result := 504;
    end;
  end;
end;

The Errormessage is this:   sad
EAccessViolation: Access violation at address 0045E5A1 in module 'JsonSQLServer.exe'. Read of address 02310000

mORMot code:

function UpperCopy255BufSSE42(dest: PAnsiChar; source: PUTF8Char; sourceLen: PtrInt): PAnsiChar;
asm // eax=dest edx=source ecx=sourceLen
       test    ecx,ecx
       jz      @z
       movdqu  xmm1, dqword ptr [@az]
       movdqu  xmm3, dqword ptr [@bits]
       cmp     ecx, 16
       ja      @big
       // optimize the common case of sourceLen<=16
       movdqu  xmm2, [edx]      [b]<<<<< an exception occurs[/b]
       
....

Offline

#2 2018-11-30 15:51:26

mpv
Member
From: Ukraine
Registered: 2012-03-24
Posts: 1,571
Website

Re: Database query error.

I can recommend to use a Samples/13-StandAlone JSON SQL server as a starting point.
Also you can remove fServer.Clone(31) from your code to test in the single thread

Offline

Board footer

Powered by FluxBB