Safety Error Recorder#

class SafetyErrorRecorder : public nvinfer2::safe::ISafeRecorder#

Fixed-capacity runtime recorder with optional fatal-error forwarding.

Retained diagnostics, their count, and overflow state are protected by one mutex. The callback and context are borrowed for the recorder lifetime, and the callback executes only after the diagnostics mutex is released.

Public Functions

SafetyErrorRecorder(
DliErrorCallback callback,
void *context
) noexcept#

Construct an empty recorder.

Parameters:
  • callback – Optional no-throw error sink; nullptr disables runtime forwarding.

  • context – Borrowed callback context; may be nullptr when callback is nullptr.

~SafetyErrorRecorder() noexcept = default#
int32_t getNbErrors() const noexcept override#

Return the retained diagnostic count.

Returns:

A thread-safe count between zero and kMAX_DLI_ERRORS.

nvinfer1::ErrorCode getErrorCode(
int32_t errorIdx
) const noexcept override#

Return a retained TensorRT error code.

Parameters:

errorIdx – Zero-based retained diagnostic index.

Returns:

The stored code, or kUNSPECIFIED_ERROR for an invalid index.

ErrorDesc getErrorDesc(int32_t errorIdx) const noexcept override#

Return recorder-owned diagnostic text.

Parameters:

errorIdx – Zero-based retained diagnostic index.

Returns:

The retained slot, or an empty string for an invalid index. The SDK pointer must not be retained across clear() followed by slot reuse.

bool copyErrorDescription(
int32_t errorIdx,
DliDescription &destination
) const noexcept#

Copy one diagnostic while holding the recorder lock.

Parameters:
  • errorIdx – Zero-based retained diagnostic index.

  • destination – Caller-owned fixed storage that remains stable after this call.

Returns:

True when errorIdx selected a retained diagnostic; otherwise destination is empty.

bool hasOverflowed() const noexcept override#

Determine whether at least one diagnostic was dropped.

Returns:

True after fixed diagnostic storage has overflowed and until clear() is called.

void clear() noexcept override#

Clear retained diagnostic bookkeeping without changing refcount or runtime terminal state.

bool reportError(
nvinfer1::ErrorCode code,
ErrorDesc description
) noexcept override#

Retain and forward one TensorRT error.

Parameters:
  • code – TensorRT error classification.

  • description – Diagnostic text valid for the duration of this call.

Returns:

Always true because every DLI error is fatal to the affected operation.

RefCount incRefCount() noexcept override#

Acquire one borrowed recorder reference.

Returns:

The incremented reference count.

RefCount decRefCount() noexcept override#

Release one borrowed recorder reference without deleting the recorder.

Returns:

The decremented count, or zero after reporting an attempted underflow.

RefCount referenceCount() const noexcept#

Snapshot the current borrower count.

Returns:

The current nonnegative reference count.

struct RecordedDliError#

One fixed-storage TensorRT diagnostic retained by SafetyErrorRecorder.

Public Members

nvinfer1::ErrorCode code = {nvinfer1::ErrorCode::kSUCCESS}#

Owned TensorRT error code.

DliDescription description = {}#

Owned, NUL-terminated diagnostic text.