Recent

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

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 216
Re: [Partially Solved] My main form crashes Lazarus IDE
« Reply #15 on: December 20, 2018, 02:55:07 pm »
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.

The AllocData method has 2 bugs:
1.) SetLength(FData, ACount * FWidth * FHeight * SizeOf(FData[0]));
2.) Inc(FAllocCount, ACount);

It should read:
1.) SetLength(FData, ACount * FWidth * FHeight);
2.) FAllocCount := ACount;

If you fix both, your IDE should work fine. The bugs have been in the LCL for years (I checked 1.4.4 and they are there) - strange that nobody noticed them, including myself when I rewrote the imagelist in 1.9.

Btw. I wanted to send a patch to Mantis but you closed https://bugs.freepascal.org/view.php?id=34708 as "no change required" :/

Code: [Select]
procedure TCustomImageListResolution.AllocData(ACount: Integer);
var
  n: Integer;
begin
  if FAllocCount >= ACount
  then Exit;

  // calculate number of blocks, add an extra block for the remainder.
  n := ACount mod FImageList.FAllocBy;
  if n <> 0
  then Inc(ACount, FImageList.FAllocBy - n);

  SetLength(FData, ACount * FWidth * FHeight);

  FAllocCount := ACount;
end;

lainz

  • Hero Member
  • *****
  • Posts: 3563
    • Lainz
Re: [Partially Solved] My main form crashes Lazarus IDE
« Reply #16 on: December 20, 2018, 03:58:45 pm »
Ok I reopened it
https://lainz.github.io - My Website
https://lazpaint.github.io/ - LazPaint Downloads

wp

  • Hero Member
  • *****
  • Posts: 7043
Re: [Partially Solved] My main form crashes Lazarus IDE
« Reply #17 on: December 20, 2018, 05:55:35 pm »
I applied Ondrej's patch - thank you. I understand that the bug was responsible for allocation of 4 times more memory than needed. But does this explain the gradual allocation of memory consumption reported by lainz?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 216
Re: [Partially Solved] My main form crashes Lazarus IDE
« Reply #18 on: December 20, 2018, 06:09:39 pm »
But does this explain the gradual allocation of memory consumption reported by lainz?

No, not directly.

zeljko

  • Hero Member
  • *****
  • Posts: 1139
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: [Partially Solved] My main form crashes Lazarus IDE
« Reply #19 on: December 21, 2018, 05:16:11 pm »
r59880 introduced memory corruption. See why in r59888. In any case r59880 and r59888 should be reverted back until it's properly fixed because now some imagelists (haven't tested all scenarios yet), does not work as expected.
Edit: without r59888 win32 works fine, but gtk2, qt and qt5 crashes because of memory corruption. With r59888, there's no crashes, but some bitmaps are invisible when loaded from imagelist - reproducable on win32 (via wine), gtk2 and qt/qt5.
« Last Edit: December 21, 2018, 05:30:57 pm by zeljko »

 

TinyPortal © 2005-2018