Recent

Author Topic: Application sometimes crashes when I using filter on SQLQuery  (Read 1123 times)

Milsa

  • Sr. Member
  • ****
  • Posts: 309
Application sometimes crashes when I using filter on SQLQuery
« on: February 03, 2020, 11:42:40 am »
I am using ServerFiltered property with parameters on SQL. Application crashes SOMETIME no always. If application does not crashes then heap is correct unallocated. If it crashes, I have this log. It is problem for bug tracker or?

Please help me with this.
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Application sometimes crashes when I using filter on SQLQuery
« Reply #1 on: February 03, 2020, 11:45:55 am »
If it crashes, I have this log. It is problem for bug tracker or?
The stacktrace isn't really useful at this moment. It only means you didn't catch an exception and a lot of things didn't get freed because of it.

Maybe you can show the code where you set the ServerFiltered and put correct exception handling around it (so it will provide a useful message).

Code: Pascal  [Select][+][-]
  1. try
  2.   // do your thing
  3. except
  4.   on E: Exception do
  5.     Showmessage(E.Message);
  6. end;


Milsa

  • Sr. Member
  • ****
  • Posts: 309
Re: Application sometimes crashes when I using filter on SQLQuery
« Reply #2 on: February 20, 2020, 07:27:08 am »
I have active exception handler for stack trace:
Code: Pascal  [Select][+][-]
  1. procedure TFormMain.CustomExceptionHandler(Sender: TObject; E: Exception);
  2. begin
  3.   DumpExceptionCallStack(E);
  4. end;
  5.  
But this doesn't create any file. Exception handler with try except doesn't catch any exception too. Application still crashes.

Why?

I think that application crashes because bug is in filter but I have not any log except this heap tracing.
« Last Edit: February 20, 2020, 07:30:04 am by Milsa »
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Application sometimes crashes when I using filter on SQLQuery
« Reply #3 on: February 20, 2020, 09:04:48 am »
DumpExceptionCallStack dumps the stack trace to StdOut.

Milsa

  • Sr. Member
  • ****
  • Posts: 309
Re: Application sometimes crashes when I using filter on SQLQuery
« Reply #4 on: February 20, 2020, 10:00:28 am »
Excuse me. It is my custom procedure. This is it:
Code: Pascal  [Select][+][-]
  1. procedure DumpExceptionCallStack(E: Exception);
  2. var
  3.   f: Text;
  4.   i: integer;
  5.   Frames: PPointer;
  6.   Message: string;
  7.   Report: string;
  8. begin
  9.   Message :=
  10.     E.Message + LineEnding + LineEnding +
  11.     'Stacktrace:' + LineEnding;
  12.   if E <> nil then
  13.   begin
  14.     Report :=
  15.       'Date and time: ' + DateTimeToStr(Now) + LineEnding +
  16.       'Exception class: ' + E.ClassName + LineEnding +
  17.       'Message: ' + E.Message + LineEnding;
  18.   end;
  19.   Report := Report + '1:' + BackTraceStrFunc(ExceptAddr);
  20.   Frames := ExceptFrames;
  21.   for i := 0 to ExceptFrameCount - 1 do
  22.     Report := Report + LineEnding +
  23.       IntToStr(i + 2) + ':' + BackTraceStrFunc(Frames[i]);
  24.   ShowMessage(Message + Report);
  25.  
  26.   AssignFile(f, LogFilename);
  27.   if FileExists(LogFilename) then
  28.     Append(f)
  29.   else
  30.     Rewrite(f);
  31.   Report := Report + LineEnding + LineEnding + LineEnding;
  32.   Write(f, Report);
  33.   CloseFile(f);
  34.   //Halt;
  35. end;
  36.  
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Application sometimes crashes when I using filter on SQLQuery
« Reply #5 on: February 20, 2020, 11:23:39 am »
Excuse me. It is my custom procedure. This is it:
You also have a ShowMessage in there so either you didn't set your Application.OnException or you are running in the IDE and didn't continue the program after the GDB (debugger) gave it's exception.

If you run inside the IDE with debugging on, the GDB debugger first catches the exception and gives you a dialog. You need to click continue (or run again) to continue to your own exception handler. If you run outside the IDE only your own exception handler should fire.

If all that doesn't work... did you set the Application.OnException correctly?

 

TinyPortal © 2005-2018