strange errorors lazarus / 21-General ---------------------------------------------------------------------- berghem · 2021-04-17 18:56 Hi all in my software I have two stange errors in external library I know where are the errors.... Can you help me? ---------------------------------------------------------------------- MarkMLl · 2021-04-17 19:15 There's a bug in your program. You haven't told us what your program's doing, what library it's using and how it's interfaced to it, posted any example code exhibiting the bug, told us what OS you're running, what version of FPC or whether you're using Lazarus and the LCL. In particular, you've not told us whether you've got debugging enabled and have tried running under an IDE that would trap the (first) exception. MarkMLl ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-04-17 19:34 Hey Mark, Quote from: MarkMLl on April 17, 2021, 09:15:49 pmYou haven't told us what your program's doing, what library it's using and how it's interfaced to it, posted any example code exhibiting the bug, told us what OS you're running, what version of FPC or whether you're using Lazarus and the LCL. In particular, you've not told us whether you've got debugging enabled and have tried running under an IDE that would trap the (first) exception. Rather big off-topic here(but hey): I do begin to sympathise with your, sometimes, murderous tendencies toward these badly presented questions. I've been around for WAY less time than you and they are already getting at me. I commend you, very strongly, for having the patience and fortitude to list all that he didn't tells us without even a swear word!! Cheers, Gus ---------------------------------------------------------------------- MarkMLl · 2021-04-17 19:48 Quote from: Gustavo 'Gus' Carreno on April 17, 2021, 09:34:37 pmRather big off-topic here(but hey): I do begin to sympathise with your, sometimes, murderous tendencies toward these badly presented questions. I've been around for WAY less time than you and they are already getting at me. I commend you, very strongly, for having the patience and fortitude to list all that he didn't tells us without even a swear word!! I've been doing tech support stuff, in between or often at the same time as other things, for around 40 years. I've pretty much seen it all... including, just now and again, a user who expressed gratitude- or contrition after a silly mistake. OP: I'm not necessarily saying that I can be of direct help fixing your problem, because it's likely that I'm not running the same OS etc. as you've got. But if you don't give us a full picture of what's going on it's unlikely that anybody else will be able to help either. MarkMLl ---------------------------------------------------------------------- berghem · 2021-04-17 19:49 I am developping on raspberry and I use Lazarus 2.0.6 and I use FPC 3.0.4. I have try except in a lot of procedure and in exception, I save the errors in a log file but I haven't log in this case. I am trying to ensure that there are try except in ALL procedure.... ---------------------------------------------------------------------- jamie · 2021-04-17 22:26 To get the ball rolling here :    1. Is this a fast error, meaning it happens at startup of app.    2 is this an error that seems to only happen when using some specific function in your code?    3. Does it happen when the program is used for a while ?  as for #3,  I would say you could have resource problem, meaning that you are using up memory or handles without releasing unused one's   As for 1 well, that should be easy to track down using the step features of the debugger..  as for 2. then it should be obvious..  You need to track what you are doing in the app at the time it takes place. P.S.  I wanted to say I know what the tree component is, I just don't know what it would be used for since given the nature of it. it's sort of academic . ---------------------------------------------------------------------- berghem · 2021-04-18 08:56 It's a OT software for produce beer in my home, I have a timer that start 20 seconds and call this procedure, In my opinion the proble is some nil pointer... Code: [Select]procedure TFrameBrew.RefreshTemperature; var   lfMashTemperatue: double;   lfSpargeTemperature: double; begin   try     if Assigned(poOptional1Probe) then       lblOptional1.Caption := format('%.1f°', [poOptional1Probe.Temperature]);     if Assigned(poOptional2Probe) then       lblOptional2.Caption := format('%.1f°', [poOptional2Probe.Temperature]);     if piStep < poStep.Count then     begin       poMashProbe.Target := PStep(poStep.Items[piStep])^.Temperature;     end     else       LogError('piStep = ' + IntToStr(piStep));     //Some time the Dallas probe return zero value...     //if lfMashTemperatue > 0 then     //begin     //Sono in Mash     if (pbMash = True) and (piStep < poStep.Count) then     begin       lfMashTemperatue := poMashProbe.Temperature;       if Assigned(poSpargeProbe) then       begin         poSpargeProbe.Target := pfSpargeTemperature;         if not poIniFile.Simulation then         begin           lfSpargeTemperature := poSpargeProbe.Temperature;         end;       end;       if not Assigned(poStep.Items[piStep]) then       begin         LogError('Error in Refresh Temperature poStep not assigned piStep = ' +           IntToStr(piStep));         //Exit;       end;       poMashProbe.Target := PStep(poStep.Items[piStep])^.Temperature;       if poIniFile.Enviroment <> 2 then       begin         if lfMashTemperatue > PStep(poStep.Items[piStep])^.TempMax then         begin           try             PStep(poStep.Items[piStep])^.TempMax := lfMashTemperatue;           except             on e: Exception do               LogError('error in Refresh Temperature poStep = nil ' + e.Message);           end;         end;         lblActualMash.Caption := format('%.1f°', [lfMashTemperatue]);         if assigned(poSpargeGPIO) then           lblActualSparge.Caption := format('%.1f°', [lfSpargeTemperature]);         if (lfMashTemperatue < PStep(poStep.Items[piStep])^.Temperature) then         begin           try             if (lfMashTemperatue >= PStep(poStep.Items[piStep])^.Temperature -               DeltaTemperaturePID) then             begin               try               PowerOffActor(Sparge);               lblFinishBoil.Visible := True;               lblFinishBoil.Caption := 'PID algorithm ON';               PID(lfMashTemperatue, PStep(poStep.Items[piStep])^.Temperature);               except                 on e: exception do                 LogError('error in Refresh Temperature PID start ' + e.Message);               end;             end             else               PowerOnResistence(Mash);           except             on e: Exception do               LogError(                 'Errore in RefreshTemperature lfMashTemperatue < PStep(poStep.Items[piStep])^.Temperature '                 + e.Message);           end;         end;         if lfMashTemperatue >= pfMashSetTemperature then         begin           try             PowerOffActor(Sparge);             lblFinishBoil.Visible := False;             if poIniFile.SpargeProbeValue <> '' then             begin               if lfSpargeTemperature < pfSpargeTemperature then               begin                 if poIniFile.Simulation then                 begin                   lfSpargeTemperature := poSpargeProbe.Temperature;                   lblActualSparge.Caption := format('%.1f°', [lfSpargeTemperature]);                 end;                 PowerOnResistence(Sparge);               end;             end;             if PStep(poStep.Items[piStep])^.FirstTime = False then             begin               PStep(poStep.Items[piStep])^.FirstTime := True;               tmrMash.Enabled := True;             end;           except             on e: Exception do               LogError('Error in Refresh temperature if lfMash >= pfMashTemperature ' +                 e.Message);           end;         end;         if (Assigned(poSpargeGPIO)) and (lfSpargeTemperature >           pfSpargeTemperature) then         begin           try             PowerOffActor(Sparge);           except             on e: Exception do               LogError('Error in Refresh temperature if lfSpargeTemperature > pfSpargeTemperature '                 + e.Message);           end;         end;       end       else         //HERMS       begin         //Varifica Max Temperatura         CheckMash;         //pfSpargeActualTemperature := poSpargeProbe.Temperature;         if piStep < poStep.Count then         begin           lfSpargeTemperature := poSpargeProbe.Temperature;           lblActualMash.Caption := format('%.1f°', [lfMashTemperatue]);           lblActualSparge.Caption := format('%.1f°', [lfSpargeTemperature]);         end;         if (lfMashTemperatue < PStep(poStep.Items[piStep])^.Temperature) then         begin           if (lfMashTemperatue >= PStep(poStep.Items[piStep])^.Temperature -             DeltaTemperaturePID) then           begin             lblFinishBoil.Visible := True;             lblFinishBoil.Caption := 'PID algorithm ON';             PID(lfMashTemperatue, PStep(poStep.Items[piStep])^.Temperature);             lblFinishBoil.Visible := True;           end           else           begin             //Power ON HLT Resistence             PowerOnResistence(Sparge);             //In HERMS Kind this object is pumpMash             poMashPumpGPIO.WritePIN := ON;           end;         end;         if lfMashTemperatue >= pfMashSetTemperature then         begin           PowerOffActor(Sparge);           //In HERMS Kind this object is pumpMash           poMashPumpGPIO.WritePIN := OFF;           lblFinishBoil.Visible := False;           if PStep(poStep.Items[piStep])^.FirstTime = False then           begin             PStep(poStep.Items[piStep])^.FirstTime := True;             tmrMash.Enabled := True;           end;         end;       end;     end     else     begin       //Only after click       if pbBoil = True then       begin         //sono in boil o in rampa di risalita         poBoilProbe.Target := piBoilTemperature;         pfActualBoilTemperature := poBoilProbe.Temperature;         //This condition start the boil timer         if (pfActualBoilTemperature >= piBoilTemperature) and           (pbBoilFlag = False) and (piStep = poStep.Count) then         begin           if piStepTime = 0 then             piStepTime := edtBoilTime.Value;           pbBoilFlag := True;           tmrBoil.Enabled := True;           if poHop.Count > 0 then           begin             tmrHop.Interval :=               ((piBoilTime - PHop(poHop.Items[0])^.Time)) * 60 * 1000;             //logError('timer hop ' + IntToStr(tmrHop.Interval) + ' Time init : ' + INtToStr(PHop(poHop.Items[0])^.Time));             if tmrHop.Interval = 0 then             begin               lblGettata.Caption := Format('#%d Throw Hop', [piThrowHop + 1]);               pnlgettataHop.Visible := True;               TframeMashStep(poHopStep.Items[piThrowHop]).shpStatus.Brush.Color :=                 clGreen;               Inc(piThrowHop);               tmrHop.Interval :=                 (piBoilTime - PHop(poHop.Items[piThrowHop])^.Time) * 60 * 1000;               //logError('timer hop ' + IntToStr(tmrHop.Interval));             end;             tmrHop.Enabled := True;           end;           lblFinishBoil.Caption :=             'Finish Boil Time: ' + FormatDateTime('hh:nn:ss',             IncMinute(now, tmrBoil.Interval div 1000 div 60));           lblFinishBoil.Visible := True;           poReport.Add(Format('
Boil Start %s', [TimeToStr(Now)]));           poReport.SaveToFile('Report_' + cmbRecipe.Text + '.html');         end;         pfActualBoilTemperature := poBoilProbe.Temperature;         lblActualBoil.Caption := format('%.1f°', [pfActualBoilTemperature]);         if (poIniFile.Enviroment = 1) or (poIniFile.Enviroment = 3) then         begin           lblActualMash.Caption := lblActualBoil.Caption;         end;       end;     end;     Application.ProcessMessages;     //end;   except     on e: Exception do       LogError(Format('Error in RefreshTemperature pistep=%d, ActualMash=%1.f,  %s', [piStep, lfMashTemperatue,  e.Message]));   end; end; ---------------------------------------------------------------------- alpine · 2021-04-18 10:08 Code still doesn't help much. What is the type of poStep, poMash variables? Can't you trace back the faulty line in your code? I mean to run the program inside the IDE with F9 and to examine the stack (Ctrl+ALT+S) after the exception occurs? ---------------------------------------------------------------------- Thaddy · 2021-04-18 10:14 Quote from: y.ivanov on April 18, 2021, 12:08:32 pmCode still doesn't help much. What is the type of poStep, poMash variables? It is a set. Errorors does not help: errors. ---------------------------------------------------------------------- alpine · 2021-04-18 10:42 Quote from: Thaddy on April 18, 2021, 12:14:17 pmIt is a set. Errorors does not help: errors. How you can be sure it is a set? By laz_avl_tree.pp in the message? I would say we can't even be sure the exception is in that given procedure ---------------------------------------------------------------------- jamie · 2021-04-18 12:46 you should at least have a exit block at the start of that procedure incase the block is already there. THe Ttimer has a TAG property … Test that property upon entry to the block of code, if it's not 0 then exit else set it to something other than 0.. at the end of the procedure block set it back to 0 This way in case there is some hold up in the block it won't get re- entered and it will help you find your problem ---------------------------------------------------------------------- Thaddy · 2021-04-18 13:02 So you encourage the misuse of TAG? I stopped using that since Delphi 1. ---------------------------------------------------------------------- Gustavo 'Gus' Carreno · 2021-04-18 17:25 Hey Jamie, Quote from: jamie on April 18, 2021, 02:46:54 pmTHe Ttimer has a TAG property … I'm really sorry Jamie but I have to agree with Thaddy!! The TTimer also has a property called Active that you can set to False on entry and True on exit, exactly to avoid reentry, right? Cheers, Gus ---------------------------------------------------------------------- jamie · 2021-04-18 18:35 Setting the Active timer on/off stops the sequence and thus involves interaction with the OS. With the Timer still operating, you can still use it for other things and keep it in sync. making it inactive and then active resets it and restarts etc. The loop of code that was presented here has a Application.ProcessMessages and that causes another re-entry effect. the poster can do as they wish, I've been down that path too many times. If you want sloppy timer action then I guess that is the root one can take... good luck.