Hello,
I found this one interesting and tried to reproduce it,
and hit this issue quite reliable with an unstable armel chroot,
inside an armhf unstable qemu VM,
or with a Android/LineageOS with real arm CPU.

Unfortunately valgrind is no longer built for armel, and a local armel rebuild
shows issues with latest "-fstack-protector-strong -fstack-clash-protection".

Finally I found this issue leads not to a crash at amd64, but
valgrind uncovers it there reliable [1].

dpkg-buildpackage with valgrind installed uses it automatically.
Therefore the change in [2] might be an improvement?


Increasing the allocation of the input buffer like in [3]
makes the valgrind errors go away.
Unfortunately I don't know what exact size this buffer is expected to have.

Kind regards,
Bernhard




[1]
...
fft const
==1105453== Invalid write of size 4
==1105453==    at 0x60BFC25: ??? (in 
/usr/lib/x86_64-linux-gnu/libavutil.so.58.29.100)
==1105453==    by 0x4CE1880: av_rdft_calc (in 
/usr/lib/x86_64-linux-gnu/libavcodec.so.60.31.102)
==1105453==    by 0x11246F: FFTPlanImpl::execute() (spek-fft.cc:38)
==1105453==    by 0x110A76: test_const() (test-fft.cc:21)
==1105453==    by 0x1105F5: test_fft() (test-fft.cc:77)
==1105453==    by 0x10BF5C: main (test.cc:11)
==1105453==  Address 0x11a828c4 is 4 bytes after a block of size 64 alloc'd
==1105453==    at 0x4845DA0: memalign (in 
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1105453==    by 0x4845F01: posix_memalign (in 
/usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==1105453==    by 0x608CC14: av_malloc (in 
/usr/lib/x86_64-linux-gnu/libavutil.so.58.29.100)
==1105453==    by 0x1126A0: FFTPlan (spek-fft.h:29)
==1105453==    by 0x1126A0: FFTPlanImpl::FFTPlanImpl(int) (spek-fft.cc:27)
==1105453==    by 0x112745: FFT::create(int) (spek-fft.cc:24)
==1105453==    by 0x1109AE: test_const() (test-fft.cc:13)
==1105453==    by 0x1105F5: test_fft() (test-fft.cc:77)
==1105453==    by 0x10BF5C: main (test.cc:11)
...


[2]
--- debian/control.orig 2023-01-11 07:25:51.000000000 +0100
+++ debian/control      2024-04-21 16:30:57.545576734 +0200
@@ -11,3 +11,4 @@ Build-Depends: debhelper-compat (= 13),
                libwxgtk3.2-dev,
-               wx-common
+               wx-common,
+               valgrind-if-available
 Standards-Version: 4.6.2


[3]
--- src/spek-fft.h.orig 2023-01-10 05:00:39.000000000 +0100
+++ src/spek-fft.h      2024-04-21 16:28:07.000000000 +0200
@@ -28,3 +28,3 @@ public:
         // input data to be aligned by up to 32 bytes (e.g. AVX)
-        this->input = (float*) av_malloc(sizeof(float) * input_size);
+        this->input = (float*) av_malloc(sizeof(float) * (input_size + 2));
     }

Reply via email to