Recent

Author Topic: strange errorors  (Read 1720 times)

berghem

  • Jr. Member
  • **
  • Posts: 60
strange errorors
« on: April 17, 2021, 08:56:53 pm »
Hi all
in my software I have two stange errors in external library I know where are the errors....

Can you help me?
« Last Edit: April 17, 2021, 08:59:35 pm by berghem »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: strange errorors
« Reply #1 on: April 17, 2021, 09:15:49 pm »
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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
Re: strange errorors
« Reply #2 on: April 17, 2021, 09:34:37 pm »
Hey Mark,

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.

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
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: strange errorors
« Reply #3 on: April 17, 2021, 09:48:06 pm »
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!!

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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

berghem

  • Jr. Member
  • **
  • Posts: 60
Re: strange errorors
« Reply #4 on: April 17, 2021, 09:49:11 pm »
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

  • Hero Member
  • *****
  • Posts: 6090
Re: strange errorors
« Reply #5 on: April 18, 2021, 12:26:25 am »
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 .
« Last Edit: April 18, 2021, 12:37:40 am by jamie »
The only true wisdom is knowing you know nothing

berghem

  • Jr. Member
  • **
  • Posts: 60
Re: strange errorors
« Reply #6 on: April 18, 2021, 10:56:39 am »
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('<br> 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

  • Hero Member
  • *****
  • Posts: 1038
Re: strange errorors
« Reply #7 on: April 18, 2021, 12:08:32 pm »
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?
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: strange errorors
« Reply #8 on: April 18, 2021, 12:14:17 pm »
Code still doesn't help much. What is the type of poStep, poMash variables?
It is a set.
Errorors does not help: errors.
Specialize a type, not a var.

alpine

  • Hero Member
  • *****
  • Posts: 1038
Re: strange errorors
« Reply #9 on: April 18, 2021, 12:42:03 pm »
It 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  :)
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: strange errorors
« Reply #10 on: April 18, 2021, 02:46:54 pm »
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
The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 14201
  • Probably until I exterminate Putin.
Re: strange errorors
« Reply #11 on: April 18, 2021, 03:02:53 pm »
So you encourage the misuse of TAG? I stopped using that since Delphi 1.  :P :-X
Specialize a type, not a var.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1111
  • Professional amateur ;-P
Re: strange errorors
« Reply #12 on: April 18, 2021, 07:25:15 pm »
Hey Jamie,

THe 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
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: strange errorors
« Reply #13 on: April 18, 2021, 08:35:02 pm »
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.

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018