Recent

Author Topic: [Partially Solved] My main form crashes Lazarus IDE  (Read 4872 times)

lainz

  • Hero Member
  • *****
  • Posts: 3563
    • Lainz
[Partially Solved] My main form crashes Lazarus IDE
« on: December 12, 2018, 11:09:34 pm »
Hi, In the project I'm working I have a huge form (2 mb) that when it's opened it crashes the Lazarus IDE with 'access violation'.

If the form is closed Lazarus works normally.

How I can debug that? The ide in some time was at 900 MB of RAM usage, so it's leaking somewhere.
« Last Edit: December 19, 2018, 09:43:19 pm by lainz »
https://lainz.github.io - My Website
https://lazpaint.github.io/ - LazPaint Downloads

wp

  • Hero Member
  • *****
  • Posts: 7043
Re: My main form crashes Lazarus IDE
« Reply #1 on: December 12, 2018, 11:18:14 pm »
If you are working with Laz trunk: This version has been leaking for a few days recently. Try a more recent trunk version.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

lainz

  • Hero Member
  • *****
  • Posts: 3563
    • Lainz
Re: My main form crashes Lazarus IDE
« Reply #2 on: December 12, 2018, 11:28:25 pm »
Thanks I will try, I'm using trunk. It happens about a month ago or more, so I wish this can be solved or if I can debug it in some way.
https://lainz.github.io - My Website
https://lazpaint.github.io/ - LazPaint Downloads

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6288
    • wiki
Re: My main form crashes Lazarus IDE
« Reply #3 on: December 13, 2018, 12:00:03 am »
There are several ways to debug the IDE.

First of all for any of them make sure you have debug info. In Tools > Configure build Lazarus
-gw -godwarfset -O- -gh
-Sa -gt -Criot

the 2nd line is optional.
Make sure this applies to any package you use. (installed in the IDE)


1) run the IDE with a logfile (on windows edit properties of a shortcut)
lazarus.exe --debug-log=/path/file.log

Crashes will likely write logs to the file

2) If you need very basic info only, or no trace was written in (1)
start gdb on commandline
  gdb lazarus.exe
and then use "r" to run it.
"bt" to get a trace when it stops

3) In the ide open the project ide/lazarus.lpi
Hit F9
A 2nd IDE will be started and is being debugged by the first.

------
Since you know aprox when it started, consider bisecting the guilty revision

lainz

  • Hero Member
  • *****
  • Posts: 3563
    • Lainz
Re: My main form crashes Lazarus IDE
« Reply #4 on: December 16, 2018, 03:21:48 pm »
Ok what I get is this:

