Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test Failed] DEM_TC_2_6 Device crashes. #34954

Closed
jadhavrohit924 opened this issue Aug 13, 2024 · 2 comments · Fixed by #35067
Closed

[Test Failed] DEM_TC_2_6 Device crashes. #34954

jadhavrohit924 opened this issue Aug 13, 2024 · 2 comments · Fixed by #35067

Comments

@jadhavrohit924
Copy link
Contributor

Test issue(s)

Device crashes at TH step for Test DEM_TC_2_6
Executing Test Step: TH sends ModifyForecastRequest with ForecastID=Forecast.ForecastID+1, SlotAdjustments[0].{SlotIndex=0, Duration=Forecast.Slots[0].MaxDurationAdjustment}, Cause=GridOptimization.

Platform

No response

Anything else?

DEM2-6_2024_08_13_13_45_15.log
device.txt

@jamesharrow
Copy link
Contributor

There is a bounds check failure on the slots (although it checks the length it should use >= not just >).

A second crash then occurs which is because there is no check on the optional .HasValue() before using the value.

In fixing both of these however the test script bombs out with a check on the error being Failure but it returns a Constraint error. So needs a proper look at this code since the test case is not including a nominal power in the adjustmentSlot structure.

This was the patch that stops it from crashing.

+++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp
@@ -676,7 +676,7 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands:
         const Structs::SlotAdjustmentStruct::Type & slotAdjustment = iterator.GetValue();
 
         // Check for an invalid slotIndex
-        if (slotAdjustment.slotIndex > forecast.Value().slots.size())
+        if (slotAdjustment.slotIndex >= forecast.Value().slots.size())
         {
             ChipLogError(Zcl, "DEM: Bad slot index %d", slotAdjustment.slotIndex);
             ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure);
@@ -697,6 +697,7 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands:
         if (HasFeature(Feature::kPowerForecastReporting))
         {
             if (!slot.minPowerAdjustment.HasValue() || !slot.maxPowerAdjustment.HasValue() ||
+                !slotAdjustment.nominalPower.HasValue() || 
                 slotAdjustment.nominalPower.Value() < slot.minPowerAdjustment.Value() ||
                 slotAdjustment.nominalPower.Value() > slot.maxPowerAdjustment.Value())
             {

@PeterC1965
Copy link
Contributor

Test 2.6 might being run on the ESP32 with both kPowerForecastReporting and kStateForecastReporting set when it should only be run with kStateForecastReporting (they are mutually exclusive flags). When I run the Linux test with both of these set, I see the same fail in test step 4.

I'll update the test plan + scripts to check for this and fail straightaway if they see this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants