#1 2024-08-08 08:18:32

htits2008
Member
Registered: 2015-03-25
Posts: 34

interface method return error 500

The system environment is Linux64, fpcdeluxe lazarus 3.99, The latest framework version .
In my interface method, I used try.. Except end structure, no exception was caught. At the end of the method, be able to log the correct SQL and return the rawjson value. But in HTTP calls, the result cannot be returned normally, instead it is a 500 error.
and EAccessViolation (dcbd5f40) [R1:orp] at 4327f0 orpDaemon.lpr  (535) ../../src/core/mormot.core.interfaces.pas  (6948)  is asm.

20240808 15472828  $  -    00.173.691
20240808 15472846  ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15472915  ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15472946  ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15473015  ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=0 free=1 client=0
20240808 15473161  $  +    mormot.rest.sqlite3.TRestServerDB(7fdee549b550).URI GET orp/ORP.listresPlan?aFields=ORPPlan&aresID=1557&aWhere=&session_signature=00085cbe0030f50dc8c151c4 in=0 B
20240808 15473161  $ call  	mormot.rest.sqlite3.TRestServerDB(7fdee549b550) ORP.listresPlan["ORPPlan",1557,"",false]
20240808 15473210  $ SQL   	mormot.rest.sqlite3.TRestServerDB(7fdee549b550) 182.20ms returned 4 rows as 1.9 KB select a.* ,resID from orpPlan a  left outer JOIN (select PID,ResID FROM ORPPlanSource where resID = 1557 ) b on b.PID=a.ID 
20240808 15473210  $ res   	mormot.db.raw.sqlite3.TSqlDatabase(7fdee5522a80) [{"ID":1,"typeCode":"","GUID":"","PID":"",... (truncated) length=1950
20240808 15473210  $  +    	
20240808 15473210  $ info  		[{"ID":1,"typeCode":"","GUID":"","PID":"",...] //result log , correct
20240808 15473210  $  -    	00.000.004
20240808 15473210  $ EXCOS 	EAccessViolation (dcbd5f40) [R1:orp] at 4327f0 orpDaemon.lpr  (535) ../../src/core/mormot.core.interfaces.pas  (6948) 
20240808 15473210  $ debug 	mormot.rest.sqlite3.TRestServerDB(7fdee549b550) TRestServerRoutingRest.Error: {  "errorCode":500,  "error":  {"EAccessViolation":  {   "ClassName": "EAccessViolation",   "Address": "7fdedcbd6400",   "Message": "Access violation"  }}  }
20240808 15473210  $ srvr  	  Interface GET orp/ORP.listresPlan=500 out=157 B in 182.55ms
20240808 15473210  $ ret   	mormot.rest.server.TRestServerRoutingRest(7fdedd052530) {  "errorCode":500,  "error":  {"EAccessViolation":  {   "ClassName": "EAccessViolation",   "Address": "7fdedcbd6400",   "Message": "Access violation"  }}  }
20240808 15473210  $  -    00.182.581
20240808 15473215  ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15473246  ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15473315  ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=1 free=0 client=0
20240808 15473346  ( trace mormot.net.async.THttpAsyncConnections(7fdee4439bd0) DoGC #1=0 #2=0 free=1 client=0

Offline

#2 2024-08-08 08:22:01

htits2008
Member
Registered: 2015-03-25
Posts: 34

Re: interface method return error 500

Only a few  interface methods runs wrong.  And  , the same  interface methods were compiled and run normally under the original Win10 and CodeTyphon 8.1.

Last edited by htits2008 (2024-08-08 08:25:55)

Offline

#3 2024-08-08 10:08:38

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

Re: interface method return error 500

There is something wrong on the server side: an EAccessViolation is raised in your service code.
Therefore, it returns an error 500.

You have to debug your code on the server side.
The exception is raised in your own code.
It is very likely that something is actually wrong, but works by chance on Win10 but fails on linux-x86_64.

Some ideas:
- Compile your project in -O1 mode to check the full stack trace (which is truncated here).
- Use the debugger on Lazarus / Linux to see where it actually fails.
- Check also the method parameters, and try to find if the faulty methods use some special kind of parameters.
- Run your project using either heaptrc or mormot memory manager, to track for memory issues.
- How to you generate the result log? It seems to fail just when returning from this logging method as sllInfo. There is some weird Enter/Leave with no method name at "15473210  $  +".

and don't forget to not put code or log content within the forum thread itself, as stated by our forum rules.

Offline

#4 2024-08-15 03:21:02

htits2008
Member
Registered: 2015-03-25
Posts: 34

Re: interface method return error 500

Thank you, AB
It's my mistake. In the method, I used codes。

Orm.ExecuteJson([], fsSQL,true, @fTotal  );  

The reason for this error is that fTotal requires int64, but I put it in integer.
Also shared with everyone.

Last edited by htits2008 (2024-08-15 03:21:22)

Offline

#5 2024-08-15 06:31:36

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

Re: interface method return error 500

You are right. It is confusing, and sometimes happens to me too. And the compiler should better behave.
I have enhanced the documentation to avoid confusion with such optional parameters.

- optional pointers should be treated as exact type by the compiler, at least about their size (32-bit or 64-bit) - just like "var" parameters
- but sadly the compiler (neither FPC nor Delphi) is rigourous about it
- to circumvent GPF or wrong value runtime issues, we added some explicit comments
https://github.com/synopse/mORMot2/comm … 8a1a7bR749

Offline

Board footer

Powered by FluxBB