Code: Pascal  [Select][+][-]
  1. TApplication.HandleException: EOutOfMemory
  2. Out of memory
  3.   Stack trace:
  4.   $00413B9A
  5.   $00413EDA
  6.   $0061B2B2  ALLOCDATA,  line 329 of include/imglist.inc
  7.   $0061BF46  INTERNALINSERT,  line 626 of include/imglist.inc
  8.   $0061E112  ADDSLICE,  line 1390 of include/imglist.inc
  9.   $0062227A  ADDNEWBTNIMAGE,  line 2745 of include/imglist.inc
  10.   $00621F76  GETIMAGEINDEX,  line 2781 of include/imglist.inc
  11.   $007F96CD  GETIMAGEINDEX,  line 290 of ideimagesintf.pas
  12.   $008494C8
  13.   $008663DE
  14.   $00875CE8
  15.   $0043A61E  GETCHILDREN,  line 1072 of include/customform.inc
  16.   $008755B0
  17.   $00875E7A
  18.   $008760E7
  19.   $00875F59
  20.   $008785B8
  21. ERROR in code:
  22. Creating gdb catchable error:
  23.  
  24.   $004E4BC4  DEBUGLNSTACK,  line 868 of lazloggerbase.pas
  25.   $004E20CC  DEBUGLNSTACK,  line 12 of LazLoggerImpl.inc
  26.   $004E61E7  RAISEGDBEXCEPTION,  line 48 of laztracer.pas
  27.   $00CDBECA
  28.   $00CDBE78
  29.   $008712E7
  30.   $0087407E
  31.   $005A339D  WNDPROC,  line 2186 of include/control.inc
  32.   $005A1D2A  PERFORM,  line 1580 of include/control.inc
  33.   $00595CF4  PAINTCONTROLS,  line 4959 of include/wincontrol.inc
  34.   $00595AE0  PAINTHANDLER,  line 4871 of include/wincontrol.inc
  35.   $00599D2B  WMPAINT,  line 6841 of include/wincontrol.inc
  36.   $005ACD4D  WMPAINT,  line 98 of include/customcontrol.inc
  37.   $00410449
  38.   $0087407E
  39.   $005A339D  WNDPROC,  line 2186 of include/control.inc
  40.   $00596E2B  WNDPROC,  line 5425 of include/wincontrol.inc
  41.   $0068472A  DELIVERMESSAGE,  line 112 of lclmessageglue.pas
  42.   $00572FDE  SENDPAINTMESSAGE,  line 710 of win32/win32callback.inc
  43.   $0057749D  DOWINDOWPROC,  line 2297 of win32/win32callback.inc
  44.   $00578589  WINDOWPROC,  line 2699 of win32/win32callback.inc
  45.   $76ACBF1B
  46.   $76AC83EA
  47.   $76AABECA
  48.   $76AABC57
  49.   $723A5F23
  50.   $73489FBF
  51.   $734C0F7E
  52.   $734C0E64
  53.   $7346FA96
  54.   $76ACBF1B
  55.   $76AC83EA
  56.   $76AA7AFD
  57.   $00571DD9  CALLDEFAULTWINDOWPROC,  line 97 of win32/win32callback.inc
  58.   $005779E6  DOWINDOWPROC,  line 2445 of win32/win32callback.inc
  59.   $00578589  WINDOWPROC,  line 2699 of win32/win32callback.inc
  60.   $76ACBF1B
  61.   $76AC83EA
  62.   $76AC7F8A
  63.   $76ACA6D9
  64.   $7748CD3D
  65.   $6B677DE6
  66.   $76ABA989
  67.   $7748CD3D
  68.   $76AC90A4
  69.   $76AA8FB3
  70.   $76AA4B0A
  71.   $76AA4A22
  72.   $76AA49DB
  73.   $7357D5A3
  74.   $734A6A35
  75.   $734A7526
  76.   $00583A3B  PROMPTUSER,  line 773 of win32/win32lclintf.inc
  77.   $0052F1AD  PROMPTUSER,  line 376 of include/lclintf.inc
  78.   $0052F7EF  PROMPTUSER,  line 535 of include/lclintf.inc
  79.   $00446DD0  SHOWEXCEPTION,  line 1591 of include/application.inc
  80.   $0078A169  HANDLEAPPLICATIONEXCEPTION,  line 28 of lclexceptionstacktrace.pas
  81.   $00445EC0  HANDLEEXCEPTION,  line 1258 of include/application.inc
  82.   $004465EB  RUNLOOP,  line 1421 of include/application.inc
  83.   $0048F2EF  APPRUN,  line 54 of include/interfacebase.inc
  84.   $00446556  RUN,  line 1407 of include/application.inc
  85.   $00403A9B  main,  line 152 of lazarus.pp
  86.   $00418C76
  87. ERROR in code:
  88. Creating gdb catchable error:
  89.  
  90.   $004E4BC4  DEBUGLNSTACK,  line 868 of lazloggerbase.pas
  91.   $004E20CC  DEBUGLNSTACK,  line 12 of LazLoggerImpl.inc
  92.   $004E61E7  RAISEGDBEXCEPTION,  line 48 of laztracer.pas
  93.   $00CDBECA
  94.   $00CDBE78
  95.   $008712E7
  96.   $0087407E
  97.   $005A339D  WNDPROC,  line 2186 of include/control.inc
  98.   $00596E2B  WNDPROC,  line 5425 of include/wincontrol.inc
  99.   $0068472A  DELIVERMESSAGE,  line 112 of lclmessageglue.pas
  100.   $00572FDE  SENDPAINTMESSAGE,  line 710 of win32/win32callback.inc
  101.   $0057749D  DOWINDOWPROC,  line 2297 of win32/win32callback.inc
  102.   $00578589  WINDOWPROC,  line 2699 of win32/win32callback.inc
  103.   $76ACBF1B
  104.   $76AC83EA
  105.   $76AABECA
  106.   $76AABC57
  107.   $723A5F23
  108.   $73489FBF
  109.   $734C0F7E
  110.   $734C0E64
  111.   $7346FA96
  112.   $76ACBF1B
  113.   $76AC83EA
  114.   $76AA7AFD
  115.   $00571DD9  CALLDEFAULTWINDOWPROC,  line 97 of win32/win32callback.inc
  116.   $005779E6  DOWINDOWPROC,  line 2445 of win32/win32callback.inc
  117.   $00578589  WINDOWPROC,  line 2699 of win32/win32callback.inc
  118.   $76ACBF1B
  119.   $76AC83EA
  120.   $76AC7F8A
  121.   $76ACA6D9
  122.   $7748CD3D
  123.   $0044542E  UPDATEVISIBLE,  line 992 of include/application.inc
  124.   $004391F6  SETVISIBLE,  line 493 of include/customform.inc
  125.   $0043DFA0  HIDE,  line 2318 of include/customform.inc
  126.   $00438502  BEFOREDESTRUCTION,  line 183 of include/customform.inc
  127.   $00438560  DESTROY,  line 198 of include/customform.inc
  128.   $0040FF42
  129.   $00433E3D  BEFOREFINALIZATION,  line 1935 of forms.pp
  130.   $00412C01
  131.   $006847A3  DELIVERMESSAGE,  line 116 of lclmessageglue.pas
  132.   $00572FDE  SENDPAINTMESSAGE,  line 710 of win32/win32callback.inc
  133.   $0057749D  DOWINDOWPROC,  line 2297 of win32/win32callback.inc
  134.   $00578589  WINDOWPROC,  line 2699 of win32/win32callback.inc
  135.   $76ACBF1B
  136.   $76AC83EA
  137.   $76AABECA
  138.   $76AABC57
  139.   $723A5F23
  140.   $73489FBF
  141.   $734C0F7E
  142.   $734C0E64
  143.   $7346FA96
  144.   $76ACBF1B
  145.   $76AC83EA
  146.   $76AA7AFD
  147.   $00571DD9  CALLDEFAULTWINDOWPROC,  line 97 of win32/win32callback.inc
  148.   $005779E6  DOWINDOWPROC,  line 2445 of win32/win32callback.inc
  149.   $00578589  WINDOWPROC,  line 2699 of win32/win32callback.inc
  150.   $76ACBF1B
  151.   $76AC83EA
  152.   $76AC7F8A
  153.   $76ACA6D9
  154.   $7748CD3D
  155.   $6B677DE6
  156.   $76ABA989
  157.   $7748CD3D
  158.   $76AC90A4
  159.   $76AA8FB3
  160.   $76AA4B0A
  161.   $76AA4A22
  162.   $76AA49DB
  163.   $7357D5A3
  164.   $734A6A35
  165.   $734A7526
  166.   $00583A3B  PROMPTUSER,  line 773 of win32/win32lclintf.inc
  167.   $0052F1AD  PROMPTUSER,  line 376 of include/lclintf.inc
  168.   $0052F7EF  PROMPTUSER,  line 535 of include/lclintf.inc
  169.   $00446DD0  SHOWEXCEPTION,  line 1591 of include/application.inc
  170.   $0078A169  HANDLEAPPLICATIONEXCEPTION,  line 28 of lclexceptionstacktrace.pas
  171.   $00445EC0  HANDLEEXCEPTION,  line 1258 of include/application.inc
  172.   $0044

