Segfault due to absence of alignment of float in universal_nonlinear_rgb_u8_converter_sse2 (babl/base/babl-rgb-converter.c)
Babl version: 0.1.92
Operating system: Gentoo Linux
The absence of alignment of float in universal_nonlinear_rgb_u8_converter_sse2
(babl/base/babl-rgb-converter.c)
results in gegl segmentation fault while GIMP compilation in some cases.
Presumably it mainly occurs for AMD K8 CPUs (see bug [1]).
Offered patch by Alexander Bezrukov (please see [1] discussion):
Fix alignment of vector of floats in babl-rgb-converter.c
Bug: https://bugs.gentoo.org/857708
Signed-off-by: Alexander Bezrukov <phmagic@mail.ru>
diff -ur a/babl/base/babl-rgb-converter.c b/babl/base/babl-rgb-converter.c
--- a/babl/base/babl-rgb-converter.c
+++ b/babl/base/babl-rgb-converter.c
@@ -306,7 +306,8 @@
uint8_t *rgb_in_u8 = (void*)src_char;
uint8_t *rgb_out_u8 = (void*)dst_char;
- float rgba_out[4*samples];
+ // The alignment is necessary for SIMD intrinsics in babl_matrix_mul_vectorff_buf4_sse2()
+ float __attribute__ ((aligned (16))) rgba_out[4*samples];
for (i = 0; i < samples; i++)
{
The proposed patch fixes this issue as several Gentoo users recall and used for babl in Gentoo main repository.