NVIMGCODEC_MAX_IMAGE_SIZE is parsed as a bool: any value becomes a 1 byte limit and every decode returns None
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 79/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- backend, computer-vision
Hướng nghiên cứu
Bắt đầu trong python/decoder.cpp gần dòng 240 được báo cáo và kiểm tra cách NVIMGCODEC_MAX_IMAGE_SIZE được phân tích. Sau đó, đọc test/python/test_cpu_only.py để xem các mẫu kiểm thử decoder hiện có và tái hiện lỗi bằng ví dụ PPM 16×16 trong issue trên một trình thông dịch mới. Hoàn thành khi giới hạn byte được cấu hình được tuân thủ và kiểm thử hồi quy chạy thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
0.10.0 (wheel nvidia-nvimgcodec-cu12==0.10.0.9; also main at 77a7d15)
Describe the bug.
Setting NVIMGCODEC_MAX_IMAGE_SIZE to any non-zero value makes the Python Decoder return None for every image. The warning shows that the limit was read as 1:
768 > NVIMGCODEC_MAX_IMAGE_SIZE(1)
Expected: the value is used as a byte limit, so a 768 byte image decodes with NVIMGCODEC_MAX_IMAGE_SIZE=100000000. The warning text itself describes the variable as the maximum "Total image volume (height x width x channels x bytes_per_sample)".
The cause is in python/decoder.cpp (line 240 on main):
static const size_t max_image_sz = max_image_size_str && atol(max_image_size_str);
&& gives a bool, so max_image_sz is 0 or 1. The same expression is in the v0.3.0, v0.5.0 and v0.7.0 to v0.10.0 sources.
Minimum reproducible example
cat > repro.py <<'PY'
import os
from nvidia import nvimgcodec
print("nvimgcodec", nvimgcodec.__version__)
print("NVIMGCODEC_MAX_IMAGE_SIZE =", os.environ.get("NVIMGCODEC_MAX_IMAGE_SIZE"))
# A 16x16 binary PPM, 768 bytes of pixel data.
ppm = b"P6\n16 16\n255\n" + bytes(16 * 16 * 3)
decoder = nvimgcodec.Decoder(
device_id=nvimgcodec.NVIMGCODEC_DEVICE_CPU_ONLY,
backends=[nvimgcodec.Backend(nvimgcodec.BackendKind.CPU_ONLY)],
)
image = decoder.decode(ppm)
print("decoded:", None if image is None else image.shape)
PY
NVIMGCODEC_MAX_IMAGE_SIZE=100000000 python repro.py
Environment details
tools/print_env.sh was not run. Environment used for the repro:
x86_64 Linux, Ubuntu 24.04, Python 3.12
nvidia-nvimgcodec-cu12 0.10.0.9, CPU-only backend, no GPU visible (CUDA_VISIBLE_DEVICES empty)
Also reproduced with a from-source build of main 77a7d15 (CUDA toolkit 12.9, GCC 14.4)
Relevant log output
[WARNING] [pynvimgcodec] Total image volume (height x width x channels x bytes_per_sample) exceeds the maximum configured value: 768 > NVIMGCODEC_MAX_IMAGE_SIZE(1). Use NVIMGCODEC_MAX_IMAGE_SIZE env variable to control this maximum value.
nvimgcodec 0.10.0
NVIMGCODEC_MAX_IMAGE_SIZE = 100000000
decoded: None
Without the variable the same script prints decoded: (16, 16, 3).
Other/Misc.
A local fix is available if useful: parse the value with atoll and treat a missing, non-numeric or non-positive value as "no limit", plus a test in test/python/test_cpu_only.py that sets the variable in a fresh interpreter. The new test fails on main and passes with the change. One behaviour change: a negative value would mean "no limit" instead of "limit 1".
Check for duplicates
- I have searched the open bugs/issues and have found no duplicates for this bug report
This was found with an AI coding assistant (Claude Code, claude-fable-5-2), which also wrote and ran the repro above and drafted this report.
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 164
- Fork
- 26
- Merge trung bình
- 27 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của NVIDIA/nvImageCodec
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
NVIDIA/nvImageCodec#66 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
NVIDIA/nvImageCodec#64 ·
-
nvjpeg2k error 3 (Bad jpeg) on valid JPEG 2000 aerial photos that OpenJPEG and ffmpeg decode identicallyCó thể đã có người làm @mkepa-nv đã nhận 5 ngày trước. Đang mởbug
NVIDIA/nvImageCodec#63 · 2 bình luận · 1 người được giao ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 8/100
NVIDIA/nvImageCodec#60 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
NVIDIA/nvImageCodec#59 ·
Tất cả issue của NVIDIA/nvImageCodec
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
tauri-apps/plugins-workspace#3780 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AAswordman/Operit#1490 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
open-telemetry/opentelemetry-zig#179 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:cards enhancement hand-tail ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
fil-donadoni/tolaria#9275 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/build area/events area/storage area/storage/kafkasql area/storage/sql
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Apicurio/apicurio-registry#11079 ·
Maintainer thường phản hồi trong vòng 1 ngày