361 views
in Platform Packages by

I am encountering a hard fault in EwReclaimMemory() while executing EwMarkObject( item->Object );

I am able to reproduce this issue. May be it sems to happen after I update variables from native code including also a string variable. It happes if I access the the cooking prorgam is a dedicated order: manually load LAST cooking program start and stop cooking cycle; power off device (last settings are stored); power on device (last settings are loaded); manually load first cooking program -> next Call to EwReclaimMemory() cause hard fault.

Is there a way to debug the garbage collection to get some information what actions can cause this issue?

this is the code which is may be cause the problem:

...

$if !$prototyper

var int32 i = 0;
var int32   NumPrograms       = 0;

for( i = 0; i < 10; i = i+1 ) { 

  var bool    ReadResult        = false;

  var string  Name              = "  ";
  var int32   StartDelayTime    = 0;
  var bool    HoldMode          = false;
  var int32   NumSteps          = 0;

  var SO_Application::Mode   Step_0_Mode       = SO_Application::Mode.Convection;
  var int32   Step_0_Temp_C     = 0;
  var int32   Step_0_Temp_F     = 0;
  var int32   Step_0_Time_min   = 0;

  var SO_Application::Mode   Step_1_Mode       = SO_Application::Mode.Convection;
  var int32   Step_1_Temp_C     = 0;
  var int32   Step_1_Temp_F     = 0;
  var int32   Step_1_Time_min   = 0;

  var SO_Application::Mode   Step_2_Mode       = SO_Application::Mode.Convection;
  var int32   Step_2_Temp_C     = 0;
  var int32   Step_2_Temp_F     = 0;
  var int32   Step_2_Time_min   = 0;

  var SO_Application::Mode   Step_3_Mode       = SO_Application::Mode.Convection;
  var int32   Step_3_Temp_C     = 0;
  var int32   Step_3_Temp_F     = 0;
  var int32   Step_3_Time_min   = 0;

  native ( NumPrograms, ReadResult, Name, StartDelayTime, HoldMode, NumSteps,
           Step_0_Mode, Step_0_Temp_C, Step_0_Temp_F, Step_0_Time_min,
           Step_1_Mode, Step_1_Temp_C, Step_1_Temp_F, Step_1_Time_min, 
           Step_2_Mode, Step_2_Temp_C, Step_2_Temp_F, Step_2_Time_min, 
           Step_3_Mode, Step_3_Temp_C, Step_3_Temp_F, Step_3_Time_min ) {

    CookingProgram_t Program;

    if( SO_DeviceDriver_ReadCookingProgram(i, &Program) ) {

      ReadResult = true;

      XString xName;

      xName = EwNewStringAnsi(Program.Name);

      Name           = xName;
      StartDelayTime = Program.u16_StartDelay_min;
      HoldMode       = Program.u8_HoldMode_EN;
      NumSteps       = Program.u8_NumCookingSteps;

      if( Program.u8_NumCookingSteps >= 1) {

        Step_0_Mode     = Program.Step[0].u8_Mode;
        Step_0_Temp_C   = Program.Step[0].u16_Temp_C;
        Step_0_Temp_F   = Program.Step[0].u16_Temp_F;
        Step_0_Time_min = Program.Step[0].u16_Time_min;
      }

      if( Program.u8_NumCookingSteps >= 2) {

        Step_1_Mode     = Program.Step[1].u8_Mode;
        Step_1_Temp_C   = Program.Step[1].u16_Temp_C;
        Step_1_Temp_F   = Program.Step[1].u16_Temp_F;
        Step_1_Time_min = Program.Step[1].u16_Time_min;
      }

      if( Program.u8_NumCookingSteps >= 3) {

        Step_2_Mode     = Program.Step[2].u8_Mode;
        Step_2_Temp_C   = Program.Step[2].u16_Temp_C;
        Step_2_Temp_F   = Program.Step[2].u16_Temp_F;
        Step_2_Time_min = Program.Step[2].u16_Time_min;
      }

      if( Program.u8_NumCookingSteps >= 4) {

        Step_3_Mode     = Program.Step[3].u8_Mode;
        Step_3_Temp_C   = Program.Step[3].u16_Temp_C;
        Step_3_Temp_F   = Program.Step[3].u16_Temp_F;
        Step_3_Time_min = Program.Step[3].u16_Time_min;
      }

    } // if SO_DeviceDriver_ReadCookingProgram

  }  // native


  // Cooking Porgram Mapping NVM <-> HMI
  // Cooking Programs: 0 to 9 
  // HMI Cooking Programs: 0. Actual Programs; 1 : Manual; 2 to 11 : Stored Programs


  if( ReadResult ) {

    // (i) ---> (i+2) to adapt to GUI index
    SO_Application::Device.CookingPrograms[i+2].Name            = Name;
    SO_Application::Device.CookingPrograms[i+2].StartDelay      = StartDelayTime;
    SO_Application::Device.CookingPrograms[i+2].HoldModeEnabled = HoldMode;
    SO_Application::Device.CookingPrograms[i+2].NumSteps        = NumSteps;

    SO_Application::Device.CookingPrograms[i+2].CookingSteps[0].Mode      = Step_0_Mode;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[0].Temp_C    = Step_0_Temp_C;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[0].Temp_F    = Step_0_Temp_F;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[0].Time_min  = Step_0_Time_min;

    SO_Application::Device.CookingPrograms[i+2].CookingSteps[1].Mode      = Step_1_Mode;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[1].Temp_C    = Step_1_Temp_C;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[1].Temp_F    = Step_1_Temp_F;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[1].Time_min  = Step_1_Time_min;

    SO_Application::Device.CookingPrograms[i+2].CookingSteps[2].Mode      = Step_2_Mode;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[2].Temp_C    = Step_2_Temp_C;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[2].Temp_F    = Step_2_Temp_F;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[2].Time_min  = Step_2_Time_min;

    SO_Application::Device.CookingPrograms[i+2].CookingSteps[3].Mode      = Step_3_Mode;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[3].Temp_C    = Step_3_Temp_C;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[3].Temp_F    = Step_3_Temp_F;
    SO_Application::Device.CookingPrograms[i+2].CookingSteps[3].Time_min  = Step_3_Time_min;

    NumPrograms = NumPrograms + 1;

  } 

} // for

