Skip to content

[BUG] gst-nvtracker: uninitialised pShadowTrackBatch passed to the tracker library when the user meta pool is empty #122

Open

Description

@TheGoncaloSilva

Describe the bug
In NvTrackerProc::processBatch() and processSubBatch(), miscDataResult is declared without initialisation (nvtracker_proc.cpp#L2512, #L2902). When m_MiscDataMgr.pop() returns no buffer, the else branch resets pPastFrameObjBatch, pTerminatedTrackBatch and pReidTensorBatch, but not pShadowTrackBatch (#L2527-L2531, #L2910-L2914):

NvMOTTrackerMiscData miscDataResult;          // not initialised
if (pMiscDataBuf) { /* all pointers set */ }
else
{
  miscDataResult.pPastFrameObjBatch = nullptr;
  procResult.pReidTensorBatch = nullptr;
  miscDataResult.pTerminatedTrackBatch = nullptr;
  // pShadowTrackBatch keeps whatever was on the stack
}

The tracker library then treats any non-null pointer as valid and writes shadow-track output through it (context.cpp#L280):

if(pTrackerMiscData && pTrackerMiscData->pShadowTrackBatch)
    m_pLocalizer->outputShadowObj(videoStreamIdList, pTrackerMiscData->pShadowTrackBatch);

The result is a write through an indeterminate pointer: silent memory corruption or a crash far from the cause.

The "Unable to acquire a user meta buffer" warning is only printed when pastFrame or outputReidTensor is on, so with only shadow-track output enabled, pool exhaustion is not logged at all.

Related, smaller: TrackerMiscDataManager never sets numAllocated on the per-target past-frame and shadow-track lists (miscdatabufmanager.cpp#L109, #L297); terminated-track lists do set it (#L216-L217). The library does not read it today, but the field is public in NvDsTargetMiscDataObject, so applications reading this metadata get an indeterminate capacity.

Steps/Code to reproduce bug
Found by code review; no deterministic reproduction, because the outcome depends on stack contents. The path is reached by any nvtracker pipeline with shadow-track output enabled (TargetManagement.outputShadowTracks: 1) and a user meta pool that runs empty, e.g. user-meta-pool-size=1 (default 32) with a slow downstream that holds the user meta. A debug build of the plugin under valgrind (--track-origins=yes) or MemorySanitizer should then report the uninitialised pShadowTrackBatch.

Expected behavior
When no misc data buffer is available, every output pointer passed to the library is nullptr.

Fix is on my fork:

Summary of the change:

-      NvMOTTrackerMiscData miscDataResult;
+      NvMOTTrackerMiscData miscDataResult = {};
 ...
         miscDataResult.pTerminatedTrackBatch = nullptr;
+        miscDataResult.pShadowTrackBatch = nullptr;

(in both processBatch() and processSubBatch()), plus objList.numAllocated = maxShadowTrackingAge; / = 1; in allocatePastFrame() / allocateShadowTracks().

Environment details (please complete the following information):

  • Environment location: Docker on bare-metal Jetson Orin, JetPack 6.2 (L4T R36.4.7)
  • Method of DeepStream install: Docker (nvcr.io/nvidia/deepstream:7.1-triton-multiarch)
  • scripts/print_env.sh: not run. Found by reading the DeepStream 7.1 SDK sources (sources/gst-plugins/gst-nvtracker/nvtracker_proc.cpp); the same code is on develop (3091168).

Activity

  1. added
    bug
    on Nov 15, 2026
  2. added a commit that references this issue on Nov 15, 2026
    bf1618a
  3. kevinsongbing commented on Nov 17, 2026

    @kevinsongbing
    Collaborator

    Seems reasonable, we will check and feedback later.

  4. kevinsongbing commented on Nov 18, 2026

    @kevinsongbing
    Collaborator
  5. added a commit that references this issue on Nov 18, 2026
    c69617b
  6. TheGoncaloSilva commented on Nov 18, 2026

    @TheGoncaloSilva
    Author

    Not in practice. We found it while tracking down the heap corruption in #121, which turned out to be the real cause of our crashes. We run with shadow-track output enabled and the default user meta pool size, and have never seen the pool run empty, so we have never hit this path.

    It's a small, low-risk fix, but I understand if it gets lower priority. As with #121, I can't open a pull request, since i'm not a collaborator. The branch is rebased on the current develop (dfcc4e7), with a Conventional Commit and sign-off:

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

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions