https://bugs.kde.org/show_bug.cgi?id=513760
--- Comment #7 from [email protected] --- Maik, This is the analysis of Mistral AI on the relevant code from the backtrace. I think the recommendations are fine: // --------------------- Root Cause Analysis: The crash is triggered by a Qt assertion in qRound from qnumeric.h, specifically: ASSERT: "!std::isnan(value)" in file /usr/include/qt6/QtCore/qnumeric.h, line 501 Problem Breakdown: Direct Cause: The qRound function receives a NaN (Not a Number) value, which triggers a fatal assertion in Qt. This means one of the calculated values before the call to qRound is NaN. Source of NaN: The code calculates the following ratios: xThumbnailPercent and yThumbnailPercent: Ratios of the face region size to the image dimensions. xFaceAreaPercent and yFaceAreaPercent: Ratios of face coordinates (from faceEmbedding.first.at<float>(0, 2) and faceEmbedding.first.at<float>(0, 3)) to the thumbnail size. Critical Points: If package->info.dimensions().width() or package->info.dimensions().height() is zero, it causes a division by zero, resulting in NaN. If package->thumbnail.width() or package->thumbnail.height() is zero, the same issue occurs. If faceEmbedding.first.at<float>(0, 2) or faceEmbedding.first.at<float>(0, 3) is NaN or infinite, it can propagate NaN. Line 424: QSize faceSize(qRound(package->info.dimensions().width() * xThumbnailPercent * xFaceAreaPercent), qRound(package->info.dimensions().height() * yThumbnailPercent * yFaceAreaPercent)); If any of the calculated values (xThumbnailPercent, xFaceAreaPercent, etc.) is NaN, the call to qRound will fail. Proposed Solutions: 1. Check for Division by Zero Before calculating ratios, add checks to avoid division by zero: float width = static_cast<float>(package->info.dimensions().width()); float height = static_cast<float>(package->info.dimensions().height()); float thumbWidth = static_cast<float>(package->thumbnail.width()); float thumbHeight = static_cast<float>(package->thumbnail.height()); if (width <= 0 || height <= 0 || thumbWidth <= 0 || thumbHeight <= 0) { qWarning() << "Invalid dimensions or thumbnail size, skipping training check."; package->useForTraining = false; return; } 2. Check for NaN or Infinite Values Use std::isnan or std::isinf to detect invalid values in faceEmbedding: float xFacePos = faceEmbedding.first.at<float>(0, 2); float yFacePos = faceEmbedding.first.at<float>(0, 3); if (std::isnan(xFacePos) || std::isnan(yFacePos) || std::isinf(xFacePos) || std::isinf(yFacePos)) { qWarning() << "Invalid face embedding values, skipping training check."; package->useForTraining = false; return; } 3. Additional Debugging Log Values: Add logs to display the values of package->info.dimensions(), package->thumbnail, and faceEmbedding before calculations. This will help identify which value is invalid. Validate Input Data: Ensure the data passed to FacePipelineBase is valid (e.g., images and metadata are not corrupted). Summary of Recommended Actions: Add checks to prevent division by zero and NaN/inf values. Log values to pinpoint the source of the issue. Validate input data before using it in calculations. If the issue persists, check if the bug is reproducible with other images or if specific images consistently trigger the crash. This could indicate a problem with the generation of faceEmbedding data or image metadata. // --------------- Gilles -- You are receiving this mail because: You are watching all bug changes.