...

Any help is apreciated

Best Regards
Jens
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->

 

1 Answer

0 votes
by
Hello Jens,

first of all, a couple of questions:

- What version of Embedded Wizard are you using, and which Platform Package?

- Do you get any error messages in advance on the console (via serial interface)?

- Does your native code keep references to Chora objects?

Thanks and best regards,

Manfred.
by
Hello Manfred,

- we are useing Embedded Wizard 8.00.

- I get some Messages lik this (clipped by my debug system): [ERROR in ..\src\Libraries\EmbeddedWizard\PlatformPackage\RTE\ewslot.c:454] 'postsignal' is failed. The signal is just d

- The only Reference I keep is     "SO_DeviceObject = EwGetAutoObject( &SO_ApplicationDevice, SO_ApplicationDeviceClass );"

Best Regards
Jens
by
Hello Jens,

difficult to say, what could be wrong...

According to error description, it is very likely, that memory is overwritten so that invalid references are evaluated during the garbage collection. This can happen, e.g. if the GUI application is accessed from another thread/task, if arrays or strings are written over their boundaries, etc.

Over the years, we have introduced several features to check the integrity of strings and the entire heap - but this was not available in Version 8.00.

I think the only chance is review / reduce the native code.

In case you are using the source code of the Platform Package it might be easier to detect the object - but often this is not so easy in case the heap is already corrupted.

Best regards,

Manfred.
by

Just one further remark: Please make sure that the entire GUI application is accessed only from one thread/task. See also Take care in multi-threading environments.

Ask Embedded Wizard - Archive

Welcome to the Ask Embedded Wizard archive. This community forum served us well for many years, but we've evolved our support approach!

Your resources:

The Embedded Wizard Online Documentation provides comprehensive documentation, tutorials, examples and ready-to-use software packages.

For dedicated assistance, explore our Embedded Wizard Product Support.

You can still browse the valuable discussions from our community history here.

Embedded Wizard Website | Privacy Policy | Imprint

...