Recent

Author Topic: Solved! Thanks! A strange crash at WidgetSet.AppRun(@RunLoop);  (Read 486 times)

senglit

  • Full Member
  • ***
  • Posts: 131
Found the problem. Wrong Pointer  :o

Hi all,

I am working on a program (win7 32bit, Lazarus 2.0.0). It worked well before. 3 days ago, I decided to do some change(the way to read and write data from RS485). And I got a strange crash "Project raised exception class 'External:SIGSEGV' " At adress 4633A2 whenever I start the program.

what I did when the program starts was:
Code: Pascal  [Select][+][-]
  1. procedure TFrmMain.FormCreate(Sender: TObject);
  2. var
  3.   bRet: boolean = False;
  4.   i:integer;
  5. begin
  6.   ActivePanel:=@pnZhenKong;
  7.   ActiveLabel:=@lbZhenKong;
  8.   lbZhenKongClick(Self);
  9.   if LoadCmdFile then
  10.     log('Load cmd file OK')
  11.   else
  12.     begin
  13.       log('load cmd file fail',clRed);
  14.       exit;
  15.     end;
  16.   if LoadSysFile then
  17.     log('load sys file OK')
  18.   else
  19.     begin
  20.       log('load sys file Fail',clRed);
  21.       exit;
  22.     end;
  23.   CreateCiFenXiJiSuanBlock;
  24.   CreateShuLiuHuanJingBlock;
  25.   CreateFaMenAndKaiGuanBlock;
  26.   CreateFenZiBengBlock;
  27.   CreateZhenKongJiLED;
  28.   CreateLiuLiangJiBlock;
  29.   CreateDianYuanBlock;
  30.   CreateFuZhuKaiGuan_ShuRuBlock;
  31.   CreateFuZhuMoNi_ShuRuBlock;
  32.   CreateFuZhuMoNi_ShuChuBlock;
  33.   CreateBaTaiWenKongBlock;
  34.   CreateBuJinDianJiBlock;
  35.   for i:=0 to Length(MyCom)-1 do MyCom[i].Start;
  36.   Delay(500);
  37.   DJ2HSS442_RC_Init;
  38. end;                
  39.  

I believe something wrong with this procedure. So I did the following:
1. remark all of the code in TFrmMain.FormCreate. The program worked again. no crash.
2. remark all of the lines start from CreateCiFenXiJiSuanBlock. The program worked again. not crash.
3. unmark any line named as "Create...Block", the program crash again! What these procedures named "Create...Block" did was to create some components on the mainform according to the information they read from 'sys.pzwj'. They worked very well before.
4. I unmarked 1 "Create...Block" procedure (any one of them, the result is the same) and debuged the program step by step. It worked well at project file line: Application.CreateForm(TFrmMain, FrmMain); And I can see the components were correctly created and shown on the mainform. Then it crashed at Application.Run;
5. I stepped into Application.Run; and found it crashed at WidgetSet.AppRun(@RunLoop);

I guess I must modified something unconciously which made the dynamic created components can not be shown correctly (If i remark all of the "Create...Block", the program would not crash). But I don't know what I really did.

The dynamic created components include TLabel, TShape, TFloatSpinEdit and some components in package Industrial. I've installed the package industrial. And If I put these component statically on mainform, everything is ok. it crash only when they are created dynamically.

Anyone has suggestion? Thanks for your notice and help!

Senglit
« Last Edit: August 20, 2019, 01:59:20 pm by senglit »
I use Win10 + Lazarus 2.2.0 + FPC 3.2.2. All 64bit.

 

TinyPortal © 2005-2018