As well as the attached image.
« Last Edit: December 16, 2018, 03:25:24 pm by lainz »
https://lainz.github.io - My Website
https://lazpaint.github.io/ - LazPaint Downloads

Thaddy

  • Hero Member
  • *****
  • Posts: 10098
Re: My main form crashes Lazarus IDE
« Reply #5 on: December 16, 2018, 03:27:22 pm »
EOutOfMemory is - as in Delphi - pre-allocated so it is able to report the error and should show a nice exception dialog?
If this is not the case then Lazarus should take the same approach and pre-allocate the EOutOfMemory dialog beforehand.
Note you still need to allow for EOutOfMemory explicitly.
« Last Edit: December 16, 2018, 03:29:20 pm by Thaddy »
I am more like donkey than shrek

lainz

  • Hero Member
  • *****
  • Posts: 3563
    • Lainz
Re: My main form crashes Lazarus IDE
« Reply #6 on: December 16, 2018, 03:31:35 pm »
Hi Thaddy, I readed the docs and it says is pre allocated in FPC as well.

How I can turn it on to display the nice exception dialog? What I get is a unresponsive IDE that closes itself.

In the log shows that is image list the problem or i'm pointing it wrong?

Edit: I reported a bug
https://bugs.freepascal.org/view.php?id=34708

I think is image list, it allocates memory in allocdata line 329 and seems that is not freed.
« Last Edit: December 16, 2018, 04:06:30 pm by lainz »
https://lainz.github.io - My Website
https://lazpaint.github.io/ - LazPaint Downloads

lainz

  • Hero Member
  • *****
  • Posts: 3563
    • Lainz
Re: My main form crashes Lazarus IDE
« Reply #7 on: December 17, 2018, 12:06:26 am »
Well, I can't provide a form that replicates the issue so there's no way to get help in the bugtracker and they're right, they can't reproduce so can't test.

I will try to split the form in data modules to see if that solves the problem.
https://lainz.github.io - My Website
https://lazpaint.github.io/ - LazPaint Downloads

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: My main form crashes Lazarus IDE
« Reply #8 on: December 17, 2018, 04:53:22 am »
You obviously caught a bug. Line 329 is:
Code: Pascal  [Select][+][-]
  1. procedure TCustomImageListResolution.AllocData(ACount: Integer);
  2. ...
  3.   SetLength(FData, ACount * FWidth * FHeight * SizeOf(FData[0]));
  4.  
