Recent

Author Topic: My application crashes without any reason  (Read 1258 times)

Milsa

  • Full Member
  • ***
  • Posts: 232
My application crashes without any reason
« on: September 27, 2020, 10:36:17 pm »
Problem code is in filesthreadclass.pas in lines 52-71.
Press Find in application and it will crash.
Remove these lines and application is without problem.
Where is the problem?
I work with Lazarus 2.0.10, FPC 3.2.0, SVN 63526
This information is actual to: 1st Aug 2020

Blaazen

  • Hero Member
  • *****
  • Posts: 2994
  • POKE 54296,15
    • Eye-Candy Controls
Re: My application crashes without any reason
« Reply #1 on: September 27, 2020, 10:57:28 pm »
Are you on Linux? Threads were not enabled. I added
Code: Pascal  [Select][+][-]
  1. {$define UseCThreads}
to deduplicator.lpr and pressing Find does not crash app but opens some grids.
Lazarus 2.1.0 r64115 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Milsa

  • Full Member
  • ***
  • Posts: 232
Re: My application crashes without any reason
« Reply #2 on: September 27, 2020, 11:17:59 pm »
Windows 10 64-bit 19041
I work with Lazarus 2.0.10, FPC 3.2.0, SVN 63526
This information is actual to: 1st Aug 2020

Milsa

  • Full Member
  • ***
  • Posts: 232
Re: My application crashes without any reason
« Reply #3 on: September 27, 2020, 11:22:09 pm »
Application does not crash to system. It shows any error without any line in stack dump.

Sometimes application works correctly (in 10 % cases).
I work with Lazarus 2.0.10, FPC 3.2.0, SVN 63526
This information is actual to: 1st Aug 2020

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1075
  • Former Delphi 1-7, 10.2 User
Re: My application crashes without any reason
« Reply #4 on: September 28, 2020, 03:36:26 am »
Your application does not "crash" at all! You might like to fix your post title.

You have a "list index out of bounds" run-time error. This means that there is something wrong with your code - specifically you have tried to access a list index of 6 which is bigger than you allow for in your list.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6, Xcode 11.3.1
o Lazarus v2.1.0 r64160, FPC v3.3.1 Nov 27 21:16:31, macOS 11.0.1 (aarch64), Xcode 12.2
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware VM)
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (PD VM)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6718
  • Debugger - SynEdit - and more
    • wiki
Re: My application crashes without any reason
« Reply #5 on: September 28, 2020, 04:09:41 am »
Check the Stack window: Menu > View > Debug Windows > Callstack

If there are no line numbers there, then your project is not setup for debugging: https://wiki.lazarus.freepascal.org/Debugger_Setup

Follow the steps for the setup, and when you press "break" on the error, the IDE should take you to the error line. (Though sometimes, you need to use the stack window, and try the top 3 or 4 entries)

See, if that gives you some more info.


I did a quick run with this. And it gives me an error line (though I needed to go down a few entries in the stack).

procedure TFormMain.TimerShowTimer(Sender: TObject);
....
    begin
      StatusBar.Panels[6].Text := '2/2: ' + IntToStr(AppData.CountSort);
    end;

Milsa

  • Full Member
  • ***
  • Posts: 232
Re: My application crashes without any reason
« Reply #6 on: September 28, 2020, 08:35:17 am »
I change optimization by your instructions to 0 (I had 1 - debugger friendly).
I do not understand why I have this call stack always.
How did you find the error line?
I work with Lazarus 2.0.10, FPC 3.2.0, SVN 63526
This information is actual to: 1st Aug 2020

jamie

  • Hero Member
  • *****
  • Posts: 3797
Re: My application crashes without any reason
« Reply #7 on: September 28, 2020, 01:27:45 pm »
Are u removing items from the list in the main thread while this thread is looping through the list?

Using the for loop control can lead to issues where as once the loop counter is set in range it assumes the reference source is constant, not being depupulated in the loop.

U may need to use a critical section to stop this action in the main thread
The only true wisdom is knowing you know nothing

rvk

  • Hero Member
  • *****
  • Posts: 4407
Re: My application crashes without any reason
« Reply #8 on: September 28, 2020, 01:42:45 pm »
There are several places in your code like this:
Code: Pascal  [Select][+][-]
  1. for i := 0 to AppConfig.BlockList.Count - 1 do
