Repository navigation
Description
Describe the bug
When the first source that nvmultiurisrcbin gets is a file it cannot decode (here a zero-byte file), the pipeline does not recover after that source is removed. A good clip added next gets a 200 answer and an added message, but it gives only 4 of its 30 frames, the element never posts its removed message, and a REST remove of the clip gets no answer.
The add and the REST remove of the bad file both answer 200. The element posts an added message for it at once, and its removed message only after the REST remove. The only sign of the failure is the typefind ERROR lines on stderr ("Stream contains no data"); no error reaches Python (see #98).
The same good clip as the first source plays all 30 frames and ends with its removed message.
#111 is related: there too the pipeline stays dead after a source is removed and a later source gives no frames, but the trigger is the removal of the last RTSP source. Dropping empty batches at the element's output, as advised in #111, does not prevent it: with that probe added, 2 of 3 runs ended the same way.
Steps/Code to reproduce bug
Make a zero-byte file and a 1 s clip (30 frames) from the image's sample stream. The image has no ffmpeg, so this runs on the host:
: > zero.mp4
docker run --rm --entrypoint cat ghcr.io/nvidia/deepstream:9.2-triton-multiarch \
/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.mp4 > sample_720p.mp4
ffmpeg -v error -i sample_720p.mp4 -frames:v 30 -an -c:v libx264 -g 30 clip_1s.mp4Save as repro_bad_first_source.py. The pipeline is nvmultiurisrcbin (no sources at start, live-source=0) and fakesink, with a frame counter on the src pad of nvmultiurisrcbin. bad adds the zero-byte file, removes it by REST after 6 s, then adds the clip. control adds only the clip. The script waits 15 s for the clip's removed message and removes the clip by REST when none came. Each REST call times out after 30 s.
import json
import os
import sys
import threading
import time
import urllib.error
import urllib.request
from pyservicemaker import BatchMetadataOperator, DynamicSourceMessage, Pipeline, Probe
PORT = 9600
OPENER = urllib.request.build_opener(urllib.request.ProxyHandler({}))
T0 = time.monotonic()
frames = 0
removed = set()
def log(what):
print(f"{time.monotonic() - T0:7.2f} s {what} (frames so far: {frames})", flush=True)
class Count(BatchMetadataOperator):
def handle_metadata(self, batch_meta):
global frames
frames += sum(1 for _ in batch_meta.frame_items)
def on_message(message):
if isinstance(message, DynamicSourceMessage):
log(f"message: source {message.source_id} ({message.sensor_id}) added={message.source_added}")
if not message.source_added:
removed.add(message.sensor_id)
def post(verb, camera, path):
"""POST an add or remove; return the HTTP status, or 'no answer' after 30 s."""
value = {"camera_id": camera, "camera_name": camera, "camera_url": f"file://{path}", "change": f"camera_{verb}"}
body = json.dumps({"key": "sensor", "value": value}).encode()
request = urllib.request.Request(f"http://127.0.0.1:{PORT}/api/v1/stream/{verb}", data=body, method="POST")
started = time.monotonic()
for _ in range(80): # the REST server needs a moment after start
try:
with OPENER.open(request, timeout=30) as response:
return f"{response.status} after {time.monotonic() - started:.3f} s"
except urllib.error.HTTPError as error:
if error.code != 404:
return f"{error.code} after {time.monotonic() - started:.3f} s"
except TimeoutError:
return f"no answer within {time.monotonic() - started:.0f} s"
except urllib.error.URLError as error:
if isinstance(error.reason, TimeoutError):
return f"no answer within {time.monotonic() - started:.0f} s"
time.sleep(0.25)
return "REST server not up"
def play_good(path):
before = frames
log(f"add good: {post('add', 'good', path)}")
deadline = time.monotonic() + 15
while "good" not in removed and time.monotonic() < deadline:
time.sleep(0.05)
time.sleep(0.5)
log(f"good clip: {frames - before} frames, removed message: {'good' in removed}")
if "good" not in removed:
log(f"remove good: {post('remove', 'good', path)}")
mode, bad_path, good_path = sys.argv[1], sys.argv[2], sys.argv[3]
pipeline = Pipeline("bad-first-source")
pipeline.add("nvmultiurisrcbin", "src", {
"ip-address": "127.0.0.1", "port": str(PORT), "max-batch-size": 4, "width": 1280, "height": 720,
"live-source": False, "drop-pipeline-eos": True, "batched-push-timeout": 33333,
})
pipeline.add("fakesink", "sink", {"sync": False})
pipeline.link("src", "sink")
pipeline.attach("src", Probe("count", Count()))
pipeline.start(on_message)
threading.Thread(target=pipeline.wait, daemon=True).start()
if mode == "bad":
log(f"add bad: {post('add', 'bad', bad_path)}")
time.sleep(6)
log(f"remove bad: {post('remove', 'bad', bad_path)}")
time.sleep(2)
play_good(good_path)
os._exit(0) # the pipeline never ends by itself (drop-pipeline-eos), so leave at onceRun it in the stock container (pyyaml is installed first because import pyservicemaker needs it, see #98):
docker run --rm --gpus all -v "$PWD":/repro --entrypoint bash ghcr.io/nvidia/deepstream:9.2-triton-multiarch \
-c "pip install -q --break-system-packages pyyaml && \
python3 /repro/repro_bad_first_source.py bad /repro/zero.mp4 /repro/clip_1s.mp4"bad prints:
0.74 s message: source 0 (bad) added=True (frames so far: 0)
0.74 s add bad: 200 after 0.257 s (frames so far: 0)
6.74 s message: source 0 (bad) added=False (frames so far: 0)
6.74 s remove bad: 200 after 0.002 s (frames so far: 0)
8.74 s message: source 1 (good) added=True (frames so far: 0)
8.74 s add good: 200 after 0.002 s (frames so far: 0)
24.27 s good clip: 4 frames, removed message: False (frames so far: 4)
54.31 s remove good: no answer within 30 s (frames so far: 4)
and on stderr, between the first add and the remove:
new stream added [0:bad:bad]
nvmultiurisrcbin ERROR from element typefind: Stream contains no data.
ERROR from typefind: Stream contains no data.
nvmultiurisrcbin ERROR from element typefind: Internal data stream error.
Debug info: ../plugins/elements/gsttypefindelement.c(1154): gst_type_find_element_loop (): /GstPipeline:bad-first-source/GstDsNvMultiUriBin:src/GstBin:src_creator/GstDsNvUriSrcBin:dsnvurisrcbin0/GstURIDecodeBin:nvurisrc_bin_src_elem/GstDecodeBin:decodebin0/GstTypeFindElement:typefind:
Can't typefind empty stream
ERROR from typefind: Internal data stream error.
Debug info: ../plugins/elements/gsttypefindelement.c(1257): gst_type_find_element_loop (): /GstPipeline:bad-first-source/GstDsNvMultiUriBin:src/GstBin:src_creator/GstDsNvUriSrcBin:dsnvurisrcbin0/GstURIDecodeBin:nvurisrc_bin_src_elem/GstDecodeBin:decodebin0/GstTypeFindElement:typefind:
streaming stopped, reason error (-5)
new stream removed [0:bad]
new stream added [1:good:good]
Opening in BLOCKING MODE
uri:/api/v1/stream/remove
method:POST
Nothing more is printed after the clip's REST remove. The clip gets source id 1, although id 0 was released by the removed message before.
control (python3 /repro/repro_bad_first_source.py control /repro/zero.mp4 /repro/clip_1s.mp4) prints:
0.90 s add good: 200 after 0.256 s (frames so far: 0)
0.90 s message: source 0 (good) added=True (frames so far: 0)
1.16 s message: source 0 (good) added=False (frames so far: 30)
1.70 s good clip: 30 frames, removed message: True (frames so far: 30)
bad gave the same result in 3 of 3 runs (4 frames, no removed message, no answer to the remove), and control gave 30 of 30 frames and the removed message in 3 of 3 runs.
Expected behavior
- After the bad first source is removed, the element is in the same state as one started with no sources, and a good file added next plays all its frames and ends with its removed message, as in
control. - Every REST call answers.
- A source that fails to open is reported to the application (for example as a removed message or an error message for its source id) instead of holding its slot without a sign.
Environment details
- Environment location: Docker on bare-metal (Ubuntu 26.04.1 LTS host, kernel 7.0.0-43, NVIDIA RTX A4000 Laptop GPU 8 GB, driver 615.71.09)
- Method of DeepStream install: Docker,
ghcr.io/nvidia/deepstream:9.2-triton-multiarch(digestsha256:94a49674eb475f0416ce49742430cfbd644258b4e6512b09c76ddd90164c6dc7), DeepStream 9.2.0, pyservicemaker 0.0.1, TensorRT 10.16.0.72, CUDA 13.2 - Docker command: see the steps above
scripts/print_env.shoutput, run inside the same container:
Click here to see environment details
**git*** Not inside a git repository ***OS Information*** DISTRIB_ID=Ubuntu DISTRIB_RELEASE=24.04 DISTRIB_CODENAME=noble DISTRIB_DESCRIPTION="Ubuntu 24.04.4 LTS" PRETTY_NAME="Ubuntu 24.04.4 LTS" NAME="Ubuntu" VERSION_ID="24.04" VERSION="24.04.4 LTS (Noble Numbat)" VERSION_CODENAME=noble ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=noble LOGO=ubuntu-logo Linux 9616c69d590b 7.0.0-43-generic #43-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 23 13:25:25 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux ***GPU Information*** Mon Nov 16 13:48:45 2026 +-----------------------------------------------------------------------------------------+ | NVIDIA-SMI 615.71.09 KMD Version: 615.71.09 CUDA UMD Version: 13.4 | +-----------------------------------------+------------------------+----------------------+ | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+========================+======================| | 0 NVIDIA RTX A4000 Laptop GPU Off | 00000000:01:00.0 Off | N/A | | N/A 54C P8 16W / 80W | 13MiB / 8192MiB | 0% Default | | | | N/A | +-----------------------------------------+------------------------+----------------------+ +-----------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=========================================================================================| | No running processes found | +-----------------------------------------------------------------------------------------+ ***CPU*** Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 16 On-line CPU(s) list: 0-15 Vendor ID: GenuineIntel Model name: 11th Gen Intel(R) Core(TM) i9-11950H @ 2.60GHz CPU family: 6 Model: 141 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 1 Stepping: 1 CPU(s) scaling MHz: 38% CPU max MHz: 5000.0000 CPU min MHz: 800.0000 BogoMIPS: 5222.40 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear ibt flush_l1d arch_capabilities Virtualization: VT-x L1d cache: 384 KiB (8 instances) L1i cache: 256 KiB (8 instances) L2 cache: 10 MiB (8 instances) L3 cache: 24 MiB (1 instance) NUMA node(s): 1 NUMA node0 CPU(s): 0-15 Vulnerability Gather data sampling: Vulnerable Vulnerability Ghostwrite: Not affected Vulnerability Indirect target selection: Mitigation; Aligned branch/return thunks Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Old microcode: Not affected Vulnerability Reg file data sampling: Not affected Vulnerability Retbleed: Not affected Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI SW loop, KVM SW loop Vulnerability Srbds: Not affected Vulnerability Tsa: Not affected Vulnerability Tsx async abort: Not affected Vulnerability Vmscape: Not affected ***CMake*** /usr/bin/cmake cmake version 3.28.3 CMake suite maintained and supported by Kitware (kitware.com/cmake). ***g++*** /usr/bin/g++ g++ (Ubuntu 13.3.0-6ubuntu2~24.04.1) 13.3.0 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ***nvcc*** /usr/local/cuda/bin/nvcc nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2026 NVIDIA Corporation Built on Mon_Mar_02_09:52:23_PM_PST_2026 Cuda compilation tools, release 13.2, V13.2.51 Build cuda_13.2.r13.2/compiler.37434383_0 ***Python*** ***Environment Variables*** PATH : /opt/proto/bin:/opt/tritonserver/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/mpi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/ucx/bin:/opt/amazon/efa/bin:/.local/bin LD_LIBRARY_PATH : /opt/tritonserver/lib:/opt/tritonclient/lib:/usr/src/tensorrt/lib:/opt/riva/lib:/usr/local/cuda-13/lib64:/usr/lib/x86_64-linux-gnu:/opt/hpcx/ucc/lib/:/opt/hpcx/ucx/lib/:/usr/local/cuda/compat/lib:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/.local/lib NUMBAPRO_NVVM : NUMBAPRO_LIBDEVICE : CONDA_PREFIX : PYTHON_PATH : conda not found ***pip packages*** /usr/bin/pip Package Version ------------------- --------------- annotated-doc 0.0.4 annotated-types 0.7.0 anyio 4.12.1 apparmor 4.0.1 certifi 2026.2.25 cupy-cuda13x 13.6.0 distlib 0.4.0 distro 1.9.0 fastapi 0.143.3 fastrlock 0.8.3 filelock 3.25.2 h11 0.16.0 httpcore 1.0.9 httpx 0.27.2 idna 3.11 iniconfig 2.3.0 jaraco.context 6.1.0 jiter 0.13.0 LibAppArmor 4.0.1 numpy 1.26.4 openai 1.107.3 opentelemetry-api 1.45.1 packaging 24.0 partial-json-parser 0.2.1.1.post7 pip 24.0 platformdirs 4.9.4 pluggy 1.6.0 pydantic 2.10.6 pydantic_core 2.27.2 Pygments 2.19.2 pyservicemaker 0.0.1 pytest 9.0.2 python-apt 2.7.7+ubuntu5.3 python-discovery 1.1.3 scipy 1.16.3 setuptools 78.1.1 sniffio 1.3.1 starlette 0.52.1 tqdm 4.67.3 tritonfrontend 2.67.0 tritonserver 0.0.0 typing_extensions 4.15.0 typing-inspection 0.4.4 virtualenv 21.2.0 wheel 0.42.0
Additional context
A service that takes files from users cannot rule out a bad first file. Today one bad file at start leaves the element unusable until the process restarts, and the stuck REST call blocks the caller too.
Activity
nvqiezi commentedon Nov 17, 2026
This issue can be reproduced on dGPU with DS9.2. We are investigating.
nvqiezi commentedon Nov 18, 2026
Thanks for the reporting! the issue is in nvmultiurisrcbin. Since nvmultiurisrcbin is opensource, you can apply this patch to fix the issue.
124_workaround.diff.txt
sergeykad commentedon Nov 18, 2026
Thanks, the patch fixes it. On the 9.2 sources in the stock image, with the repro of this issue: the good clip after a zero-byte first file plays 30 of 30 frames and ends with its removed message in 5 of 5 runs (stock: 4 frames, 2 of 2). The same holds for a text file named
.mp4, a path that does not exist, 64 KiB of random bytes and an mp4 cut to half, 2 runs each.Three notes:
GstObject *top = gst_object_ref (GST_OBJECT (ubin));inGThreadFuncRemoveSourcefails with "invalid conversion from gpointer" and needs a cast.GST_IS_DS_NVURISRC_BINneedsgst_ds_nvurisrc_bin_get_type, so the plugin must linklibnvdsgst_nvurisrcbin.so.nvqiezi commentedon Nov 20, 2026
Thanks for the thorough validation and notes!