How to debug attribute list reconciliation failures

Please provide the following info (tick the boxes after creating this topic):
Software Version
DRIVE OS 6.0.10.0
DRIVE OS 6.0.8.1
DRIVE OS 6.0.6
DRIVE OS 6.0.5
DRIVE OS 6.0.4 (rev. 1)
DRIVE OS 6.0.4 SDK
other

Target Operating System
Linux
QNX
other

Hardware Platform
DRIVE AGX Orin Developer Kit (940-63710-0010-300)
DRIVE AGX Orin Developer Kit (940-63710-0010-200)
DRIVE AGX Orin Developer Kit (940-63710-0010-100)
DRIVE AGX Orin Developer Kit (940-63710-0010-D00)
DRIVE AGX Orin Developer Kit (940-63710-0010-C00)
DRIVE AGX Orin Developer Kit (not sure its number)
other

SDK Manager Version
2.1.0
other

Host Machine Version
native Ubuntu Linux 20.04 Host installed with SDK Manager
native Ubuntu Linux 20.04 Host installed with DRIVE OS Docker Containers
native Ubuntu Linux 18.04 Host installed with DRIVE OS Docker Containers
other

Issue Description
I’m trying to reconcile a simple image buffer for test purposes. I’ve followed the iep sample application mainly and the documentation online. I’ve only set the “mandatory” keys that were listed.

NvSciBufType buffer_type = NvSciBufType_Image;
// image buffer type specific attributes
// layout
NvSciBufAttrValImageLayoutType image_layout = NvSciBufImage_BlockLinearType;
// number of planes
// images are either in Surface or plane based format
int plane_count = 2;
static const int NV_SCI_BUF_IMAGE_MAX_PLANES = 3;
NvSciBufAttrValColorFmt colorFormat[NV_SCI_BUF_IMAGE_MAX_PLANES];
colorFormat[0] = NvSciColor_Y8;
colorFormat[1] = NvSciColor_U8;
colorFormat[2] = NvSciColor_V8;

u_int32_t image_width = 3840;
u_int32_t image_height = 2160;
u_int32_t plane_width[NV_SCI_BUF_IMAGE_MAX_PLANES] = {0, 0, 0};
u_int32_t plane_height[NV_SCI_BUF_IMAGE_MAX_PLANES] = {0, 0, 0};
plane_width[0] = image_width;
plane_height[0] = image_height;
plane_width[1] = image_width >> 1;
plane_height[1] = image_height >> 1;
plane_height[2] = plane_height[1];
plane_width[2] = plane_width[1];

NvSciBufAttrValImageScanType scanType = NvSciBufScan_ProgressiveType;

NvSciBufAttrKeyValuePair attributes = {
{NvSciBufGeneralAttrKey_Types, &buffer_type, sizeof(buffer_type)},
{NvSciBufImageAttrKey_Layout, &image_layout, sizeof(image_layout)},
{NvSciBufImageAttrKey_PlaneCount, &plane_count, sizeof(plane_count)},
{NvSciBufImageAttrKey_PlaneColorFormat, &colorFormat,
sizeof(colorFormat)},
{NvSciBufImageAttrKey_PlaneWidth, plane_width, sizeof(plane_width)},
{NvSciBufImageAttrKey_PlaneHeight, plane_height, sizeof(plane_height)},
{NvSciBufImageAttrKey_PlaneScanType, &scanType, sizeof(scanType)},
};

Error String
I get an reconciliation error.

E20250204 02:25:56.823077 449068 main.cc:107] Failed to reconcile attribute list with error:65792

65792 is NvSciError_ReconciliationFailed.

The main thing I’m wondering is how am I supposed to go about debugging this. I’ve seen suggestions in Issue Reconciling Buffer attribute lists for NvSci. But I’m confused as well how if I get a list of attributes (NvSciBufAttrListGetAttrs) how am I supposed to go about reading them. Also when I tried to use a generic array, I would get parameter failure.

NvSciBufAttrKeyValuePair array[50];
NvSciBufAttrListGetAttrs(newConflictList, array, 50);

So I reused my input NvSciBufAttrKeyValuePair to NvSciBufAttrListSetAttrs, and that returns okay. Now I’m not sure how this NvSciBufAttrKeyValuePair is supposed to be parsed for incorrect values.

Dear @shzhao,
Could you please share repro code and steps?