Now guess what happens when AppConfig.BlockList.Count  is zero?
 :o
Nothing, because for := 0 to -1 won't even go into the for-loop.
(you should know that)
« Last Edit: September 28, 2020, 01:45:04 pm by rvk »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6718
  • Debugger - SynEdit - and more
    • wiki
Re: My application crashes without any reason
« Reply #9 on: September 28, 2020, 02:21:17 pm »
I change optimization by your instructions to 0 (I had 1 - debugger friendly).
I do not understand why I have this call stack always.
How did you find the error line?

How did you install Lazarus/FPC?

The stack you posted shows an error in TFpList, which can be part of TList. (That matches the index out of bound)
It is normal that for such an error, the actual exception happens in either FPC or LCL (or other supplied) code.
Also there may be other packages (LCL) between that TFpList, and your code. Then that package could also be the culprit.

It is possible that your fpc is build with optimization. That can in some cases prevent the stack to be completely shown.

-----------------
You have seen my last post, and that I got an error accessing status panel index 6 (the 7th panel, but there are only 6).

Milsa

  • Full Member
  • ***
  • Posts: 232
Re: My application crashes without any reason
« Reply #10 on: September 28, 2020, 02:27:27 pm »
My installation is standard with "secondary" option during installation. I use 32 and 64 bit installation together in other directory and other config directory.
I work with Lazarus 2.0.10, FPC 3.2.0, SVN 63526
This information is actual to: 1st Aug 2020

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6718
  • Debugger - SynEdit - and more
    • wiki
Re: My application crashes without any reason
« Reply #11 on: September 28, 2020, 03:15:02 pm »
My installation is standard with "secondary" option during installation. I use 32 and 64 bit installation together in other directory and other config directory.

OK. I went to test with the official release myself. Indeed the "GDB" included has a problem in case of that error.

"GDB" => is a standalone debugger. It is used by the Lazarus (and many other open source IDE) as helper to do debugging. But it comes with some flaws....

Anyway, there is a solution. And I tested it, but it takes a few extra steps. Sorry about that.
1) Menu: Tools > Options: Debugger > General.
  There is a drop down, that currently shows "gdb debugger (gdb)" => change it to "FpDebug, internal dwarf debugger (beta)".
2) When running your app, you may be asked to choose a "debug info type". Choose "Dwarf with sets"
   You can choose "Dwarf 3", which is better. But if you ever change back to "gdb" then you must go to project options, and change it to "dwarf with sets"



EDIT: I think FpDebug should be in the list by default. But I may have made changes to my release install of Lazarus.
If it is not there: menu > Packages > Install/Uninstall Packages > and install the package "LazDebuggerFp"
« Last Edit: September 28, 2020, 03:18:04 pm by Martin_fr »

Milsa

  • Full Member
  • ***
  • Posts: 232
Re: My application crashes without any reason
« Reply #12 on: September 28, 2020, 04:02:42 pm »
I have fpdebug. But I set Dwarf3 and I got error after application start:

Debugger error.
Save your work etc.
GDB detected.

More    Stop

I translated it to english from slovak.
I work with Lazarus 2.0.10, FPC 3.2.0, SVN 63526
This information is actual to: 1st Aug 2020

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6718
  • Debugger - SynEdit - and more
    • wiki
Re: My application crashes without any reason
« Reply #13 on: September 28, 2020, 05:44:23 pm »
I have fpdebug. But I set Dwarf3 and I got error after application start:

Debugger error.
Save your work etc.
GDB detected.

More    Stop

I translated it to english from slovak.

"gdb detected" is an error message by the "gdb debugger".
Please double check the settings under tools > options.

Note there is an "gdb debugger with fpdebug" (though I am not sure that is listed by default. You do NOT want this one.

If the setting is correct (in Tools > Options), restart the IDE.
It should work without the restart, but just in case.

---
The "FpDebug internal dwarf debugger" does not use gdb at all (even though the config still has the field for the path to gdb, but that is ignored).

Milsa

  • Full Member
  • ***
  • Posts: 232
Re: My application crashes without any reason
« Reply #14 on: September 29, 2020, 09:24:36 pm »
These is my options.
I work with Lazarus 2.0.10, FPC 3.2.0, SVN 63526
This information is actual to: 1st Aug 2020

 

TinyPortal © 2005-2018