Your image shows that Lazarus did not reserve more than 240MB.
EOutOfMemory shows that ACount * FWidth * FHeight * SizeOf(FData[0]) is more than what's possible for 32-bit Lazarus.

I would suggest you catch the EOutOfMemory exception around SetLength and check the values involved in ACount * FWidth * FHeight * SizeOf(FData[0]). The odd value would give a direction toward the source of the bug, I guess.

The comments you received in your bug report are disappointing.

Cyrax

  • Hero Member
  • *****
  • Posts: 805
Re: My main form crashes Lazarus IDE
« Reply #9 on: December 17, 2018, 11:10:59 am »
Maybe removing SizeOf(FData[0]) from that line helps. With dynamic arrays SetLength knows that arrays element type size automatically, so it doesn't need to be told to it explicitly.

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: My main form crashes Lazarus IDE
« Reply #10 on: December 17, 2018, 07:19:58 pm »
Maybe removing SizeOf(FData[0]) from that line helps. With dynamic arrays SetLength knows that arrays element type size automatically, so it doesn't need to be told to it explicitly.

I believe you are right about removing SizeOf(FData[0]). Still SizeOf(FData[0]) is 4 which makes me think there might be another problem.

wp

  • Hero Member
  • *****
  • Posts: 7043
Re: My main form crashes Lazarus IDE
« Reply #11 on: December 17, 2018, 07:59:57 pm »
You obviously caught a bug. Line 329 is:
Code: Pascal  [Select][+][-]
  1. procedure TCustomImageListResolution.AllocData(ACount: Integer);
  2. ...
  3.   SetLength(FData, ACount * FWidth * FHeight * SizeOf(FData[0]));
  4.  
Your image shows that Lazarus did not reserve more than 240MB.
EOutOfMemory shows that ACount * FWidth * FHeight * SizeOf(FData[0]) is more than what's possible for 32-bit Lazarus.
You lost me. How do you know what ACount, FWidth and FHeight are? Nothing has been mentioned so far. Where do you see the 240MB in the screenshot?

The comments you received in your bug report are disappointing.
Sorry. But what do you expect when we cannot reproduce the issue and the author cannot provide precise steps how to do that.
« Last Edit: December 17, 2018, 09:57:29 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: My main form crashes Lazarus IDE
« Reply #12 on: December 18, 2018, 03:14:32 am »
You lost me. How do you know what ACount, FWidth and FHeight are? Nothing has been mentioned so far.
I am not sure why I lost you. The stack trace shows:
Code: Pascal  [Select][+][-]
  1. TApplication.HandleException: EOutOfMemory
  2. Out of memory
  3.   Stack trace:
  4.   $00413B9A
  5.   $00413EDA
  6.   $0061B2B2  ALLOCDATA,  line 329 of include/imglist.inc
EOutOfMemory at line 329.

Line 329 is:
Code: Pascal  [Select][+][-]
  1.   SetLength(FData, ACount * FWidth * FHeight * SizeOf(FData[0]));

I know ACount * FWidth * FHeight * SizeOf(FData[0]) is too much. I don't know why, nor what each value is. That is why I suggested to catch the exception and find these values.

Cyrax spotted the wrong SizeOf(FData[0]) in the call to SetLength. Do you agree with him? is this line buggy or not?

Where do you see the 240MB in the screenshot?
Check the attached image.

lainz

  • Hero Member
  • *****
  • Posts: 3563
    • Lainz
Re: My main form crashes Lazarus IDE
« Reply #13 on: December 19, 2018, 09:43:06 pm »
When using 64 bit IDE it goes worst, it uses more than 1 gb of ram and then crashes.

But, I found the problem, I have a progress bar with style marquee on that form, and seems that when that animation is running even if I'm designing in the IDE, so it refreshes the GUI a lot, and for sure there's something causing the out of memory error, is a big form as I already say.

To solve I set the style to normal and set marquee by code. But memory still growing over time, not too much and the IDE has not crashed now.

Tried to create another form to replicate and did not work, there must be a component that uses image list and causes this issue. But for now I'm good.
https://lainz.github.io - My Website
https://lazpaint.github.io/ - LazPaint Downloads

wp

  • Hero Member
  • *****
  • Posts: 7043
Re: My main form crashes Lazarus IDE
« Reply #14 on: December 20, 2018, 10:04:02 am »
I am not sure why I lost you.
Thanks for clarification, I now understand your arguments.

I tried to remove the FData[0] in the AllocData method; the effect is that the IDE hangs when restarting after building. The TCustomImageListResolution makes use of both byte-wise (System.Move(...) ) and element-wise memory (FData[0]) access to the FData array. Something else must be wrong, too.
« Last Edit: December 20, 2018, 12:30:02 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

 

TinyPortal © 2005-2018