This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 0f51c22375335a9bb2b8756b1ad2e40fbe27928b
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Nov 18 16:40:25 2026 -0600
ector: pad a radial gradient with no solution to the first stop on sse3
Where a radial gradient has no solution for a pixel, the software
rasterizer takes the square root of a negative number. Every path maps
the resulting NaN to the first stop, except the SSE3 pad clamp: maxps
returns its second operand when one is NaN, and that operand was the
index, so the NaN went on to become a colour table index of INT_MIN
and the render thread crashed reading 8 GB before the table.
Float drift produces this for an ordinary radial too, near its centre
on some spans, which is how an application drawing a shaded ball
crashed at some window sizes (800x600, not 640x480). The test uses a
focal point outside the circle, which hits it on every run.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../ector/software/ector_software_gradient_sse3.c | 5 ++-
src/tests/evas/evas_test_vg.c | 51 ++++++++++++++++++++++
2 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/src/lib/ector/software/ector_software_gradient_sse3.c b/src/lib/ector/software/ector_software_gradient_sse3.c
index 883bdbf37e..5aa17274b9 100644
--- a/src/lib/ector/software/ector_software_gradient_sse3.c
+++ b/src/lib/ector/software/ector_software_gradient_sse3.c
@@ -25,9 +25,12 @@ typedef union { __m128 v; float f[4];} vec4_f;
__m128i v_index_i_inv = _mm_sub_epi32(v_reflect_limit, v_index_i); \
index_vec.v = _mm_min_epi16(v_index_i, v_index_i_inv);
+/* maxps returns its second operand when either one is NaN, so v_index must
+ * come first: a lane with no gradient solution (sqrt of a negative det) then
+ * pads to index 0, as the scalar path does, instead of becoming INT_MIN. */
#define FETCH_CLAMP_PAD_F \
vec4_i index_vec; \
- index_vec.v = _mm_cvttps_epi32(_mm_min_ps(v_max, _mm_max_ps(v_min, v_index)));
+ index_vec.v = _mm_cvttps_epi32(_mm_min_ps(v_max, _mm_max_ps(v_index, v_min)));
#define FETCH_EPILOGUE_CPY \
*buffer++ = g_data->color_table[index_vec.i[0]]; \
diff --git a/src/tests/evas/evas_test_vg.c b/src/tests/evas/evas_test_vg.c
index 7d2961bfc5..f5fc8a149a 100644
--- a/src/tests/evas/evas_test_vg.c
+++ b/src/tests/evas/evas_test_vg.c
@@ -206,9 +206,60 @@ EFL_START_TEST(evas_vg_tiny_surface_cache)
}
EFL_END_TEST
+// A radial gradient whose focal point lies outside its circle, with the
+// default pad spread, filling the whole canvas.
+//
+// Outside the cone from the focal point to the circle no gradient position
+// exists, so the software rasterizer takes the square root of a negative
+// number there. Every path maps that NaN to the first stop, except the SSE3
+// pad clamp, which used to let it through as a colour table index of INT_MIN.
+// Float drift does the same for an ordinary radial near its centre, which is
+// how an application with a focal point inside the circle crashed with it.
+static void
+_build_radial_focal_outside(Evas *e)
+{
+ static const Efl_Gfx_Gradient_Stop stops[] = {
+ { 0.0, 255, 0, 0, 255 },
+ { 1.0, 0, 0, 255, 255 },
+ };
+ Eo *vg, *shape, *grad;
+
+ vg = efl_add(EFL_CANVAS_VG_OBJECT_CLASS, e);
+ efl_gfx_entity_size_set(vg, EINA_SIZE2D(WIN_W, WIN_H));
+ efl_gfx_entity_visible_set(vg, EINA_TRUE);
+
+ shape = efl_add(EFL_CANVAS_VG_SHAPE_CLASS, vg);
+ efl_gfx_path_append_rect(shape, 0, 0, WIN_W, WIN_H, 0, 0);
+
+ grad = efl_add(EFL_CANVAS_VG_GRADIENT_RADIAL_CLASS, vg);
+ efl_gfx_gradient_radial_center_set(grad, 128, 128);
+ efl_gfx_gradient_radial_radius_set(grad, 32);
+ efl_gfx_gradient_radial_focal_set(grad, 8, 8);
+ efl_gfx_gradient_stop_set(grad, stops, EINA_C_ARRAY_LENGTH(stops));
+ efl_canvas_vg_shape_fill_set(shape, grad);
+
+ efl_canvas_vg_object_root_node_set(vg, shape);
+}
+
+EFL_START_TEST(evas_vg_radial_without_solution_pads_to_first_stop)
+{
+ unsigned int px = 0;
+
+ // (250, 8) is seen from the focal point 45 degrees off the line to the
+ // centre, well outside the 11 degree cone the circle subtends.
+ if (!_scene_sample("buffer", _build_radial_focal_outside, 2, 250, 8, &px))
+ return;
+
+ ck_assert_msg((((px >> 16) & 0xff) > 200) && ((px & 0xff) < 50),
+ "no gradient solution should pad to the first stop (red), "
+ "got %08x", px);
+}
+EFL_END_TEST
+
void evas_test_vg(TCase *tc)
{
tcase_add_test(tc, evas_vg_mixed_sizes_group_opacity);
tcase_add_test(tc, evas_vg_container_alpha_is_applied);
tcase_add_test(tc, evas_vg_tiny_surface_cache);
+ tcase_add_test(tc, evas_vg_radial_without_solution_pads_to_first_stop);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.