Missing null pointer check in renderer.c line 1082 when accessing texture params?
Hello,
I am the maintainer of a Launchpad PPA and received a crash report for vdr-plugin-softhdvaapi which uses libplacebo with vulkan (meson build number 2.63.0, the versions 2.66.0 and later seem to cause problems if the osd is opened and SD channels are rendered distorted) to render video output and and an OSD Layer.
In the backtrace I saw that the variable planes
contains several plane
elements with a null pointer as the texture (I am not sure if this is a valid use of the method), which I suppose causes a crash when accessing the texture's params (https://code.videolan.org/videolan/libplacebo/-/blob/master/src/renderer.c#L1082) - wouldn't it be useful to check if image->planes[i].texture
is null before dereferencing it?
Thread 1 (Thread 0x7fe729797700 (LWP 2197)):
#0 0x00007fe7b62a9d09 in pass_read_image (params=0x7fe729796b40, pass=0x7fe7297967b0, rr=0x7fe6f18e7fd0) at ../src/renderer.c:1082
st = 0x7fe729796570
i = 0
image = 0x7fe729796830
neutral = <optimized out>
ref = 0x0
ref_tex = <optimized out>
off_y = <optimized out>
has_alpha = <optimized out>
sh = 0x7fe6f1906620
planes = {{type = PLANE_ALPHA, plane = {texture = 0x0, components = 0, component_mapping = {0, 0, 0, 0}, shift_x = 0, shift_y = 0}, img = {w = 0, h = 0, sh = 0x0, tex = 0x0, rect = {x0 = 0, y0 = 0, x1 = 0, y1 = 0}, repr = {sys = PL_COLOR_SYSTEM_UNKNOWN, levels = PL_COLOR_LEVELS_UNKNOWN, alpha = PL_ALPHA_UNKNOWN, bits = {sample_depth = 0, color_depth = 0, bit_shift = 0}}, color = {primaries = PL_COLOR_PRIM_UNKNOWN, transfer = PL_COLOR_TRC_UNKNOWN, light = PL_COLOR_LIGHT_UNKNOWN, sig_peak = 0, sig_avg = 0, sig_scale = 0}, comps = 0}}, {type = PLANE_ALPHA, plane = {texture = 0x0, components = 0, component_mapping = {0, 0, 0, 0}, shift_x = 0, shift_y = 1.40129846e-45}, img = {w = 1, h = 0, sh = 0x200000000, tex = 0x10000000c0, rect = {x0 = 5.60519386e-45, y0 = 1.40129846e-45, x1 = 2.69049305e-42, y1 = 1.51340234e-42}, repr = {sys = PL_COLOR_SYSTEM_BT_601, levels = PL_COLOR_LEVELS_TV, alpha = (unknown: 1920), bits = {sample_depth = 1080, color_depth = 1, bit_shift = 1}}, color = {primaries = PL_COLOR_PRIM_BT_601_525, transfer = PL_COLOR_TRC_BT_1886, light = 8294400, sig_peak = 0, sig_avg = 5.73971851e-42, sig_scale = 1.07619722e-41}, comps = 1080}}, {type = 9, plane = {texture = 0x7fe6f0beb770, components = 0, component_mapping = {0, 0, 2, 0}, shift_x = 0, shift_y = 0}, img = {w = 0, h = 0, sh = 0x0, tex = 0x0, rect = {x0 = 0, y0 = 0, x1 = 0, y1 = 0}, repr = {sys = PL_COLOR_SYSTEM_UNKNOWN, levels = PL_COLOR_LEVELS_UNKNOWN, alpha = PL_ALPHA_UNKNOWN, bits = {sample_depth = 0, color_depth = 0, bit_shift = 0}}, color = {primaries = PL_COLOR_PRIM_UNKNOWN, transfer = PL_COLOR_TRC_UNKNOWN, light = PL_COLOR_LIGHT_UNKNOWN, sig_peak = 0, sig_avg = 0, sig_scale = 0}, comps = 0}}, {type = PLANE_ALPHA, plane = {texture = 0x0, components = 0, component_mapping = {0, 0, 0, 0}, shift_x = 0, shift_y = 0}, img = {w = 0, h = 0, sh = 0x0, tex = 0x1, rect = {x0 = 2.69049305e-43, y0 = 0, x1 = 1.40129846e-45, y1 = 0}, repr = {sys = PL_COLOR_SYSTEM_BT_601, levels = 30292, alpha = PL_ALPHA_UNKNOWN, bits = {sample_depth = 0, color_depth = 0, bit_shift = 0}}, color = {primaries = PL_COLOR_PRIM_UNKNOWN, transfer = PL_COLOR_TRC_UNKNOWN, light = PL_COLOR_LIGHT_UNKNOWN, sig_peak = 0, sig_avg = 0, sig_scale = 0}, comps = 0}}}
off_x = <optimized out>
image = <optimized out>
sh = <optimized out>
neutral = <optimized out>
planes = <optimized out>
ref = <optimized out>
__PRETTY_FUNCTION__ = "pass_read_image"
ref_tex = <optimized out>
off_x = <optimized out>
off_y = <optimized out>
has_alpha = <optimized out>
i = <optimized out>
st = <optimized out>
i = <optimized out>
st = <optimized out>
rx = <optimized out>
ry = <optimized out>
rrx = <optimized out>
rry = <optimized out>
sx = <optimized out>
sy = <optimized out>
i = <optimized out>
st = <optimized out>
plane = <optimized out>
scale_x = <optimized out>
scale_y = <optimized out>
src = <optimized out>
psh = <optimized out>
sub = <optimized out>
inter_img = <optimized out>
inter_tex = <optimized out>
c = <optimized out>
#1 pl_render_image (rr=0x7fe6f18e7fd0, pimage=pimage@entry=0x7fe76c42d2c8, ptarget=ptarget@entry=0x7fe729796ce0, params=params@entry=0x7fe729796b40) at ../src/renderer.c:1600
pass = {tmp = 0x7fe6f1de3150, rr = 0x7fe6f18e7fd0, img = {w = 0, h = 0, sh = 0x0, tex = 0x0, rect = {x0 = 0, y0 = 0, x1 = 0, y1 = 0}, repr = {sys = PL_COLOR_SYSTEM_UNKNOWN, levels = PL_COLOR_LEVELS_UNKNOWN, alpha = PL_ALPHA_UNKNOWN, bits = {sample_depth = 0, color_depth = 0, bit_shift = 0}}, color = {primaries = PL_COLOR_PRIM_UNKNOWN, transfer = PL_COLOR_TRC_UNKNOWN, light = PL_COLOR_LIGHT_UNKNOWN, sig_peak = 0, sig_avg = 0, sig_scale = 0}, comps = 0}, ref_rect = {x0 = 0, y0 = 0, x1 = 0, y1 = 0}, image = {signature = 2, num_planes = 2, planes = {{texture = 0x0, components = 1, component_mapping = {0, -1, -1, -1}, shift_x = 0, shift_y = 0}, {texture = 0x0, components = 2, component_mapping = {1, 2, -1, -1}, shift_x = -0.5, shift_y = 0}, {texture = 0x0, components = 0, component_mapping = {0, 0, 0, 0}, shift_x = 0, shift_y = 0}, {texture = 0x0, components = 0, component_mapping = {0, 0, 0, 0}, shift_x = 0, shift_y = 0}}, repr = {sys = PL_COLOR_SYSTEM_BT_709, levels = PL_COLOR_LEVELS_TV, alpha = PL_ALPHA_UNKNOWN, bits = {sample_depth = 0, color_depth = 0, bit_shift = 0}}, color = {primaries = PL_COLOR_PRIM_BT_709, transfer = PL_COLOR_TRC_BT_1886, light = PL_COLOR_LIGHT_DISPLAY, sig_peak = 1, sig_avg = 0.25, sig_scale = 1}, profile = {data = 0x0, len = 0, signature = 0}, src_rect = {x0 = 0, y0 = 0, x1 = 720, y1 = 576}, overlays = 0x0, num_overlays = 0, av1_grain = {grain_seed = 0, num_points_y = 0, points_y = {"\000" <repeats 14 times>}, chroma_scaling_from_luma = false, num_points_uv = {0, 0}, points_uv = {{"\000", "\000", "\000", "\000", "\000", "\000", "\000", "\000", "\000", "\000"}, {"\000", "\000", "\000", "\000", "\000", "\000", "\000", "\000", "\000", "\000"}}, scaling_shift = 0, ar_coeff_lag = 0, ar_coeffs_y = '\000' <repeats 23 times>, ar_coeffs_uv = {'\000' <repeats 24 times>, '\000' <repeats 24 times>}, ar_coeff_shift = 0, grain_scale_shift = 0, uv_mult = "\000", uv_mult_luma = "\000", uv_offset = {0, 0}, overlap = false}, width = 720, height = 576}, target = {fbo = 0x7fe6f0bfc110, dst_rect = {x0 = 0, y0 = 0, x1 = 1920, y1 = 1080}, repr = {sys = PL_COLOR_SYSTEM_RGB, levels = PL_COLOR_LEVELS_TV, alpha = PL_ALPHA_UNKNOWN, bits = {sample_depth = 8, color_depth = 8, bit_shift = 0}}, color = {primaries = PL_COLOR_PRIM_BT_709, transfer = PL_COLOR_TRC_SRGB, light = PL_COLOR_LIGHT_DISPLAY, sig_peak = 1, sig_avg = 0.25, sig_scale = 1}, profile = {data = 0x0, len = 0, signature = 0}, overlays = 0x0, num_overlays = 0}, fbos_used = 0x7fe6f18fc440}
image = 0x7fe729796830
target = 0x7fe729796a10
#2 0x00007fe7b80fe345 in CuvidMixVideo (decoder=decoder@entry=0x7fe76c42cbf0, level=level@entry=0, target=target@entry=0x7fe729796ce0, ovl=ovl@entry=0x0) at video.c:3794
render_params = {upscaler = 0x7fe7b6517ba0 <pl_filter_lanczos>, downscaler = 0x7fe7b6517ba0 <pl_filter_lanczos>, lut_entries = 0, antiringing_strength = 0, frame_mixer = 0x0, deband_params = 0x7fe729796b10, sigmoid_params = 0x7fe7b64878d0 <pl_sigmoid_default_params>, color_adjustment = 0x7fe729796b20, peak_detect_params = 0x7fe7b64878c0 <pl_peak_detect_default_params>, color_map_params = 0x7fe7b64878a0 <pl_color_map_default_params>, dither_params = 0x7fe7b6487880 <pl_dither_default_params>, lut3d_params = 0x0, cone_params = 0x0, hooks = 0x0, num_hooks = 0, skip_anti_aliasing = false, polar_cutoff = 0, disable_overlay_sampling = false, allow_delayed_peak_detect = false, skip_redraw_caching = false, disable_linear_scaling = false, disable_builtin_scalers = false, force_3dlut = false, force_dither = false, disable_fbos = false}
deband = {iterations = 1, threshold = 4, radius = 16, grain = 6}
colors = {brightness = 0, contrast = 1, saturation = 1, hue = 0, gamma = 1}
cone = {cones = 679171093, strength = 4.58827156e-41}
vkp = <optimized out>
pl = 0x7fe76c42d300
fmt = <optimized out>
img = 0x7fe76c42d2c8
ok = <optimized out>
video_src_rect = {x0 = 0, y0 = <optimized out>, x1 = 720, y1 = <optimized out>}
dst_rect = {x0 = 0, y0 = 0, x1 = <optimized out>, y1 = <optimized out>}
dst_video_rect = {x0 = 0, y0 = 0, x1 = 1920, y1 = 1080}
current = 2
y = <optimized out>
xcropf = <optimized out>
ycropf = <optimized out>
texLoc = <optimized out>
frame = <optimized out>
#3 0x00007fe7b810489c in CuvidDisplayFrame () at video.c:4072
decoder = 0x7fe76c42cbf0
valid_frame = 1
diff = <optimized out>
filled = <optimized out>
ldiff = <optimized out>
frame = {fbo = 0x7fe6f0bfc110, flipped = false, color_repr = {sys = PL_COLOR_SYSTEM_RGB, levels = PL_COLOR_LEVELS_PC, alpha = PL_ALPHA_UNKNOWN, bits = {sample_depth = 8, color_depth = 8, bit_shift = 0}}, color_space = {primaries = PL_COLOR_PRIM_BT_709, transfer = PL_COLOR_TRC_GAMMA22, light = PL_COLOR_LIGHT_DISPLAY, sig_peak = 0, sig_avg = 0, sig_scale = 0}}
fmt = <optimized out>
i = 0
RTS_flag = <optimized out>
turnaround = <optimized out>
target = {fbo = 0x7fe6f0bfc110, dst_rect = {x0 = 0, y0 = 0, x1 = 1920, y1 = 1080}, repr = {sys = PL_COLOR_SYSTEM_RGB, levels = PL_COLOR_LEVELS_TV, alpha = PL_ALPHA_UNKNOWN, bits = {sample_depth = 8, color_depth = 8, bit_shift = 0}}, color = {primaries = PL_COLOR_PRIM_BT_709, transfer = PL_COLOR_TRC_SRGB, light = PL_COLOR_LIGHT_DISPLAY, sig_peak = 0, sig_avg = 0, sig_scale = 0}, profile = {data = 0x0, len = 0, signature = 0}, overlays = 0x0, num_overlays = 0}
ok = <optimized out>
black = <optimized out>
first_time = <optimized out>
round_time = 7897946837
last_time = 7897947159
i = <optimized out>
filled = <optimized out>
decoder = <optimized out>
RTS_flag = <optimized out>
valid_frame = <optimized out>
ldiff = <optimized out>
first = <optimized out>
turnaround = <optimized out>
diff = <optimized out>
fdiff = <optimized out>
frame = <optimized out>
target = <optimized out>
ok = <optimized out>
fmt = <optimized out>
black = <optimized out>