BUG: Preserve execution warnings when a filter is cancelled

Đang mở Phù hợp với người mới
#1,987 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 6 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
backend

Hướng nghiên cứu

Đọc src/simplnx/Filter/IFilter.cpp, đặc biệt là nhánh hủy trong IFilter::execute, và các fixture hiện có trong test/FilterTest.cpp. Thêm một kiểm thử hồi quy sử dụng các cảnh báo preflight và thực thi đã mô tả, sau đó cập nhật kết quả hủy để giữ lại cả hai danh sách cảnh báo và các giá trị đầu ra preflight, đồng thời bảo toàn các lỗi thực thi. Biên dịch simplnx_test và chạy trường hợp CTest được chỉ định; hoàn tất khi có lỗi hủy và cả hai cảnh báo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

Problem

When a filter requests cancellation during execution and returns a valid result with a warning, IFilter::execute reports cancellation and loses the execution warning. The result should contain the cancellation error and warnings from both preflight and execution.

This occurred in a Windows MSVC Release test linked against simplnx 44875faf4e349cf2004fc69fcef3ab1f308aa995. The affected IFilter.cpp is identical at the develop base 8cad1e818a6517eb933a85d1654bb4415a6396d6.

Steps to Reproduce

  1. Use a filter that returns one warning from preflight and a different warning from execution.
  2. Have the filter set the caller's cancellation flag immediately before it returns the valid execution result.
  3. Call the public IFilter::execute entry point. It returns cancellation error -1 and only the preflight warning.

Cause

The cancellation branch returns before the normal merge of the preflight and execution results. Its merge uses only the preflight result and the cancellation error. Cancellation branch in IFilter::execute

if(shouldCancel && executeImplResult.valid())
{
  return ExecuteResult{MergeResults(std::move(preflightActionsResult), MakeErrorResult(-1, "Filter cancelled")), std::move(preflightResult.outputValues)};
}

Verification Unit Test

Add the following to test/FilterTest.cpp. It uses the existing BackstopFilterBase and k_PreflightWarningCode. Build simplnx_test, then run ctest -C Release -j 1 -R "^IFilter: Cancellation preserves execution warnings$" --output-on-failure --no-tests=error from the configured build directory.

namespace
{
class CancelAfterWarningFilter : public BackstopFilterBase<CancelAfterWarningFilter>
{
public:
  static inline constexpr StringLiteral k_FilterName = "CancelAfterWarningFilter";
  static inline constexpr StringLiteral k_FilterUuid = "784f2751-bc9d-4d53-b610-1d36e26bb5f4";
  static inline constexpr int32 k_ExecutionWarningCode = -9980;

  std::atomic_bool* cancelFlag = nullptr;

protected:
  PreflightResult preflightImpl(const DataStructure&, const Arguments&, const MessageHandler&, const std::atomic_bool&, const ExecutionContext&) const override
  {
    Result<OutputActions> result;
    result.warnings().push_back(Warning{k_PreflightWarningCode, "The controlled preflight warning"});
    return {std::move(result)};
  }

  Result<> executeImpl(DataStructure&, const Arguments&, const PipelineFilter*, const MessageHandler&, const std::atomic_bool&, const ExecutionContext&) const override
  {
    cancelFlag->store(true);
    return MakeWarningVoidResult(k_ExecutionWarningCode, "The controlled execution warning");
  }
};
} // namespace

TEST_CASE("IFilter: Cancellation preserves execution warnings", "[simplnx][IFilter]")
{
  std::atomic_bool shouldCancel = false;
  CancelAfterWarningFilter filter;
  filter.cancelFlag = &shouldCancel;
  DataStructure dataStructure;
  const Arguments args;

  const auto execution = filter.execute(dataStructure, args, nullptr, {}, shouldCancel);
  REQUIRE(shouldCancel.load());
  REQUIRE(execution.result.invalid());
  REQUIRE(execution.result.errors().front().code == -1);
  const auto& warnings = execution.result.warnings();
  REQUIRE_FALSE(warnings.empty());
  CHECK(warnings.front().code == k_PreflightWarningCode);
  REQUIRE(warnings.size() == 2);
  CHECK(warnings[1].code == CancelAfterWarningFilter::k_ExecutionWarningCode);
}

The test was compiled with the existing Catch2 fixtures and run through CTest in an isolated test harness. The cancellation code and preflight warning checks passed. The warning count failed with 1 == 2. The existing test that checks execution-error precedence over cancellation passed in the same harness.

Proposed Fix

In IFilter::execute, combine the preflight and execution results before adding the cancellation error. Preserve both warning lists and the preflight output values. If execution already returned an error, keep that error as the reported failure.

Notes

This is the shared wrapper follow-up identified in the simplnx #1888 review. It applies to any filter that returns warnings when cancellation is set during execution.

Ngôn ngữ chính
C++
Star
18
Fork
15
Merge trung bình
4 ngày 23 giờ
Pull request đã merge (30 ngày)
42

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của BlueQuartzSoftware/simplnx

Tất cả issue của BlueQuartzSoftware/simplnx

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.