Repository navigation
Description
Describe the bug
pyservicemaker.Buffer(data) with data as bytes or as a numpy uint8 array succeeds and returns an empty Buffer (batch_size 0). It raises no error and logs nothing. The same bytes as a list of ints give a correct Buffer (batch_size 1).
When a Feeder returns such a Buffer from BufferProvider.generate, the appsrc ends the stream at the first push. With appsrc ! jpegparse ! jpegdec ! appsink, 5 pushes of a JPEG still as Buffer(list) give 5 decoded frames. As Buffer(bytes) or Buffer(numpy), the first push ends the stream and 0 frames are decoded.
The cause is the third constructor in service-maker/sources/python/src/bindings/buffer.h (lines 98 to 110 in the 9.2 image), documented as "Typecast a buffer from a GstBuffer object". It takes any py::object. When the object's type name is not Buffer, Gst.Buffer or gi.repository.Gst.Buffer, it returns std::make_unique<Buffer>() (line 104), an empty Buffer, instead of raising. A bytes object or a numpy array does not match the vector<uint8_t> overload (line 97), so the call lands in the typecast overload.
Steps/Code to reproduce bug
Get the image's sample still. Any JPEG works:
docker run --rm --entrypoint cat ghcr.io/nvidia/deepstream:9.2-triton-multiarch \
/opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.jpg > still.jpgSave as repro_empty_buffer.py. It prints the batch_size of a Buffer made three ways from the same file, then runs appsrc ! jpegparse ! jpegdec ! appsink with a feeder that pushes the file 5 times as Buffer(<kind>) and counts the frames at the appsink. Usage: repro_empty_buffer.py <list|bytes|numpy> <jpeg file>.
import os
import sys
import threading
import time
import numpy as np
from pyservicemaker import Buffer, BufferProvider, BufferRetriever, Feeder, Pipeline, Receiver
kind, path = sys.argv[1], sys.argv[2]
data = open(path, "rb").read()
MAKE = {
"list": lambda: list(data),
"bytes": lambda: data,
"numpy": lambda: np.frombuffer(data, dtype=np.uint8).copy(),
}
PUSHES = 5
pushed = 0
received = 0
class Feed(BufferProvider):
def generate(self, size):
global pushed
if pushed == PUSHES:
time.sleep(0.05)
return Buffer() # empty Buffer: ends the stream
pushed += 1
return Buffer(MAKE[kind]())
class Count(BufferRetriever):
def consume(self, buffer):
global received
received += 1
return 1
pipeline = Pipeline("empty-buffer") # Buffer() needs GStreamer, which Pipeline initialises
print(f"file: {len(data)} bytes")
for name, make in MAKE.items():
print(f"Buffer({name}): batch_size {Buffer(make()).batch_size}")
pipeline.add("appsrc", "src", {"caps": "image/jpeg", "format": 3, "do-timestamp": True})
pipeline.add("jpegparse", "parse", {})
pipeline.add("jpegdec", "dec", {})
pipeline.add("appsink", "sink", {"emit-signals": True, "sync": False})
pipeline.link("src", "parse", "dec", "sink")
pipeline.attach("src", Feeder("feeder", Feed()), tips="need-data/enough-data")
pipeline.attach("sink", Receiver("receiver", Count()), tips="new-sample")
pipeline.start()
threading.Thread(target=pipeline.wait, daemon=True).start()
time.sleep(5)
print(f"Buffer({kind}) pipeline: pushed {pushed}, decoded frames {received} of {pushed}", flush=True)
os._exit(0)Run it in the stock container (pyyaml is installed first because import pyservicemaker needs it, see #98):
for kind in bytes numpy list; do
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_empty_buffer.py $kind /repro/still.jpg"
donebytes prints (the start-up lines cut):
Main Loop Running...
End of stream
Main Loop Exited...
Pipeline empty-buffer stopped
file: 59724 bytes
Buffer(list): batch_size 1
Buffer(bytes): batch_size 0
Buffer(numpy): batch_size 0
Buffer(bytes) pipeline: pushed 1, decoded frames 0 of 1
numpy prints the same with Buffer(numpy) pipeline: pushed 1, decoded frames 0 of 1. The control, list, prints Buffer(list) pipeline: pushed 5, decoded frames 5 of 5.
| run | Buffer(bytes) |
Buffer(numpy) |
Buffer(list) (control) |
|---|---|---|---|
| 1 | batch_size 0, 0 of 1 frames | batch_size 0, 0 of 1 frames | batch_size 1, 5 of 5 frames |
| 2 | batch_size 0, 0 of 1 frames | batch_size 0, 0 of 1 frames | batch_size 1, 5 of 5 frames |
| 3 | batch_size 0, 0 of 1 frames | batch_size 0, 0 of 1 frames | batch_size 1, 5 of 5 frames |
No run prints an error or a warning about the buffer.
Expected behavior
Buffer(bytes) and Buffer(numpy uint8 array) either hold the bytes, as Buffer(list) does, or raise TypeError. The typecast constructor raises TypeError for an object that is not a GstBuffer, instead of returning an empty Buffer.
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 e03030dfca8e 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 17:13:28 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 56C P8 16W / 55W | 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: 40% 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
bytes and numpy arrays are the natural types for file contents, so the empty Buffer is easy to hit. The pipeline then ends as if the input were done, which looks like a normal end of stream.
Activity