int main() {
// initialize an IEP context
NvMediaIEP* context = init();

// create a scibuf module
NvSciBufModule module = NULL;
if (NvSciBufModuleOpen(&module) != NvSciError_Success) {
LOG(ERROR) << "Failed to initialize NvSciBufModule with error: "
<< NvSciError_Success;
return -1;
}
LOG(INFO) << “NvSciBufModule initialized successfully”;

// create the attribute list
NvSciBufAttrList attrList;
if (NvSciBufAttrListCreate(module, &attrList) != NvSciError_Success) {
LOG(ERROR) << “Failed to create attribute list with error:”
<< NvSciError_Success;
return -1;
}
LOG(INFO) << “Attribute list created successfully”;

// fill in the attribute list
if (!good_status(NvMediaIEPFillNvSciBufAttrList(NVMEDIA_ENCODER_INSTANCE_0,
attrList))) {
return -1;
}

// set the key-value pairs for buffer attribute list

// buffer type
NvSciBufType buffer_type = NvSciBufType_Image;
// image buffer type specific attributes
// layout
NvSciBufAttrValImageLayoutType image_layout = NvSciBufImage_BlockLinearType;
// number of planes
// images are either in Surface or plane based format
int plane_count = 2; // 1 plane is Y and luma only, 2 plane is Y + UV
// Color format is defined based the on the image format of the YUV file
// This is the color format for IYUV or YUV420P
static const int NV_SCI_BUF_IMAGE_MAX_PLANES = 3;
NvSciBufAttrValColorFmt colorFormat[NV_SCI_BUF_IMAGE_MAX_PLANES];
colorFormat[0] = NvSciColor_Y8;
colorFormat[1] = NvSciColor_U8;
colorFormat[2] = NvSciColor_V8;

// For 420 plane formats, width and height are halved for the U and the V
// plane, this is by definition of the format
u_int32_t image_width = 3840;
u_int32_t image_height = 2160;
u_int32_t plane_width[NV_SCI_BUF_IMAGE_MAX_PLANES] = {0, 0, 0};
u_int32_t plane_height[NV_SCI_BUF_IMAGE_MAX_PLANES] = {0, 0, 0};
plane_width[0] = image_width;
plane_height[0] = image_height;
plane_width[1] = image_width >> 1;
plane_height[1] = image_height >> 1;
plane_height[2] = plane_height[1];
plane_width[2] = plane_width[1];

// Plane Scan type, not sure why its set to progressive and what the
// difference is
NvSciBufAttrValImageScanType scanType = NvSciBufScan_ProgressiveType;

// attributes not set
// NvSciBufAttrValColorStd lumaColorStd = NvSciColorStd_BT601;

NvSciBufAttrKeyValuePair attributes = {
{NvSciBufGeneralAttrKey_Types, &buffer_type, sizeof(buffer_type)},
{NvSciBufImageAttrKey_Layout, &image_layout, sizeof(image_layout)},
{NvSciBufImageAttrKey_PlaneCount, &plane_count, sizeof(plane_count)},
{NvSciBufImageAttrKey_PlaneColorFormat, &colorFormat,
sizeof(colorFormat)},
{NvSciBufImageAttrKey_PlaneWidth, plane_width, sizeof(plane_width)},
{NvSciBufImageAttrKey_PlaneHeight, plane_height, sizeof(plane_height)},
{NvSciBufImageAttrKey_PlaneScanType, &scanType, sizeof(scanType)},
};
u_int32_t attributes_count =
sizeof(attributes) / sizeof(NvSciBufAttrKeyValuePair);
NvSciError sci_status =
NvSciBufAttrListSetAttrs(attrList, attributes, attributes_count);
if (sci_status != NvSciError_Success) {
LOG(ERROR) << “Failed to set attribute keys correctly with error:”
<< sci_status;
return -1;
};
LOG(INFO) << “Attribute list set successfully”;

// Reconcile the attribute list
NvSciBufAttrList reconciledAttrList;
NvSciBufAttrList conflictAttrList;
sci_status = NvSciBufAttrListReconcile(&attrList, 1U, &reconciledAttrList,
&conflictAttrList);
if (sci_status != NvSciError_Success) {
LOG(ERROR) << “Failed to reconcile attribute list with error:”
<< sci_status;
if (sci_status == 65792) { // reconcilation failed
process_conflict_attr_list(&conflictAttrList, attributes,
attributes_count);
}
return -1;
}

// Create a buffer
NvSciBufObj sci_buf_obj;
sci_status = NvSciBufObjAlloc(reconciledAttrList, &sci_buf_obj);
if (sci_status != NvSciError_Success) {
LOG(ERROR) << “Failed to allocate buffer with error:” << sci_status;
return -1;
}
}

I fixed the issue, which has to do with using the size of the array when my plane count is 2, but my array has 3 elements.

{NvSciBufImageAttrKey_PlaneWidth, plane_width, sizeof(plane_width)}, → sizeof(u_int32_t) * plane_count)

I’m still confused for generic debugging how I would have found this out. If I run “NvSciBufAttrListGetAttrs” on the same attributes key pairs used for reconciliation, how would I have found out that the issue is my plane count is wrong.