diff mbox

[FFmpeg-devel] lavc/sinewin: Do not declare tables as const

Message ID CAB0OVGph7UW=4wwWAGj-At7cJLiCf_vPAvUh7e3gewfvEj0eMw@mail.gmail.com
State Superseded
Headers show

Commit Message

Carl Eugen Hoyos Oct. 14, 2018, 8:17 p.m. UTC
Hi!

Attached patch is supposed to fix ticket #7491, I currently don't have
gcc 8 to test myself.

Please comment, Carl Eugen

Comments

Hendrik Leppkes Oct. 14, 2018, 8:30 p.m. UTC | #1
On Sun, Oct 14, 2018 at 10:18 PM Carl Eugen Hoyos <ceffmpeg@gmail.com> wrote:
>
> Hi!
>
> Attached patch is supposed to fix ticket #7491, I currently don't have
> gcc 8 to test myself.
>

Only the 120 and 960 tables are affected by this bug because they are
not being created by the hardcoded tables logic, yet this patch
changes the const attribute for all tables, defeating one purpose of
the hardcoded tables.
Can we adjust this to only affect the two tables that need it, or
remove hardcoded tables for sinewin entirely, instead of leaving them
half-baked, or add 120 and 960 to hardcoded tables generation?

- Hendrik
diff mbox

Patch

From 90ac3c2b931d060e918a66047ff76c7d45f2274a Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Sun, 14 Oct 2018 22:13:34 +0200
Subject: [PATCH] lavc/sinewin: Do not declare the tables as const.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

At least ff_sine_window_init() is writing to some of the tables causing
a crash if compiled with gcc 8 and lto.

Analyzed by Martin Liška in:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85132

Fixes ticket #7491.
---
 libavcodec/sinewin.h          |   10 ++--------
 libavcodec/sinewin_tablegen.h |    2 +-
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/libavcodec/sinewin.h b/libavcodec/sinewin.h
index 6b97a71..146d4e5 100644
--- a/libavcodec/sinewin.h
+++ b/libavcodec/sinewin.h
@@ -25,18 +25,12 @@ 
 #include "libavutil/mem.h"
 #include "libavcodec/aac_defines.h"
 
-#if CONFIG_HARDCODED_TABLES
-#   define SINETABLE_CONST const
-#else
-#   define SINETABLE_CONST
-#endif
-
 #ifndef USE_FIXED
 #define USE_FIXED 0
 #endif
 
 #define SINETABLE(size) \
-    SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size]
+    DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size]
 
 /**
  * Generate a sine window.
@@ -62,6 +56,6 @@  extern SINETABLE(2048);
 extern SINETABLE(4096);
 extern SINETABLE(8192);
 
-extern SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[16];
+extern INTFLOAT * const AAC_RENAME(ff_sine_windows)[16];
 
 #endif /* AVCODEC_SINEWIN_H */
diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h
index 0fa3561..e1f7c4f 100644
--- a/libavcodec/sinewin_tablegen.h
+++ b/libavcodec/sinewin_tablegen.h
@@ -59,7 +59,7 @@  SINETABLE(8192);
 #define SIN_FIX(a) a
 #endif
 
-SINETABLE_CONST INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = {
+INTFLOAT * const AAC_RENAME(ff_sine_windows)[] = {
     NULL, NULL, NULL, NULL, NULL, // unused
     AAC_RENAME(ff_sine_32) , AAC_RENAME(ff_sine_64), AAC_RENAME(ff_sine_128),
     AAC_RENAME(ff_sine_256), AAC_RENAME(ff_sine_512), AAC_RENAME(ff_sine_1024),
-- 
1.7.10.4