Accepting request 150679 from home:tiwai:branches:multimedia:libs

- Backport a few fix patches from upstream, mostly for fixing
  crashes in multi-thread programs:
  0044-configure-do-not-detect-incorrect-cross-compiler.patch
  0045-ucm-Set-uc_mgr-ctl-to-NULL-after-closing-it.patch
  0046-snd_pcm_direct_parse_open_conf-use-thread-safe-getgr.patch
  0047-Add-snd_lib_error_set_local-to-install-a-thread-loca.patch
  0048-snd_device_name_hint-do-not-change-the-global-error-.patch
  0049-snd_device_name_hint-do-not-use-global-snd_config.patch
  0050-conf-Fix-a-memory-access-violation-resulting-from-im.patch

OBS-URL: https://build.opensuse.org/request/show/150679
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa?expand=0&rev=123
This commit is contained in:
Takashi Iwai 2013-02-01 10:22:50 +00:00 committed by Git OBS Bridge
parent c728daee43
commit cd5dd1370c
9 changed files with 512 additions and 1 deletions

View File

@ -0,0 +1,36 @@
From b11911dddf2fd58e24c808da26105cb1e1bce722 Mon Sep 17 00:00:00 2001
From: Olivier Blin <dev@blino.org>
Date: Sat, 15 Dec 2012 01:58:59 +0100
Subject: [PATCH 44/50] configure: do not detect incorrect cross-compiler
On Ubuntu 11.04, configuring with --build=x86_64-unknown-linux-gnu
--host=x86_64-linux-gnu finds a wrong cross-compiler:
checking for cross-compiler... x86_64-x86_64-pc-linux-gnu-gcc
This happens because of a dash vs underscore inconsistency in configure.in:
host=x86_64-pc-linux-gnu
host_cpu=x86_64
host_os=linux-gnu
which ${host_cpu}-${host_os}-gcc >/dev/null 2>&1 && echo ${host_cpu}-${host-os}-gcc
This bug has been introduced in the initial --with-host support from
2002, commit eb267ade29c9a49c07b1c33dc9bf7a6790217400
This configure command is about "cross-compiling for i586", where the
system compiler is used, which just -m32 additional options.
The --build value comes from config.guess.
---
configure.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/configure.in
+++ b/configure.in
@@ -31,7 +31,7 @@ then
which ${program_prefix}gcc >/dev/null 2>&1 && CC=${program_prefix}gcc
which ${host_cpu}-${host_os}-gcc >/dev/null 2>&1 \
- && CC=${host_cpu}-${host-os}-gcc
+ && CC=${host_cpu}-${host_os}-gcc
which ${host_cpu}-${host_vendor}-${host_os}-gcc >/dev/null 2>&1 \
&& CC=${host_cpu}-${host_vendor}-${host_os}-gcc

View File

@ -0,0 +1,24 @@
From 1629e2fbf3dc211eceb37f980e11e5babe1cefe4 Mon Sep 17 00:00:00 2001
From: Tanu Kaskinen <tanuk@iki.fi>
Date: Sat, 26 Jan 2013 14:20:20 +0200
Subject: [PATCH 45/50] ucm: Set uc_mgr->ctl to NULL after closing it.
Fixes a double-free bug.
Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/ucm/main.c | 1 +
1 file changed, 1 insertion(+)
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -145,6 +145,7 @@ static int open_ctl(snd_use_case_mgr_t *
free(uc_mgr->ctl_dev);
uc_mgr->ctl_dev = NULL;
snd_ctl_close(uc_mgr->ctl);
+ uc_mgr->ctl = NULL;
}
err = snd_ctl_open(ctl, ctl_dev, 0);

View File

@ -0,0 +1,41 @@
From 2cfc8b9b44a8e493c41b3d63d5a00b306a18a5ed Mon Sep 17 00:00:00 2001
From: Jerome Forissier <jerome@taodyne.com>
Date: Wed, 30 Jan 2013 16:22:17 +0100
Subject: [PATCH 46/50] snd_pcm_direct_parse_open_conf(): use thread-safe
getgrnam_r()
Fixes a thread safety issue with snd_pcm_open().
Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/pcm/pcm_direct.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
--- a/src/pcm/pcm_direct.c
+++ b/src/pcm/pcm_direct.c
@@ -1629,13 +1629,20 @@ int snd_pcm_direct_parse_open_conf(snd_c
continue;
}
if (isdigit(*group) == 0) {
- struct group *grp = getgrnam(group);
- if (grp == NULL) {
+ long clen = sysconf(_SC_GETGR_R_SIZE_MAX);
+ size_t len = (clen == -1) ? 1024 : (size_t)clen;
+ struct group grp, *pgrp;
+ char *buffer = (char *)malloc(len);
+ if (buffer == NULL)
+ return -ENOMEM;
+ int st = getgrnam_r(group, &grp, buffer, len, &pgrp);
+ if (st != 0) {
SNDERR("The field ipc_gid must be a valid group (create group %s)", group);
- free(group);
+ free(buffer);
return -EINVAL;
}
- rec->ipc_gid = grp->gr_gid;
+ rec->ipc_gid = pgrp->gr_gid;
+ free(buffer);
} else {
rec->ipc_gid = strtol(group, &endp, 10);
}

View File

@ -0,0 +1,98 @@
From 44c1a623dd1fc9e831616b663bebc54ca98df994 Mon Sep 17 00:00:00 2001
From: Jerome Forissier <jerome@taodyne.com>
Date: Thu, 31 Jan 2013 15:47:23 +0100
Subject: [PATCH 47/50] Add snd_lib_error_set_local() to install a thread-local
error handler.
This is required so we can make other functions reentrant (such as
snd_device_name_hint()).
The default error handling function snd_lib_error_default() now checks
if a local handler exists, and if so, calls it. Otherwise, the previous
behavior is unchanged.
Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
configure.in | 10 ++++++++++
include/error.h | 6 ++++++
src/error.c | 24 +++++++++++++++++++++++-
3 files changed, 39 insertions(+), 1 deletion(-)
--- a/configure.in
+++ b/configure.in
@@ -281,6 +281,16 @@ else
AC_MSG_RESULT(no)
fi
+dnl Check for __thread
+AC_MSG_CHECKING([for __thread])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && ((__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) || (__GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ < 2))
+#error gcc has this bug: http://gcc.gnu.org/ml/gcc-bugs/2006-09/msg02275.html
+#endif], [static __thread int p = 0])],
+[AC_DEFINE(HAVE___THREAD, 1,
+Define to 1 if compiler supports __thread)
+AC_MSG_RESULT([yes])],
+[AC_MSG_RESULT([no])])
+
dnl Check for librt
AC_MSG_CHECKING(for librt)
AC_ARG_WITH(librt,
--- a/include/error.h
+++ b/include/error.h
@@ -74,5 +74,11 @@ extern int snd_lib_error_set_handler(snd
}
#endif
+typedef void (*snd_local_error_handler_t)(const char *file, int line,
+ const char *func, int err,
+ const char *fmt, va_list arg);
+
+snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func);
+
#endif /* __ALSA_ERROR_H */
--- a/src/error.c
+++ b/src/error.c
@@ -60,6 +60,21 @@ const char *snd_strerror(int errnum)
return snd_error_codes[errnum];
}
+#ifdef HAVE___THREAD
+#define TLS_PFX __thread
+#else
+#define TLS_PFX /* NOP */
+#endif
+
+static TLS_PFX snd_local_error_handler_t local_error = NULL;
+
+snd_local_error_handler_t snd_lib_error_set_local(snd_local_error_handler_t func)
+{
+ snd_local_error_handler_t old = local_error;
+ local_error = func;
+ return old;
+}
+
/**
* \brief The default error handler function.
* \param file The filename where the error was hit.
@@ -69,12 +84,19 @@ const char *snd_strerror(int errnum)
* \param fmt The message (including the format characters).
* \param ... Optional arguments.
*
- * Prints the error message including location to \c stderr.
+ * If a local error function has been installed for the current thread by
+ * \ref snd_lib_error_set_local, it is called. Otherwise, prints the error
+ * message including location to \c stderr.
*/
static void snd_lib_error_default(const char *file, int line, const char *function, int err, const char *fmt, ...)
{
va_list arg;
va_start(arg, fmt);
+ if (local_error) {
+ local_error(file, line, function, err, fmt, arg);
+ va_end(arg);
+ return;
+ }
fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function);
vfprintf(stderr, fmt, arg);
if (err)

View File

@ -0,0 +1,61 @@
From 25dbb102810b31c02358904d70d53c960fb0a10e Mon Sep 17 00:00:00 2001
From: Jerome Forissier <jerome@taodyne.com>
Date: Thu, 31 Jan 2013 15:47:24 +0100
Subject: [PATCH 48/50] snd_device_name_hint(): do not change the global error
handler.
This is the first step towards making this function reentrant.
Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/control/namehint.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
--- a/src/control/namehint.c
+++ b/src/control/namehint.c
@@ -80,7 +80,8 @@ static void zero_handler(const char *fil
int line ATTRIBUTE_UNUSED,
const char *function ATTRIBUTE_UNUSED,
int err ATTRIBUTE_UNUSED,
- const char *fmt ATTRIBUTE_UNUSED, ...)
+ const char *fmt ATTRIBUTE_UNUSED,
+ va_list arg ATTRIBUTE_UNUSED)
{
}
@@ -212,7 +213,7 @@ static int try_config(struct hint_list *
const char *base,
const char *name)
{
- snd_lib_error_handler_t eh;
+ snd_local_error_handler_t eh;
snd_config_t *res = NULL, *cfg, *cfg1, *n;
snd_config_iterator_t i, next;
char *buf, *buf1 = NULL, *buf2;
@@ -239,10 +240,9 @@ static int try_config(struct hint_list *
sprintf(buf, "%s:CARD=%s", name, snd_ctl_card_info_get_id(list->info));
else
strcpy(buf, name);
- eh = snd_lib_error;
- snd_lib_error_set_handler(&zero_handler);
+ eh = snd_lib_error_set_local(&zero_handler);
err = snd_config_search_definition(snd_config, base, buf, &res);
- snd_lib_error_set_handler(eh);
+ snd_lib_error_set_local(eh);
if (err < 0)
goto __skip_add;
cleanup_res = 1;
@@ -337,10 +337,9 @@ static int try_config(struct hint_list *
goto __ok;
/* find, if all parameters have a default, */
/* otherwise filter this definition */
- eh = snd_lib_error;
- snd_lib_error_set_handler(&zero_handler);
+ eh = snd_lib_error_set_local(&zero_handler);
err = snd_config_search_alias_hooks(snd_config, base, buf, &res);
- snd_lib_error_set_handler(eh);
+ snd_lib_error_set_local(eh);
if (err < 0)
goto __cleanup;
if (snd_config_search(res, "@args", &cfg) >= 0) {

View File

@ -0,0 +1,197 @@
From f49b2dc522a2564315c76d075203b15a39941e8a Mon Sep 17 00:00:00 2001
From: Jerome Forissier <jerome@taodyne.com>
Date: Thu, 31 Jan 2013 15:47:25 +0100
Subject: [PATCH 49/50] snd_device_name_hint(): do not use global snd_config.
This commit and its parent make the function reentrant.
Signed-off-by: Jerome Forissier <jerome@taodyne.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/control/namehint.c | 52 ++++++++++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 22 deletions(-)
--- a/src/control/namehint.c
+++ b/src/control/namehint.c
@@ -209,7 +209,8 @@ static char *get_dev_name(struct hint_li
#define BUF_SIZE 128
#endif
-static int try_config(struct hint_list *list,
+static int try_config(snd_config_t *config,
+ struct hint_list *list,
const char *base,
const char *name)
{
@@ -229,7 +230,7 @@ static int try_config(struct hint_list *
return -ENOMEM;
sprintf(buf, "%s.%s", base, name);
/* look for redirection */
- if (snd_config_search(snd_config, buf, &cfg) >= 0 &&
+ if (snd_config_search(config, buf, &cfg) >= 0 &&
snd_config_get_string(cfg, &str) >= 0 &&
((strncmp(base, str, strlen(base)) == 0 &&
str[strlen(base)] == '.') || strchr(str, '.') == NULL))
@@ -241,7 +242,7 @@ static int try_config(struct hint_list *
else
strcpy(buf, name);
eh = snd_lib_error_set_local(&zero_handler);
- err = snd_config_search_definition(snd_config, base, buf, &res);
+ err = snd_config_search_definition(config, base, buf, &res);
snd_lib_error_set_local(eh);
if (err < 0)
goto __skip_add;
@@ -338,7 +339,7 @@ static int try_config(struct hint_list *
/* find, if all parameters have a default, */
/* otherwise filter this definition */
eh = snd_lib_error_set_local(&zero_handler);
- err = snd_config_search_alias_hooks(snd_config, base, buf, &res);
+ err = snd_config_search_alias_hooks(config, base, buf, &res);
snd_lib_error_set_local(eh);
if (err < 0)
goto __cleanup;
@@ -405,7 +406,7 @@ static const next_devices_t next_devices
};
#endif
-static int add_card(struct hint_list *list, int card)
+static int add_card(snd_config_t *config, struct hint_list *list, int card)
{
int err, ok;
snd_config_t *conf, *n;
@@ -417,7 +418,7 @@ static int add_card(struct hint_list *li
snd_ctl_card_info_alloca(&info);
list->info = info;
- err = snd_config_search(snd_config, list->siface, &conf);
+ err = snd_config_search(config, list->siface, &conf);
if (err < 0)
return err;
sprintf(ctl_name, "hw:%i", card);
@@ -448,7 +449,7 @@ static int add_card(struct hint_list *li
ok = 0;
for (device = 0; err >= 0 && device <= max_device; device++) {
list->device = device;
- err = try_config(list, list->siface, str);
+ err = try_config(config, list, list->siface, str);
if (err < 0)
break;
ok++;
@@ -463,7 +464,7 @@ static int add_card(struct hint_list *li
if (err < 0) {
list->card = card;
list->device = -1;
- err = try_config(list, list->siface, str);
+ err = try_config(config, list, list->siface, str);
}
if (err == -ENOMEM)
goto __error;
@@ -492,14 +493,14 @@ static int get_card_name(struct hint_lis
return 0;
}
-static int add_software_devices(struct hint_list *list)
+static int add_software_devices(snd_config_t *config, struct hint_list *list)
{
int err;
snd_config_t *conf, *n;
snd_config_iterator_t i, next;
const char *str;
- err = snd_config_search(snd_config, list->siface, &conf);
+ err = snd_config_search(config, list->siface, &conf);
if (err < 0)
return err;
snd_config_for_each(i, next, conf) {
@@ -508,7 +509,7 @@ static int add_software_devices(struct h
continue;
list->card = -1;
list->device = -1;
- err = try_config(list, list->siface, str);
+ err = try_config(config, list, list->siface, str);
if (err == -ENOMEM)
return -ENOMEM;
}
@@ -546,13 +547,14 @@ int snd_device_name_hint(int card, const
struct hint_list list;
char ehints[24];
const char *str;
- snd_config_t *conf;
+ snd_config_t *conf, *local_config = NULL;
+ snd_config_update_t *local_config_update = NULL;
snd_config_iterator_t i, next;
int err;
if (hints == NULL)
return -EINVAL;
- err = snd_config_update();
+ err = snd_config_update_r(&local_config, &local_config_update, NULL);
if (err < 0)
return err;
list.list = NULL;
@@ -572,18 +574,21 @@ int snd_device_name_hint(int card, const
list.iface = SND_CTL_ELEM_IFACE_HWDEP;
else if (strcmp(iface, "ctl") == 0)
list.iface = SND_CTL_ELEM_IFACE_MIXER;
- else
- return -EINVAL;
+ else {
+ err = -EINVAL;
+ goto __error;
+ }
+
list.show_all = 0;
list.cardname = NULL;
- if (snd_config_search(snd_config, "defaults.namehint.showall", &conf) >= 0)
+ if (snd_config_search(local_config, "defaults.namehint.showall", &conf) >= 0)
list.show_all = snd_config_get_bool(conf) > 0;
if (card >= 0) {
err = get_card_name(&list, card);
if (err >= 0)
- err = add_card(&list, card);
+ err = add_card(local_config, &list, card);
} else {
- add_software_devices(&list);
+ add_software_devices(local_config, &list);
err = snd_card_next(&card);
if (err < 0)
goto __error;
@@ -591,7 +596,7 @@ int snd_device_name_hint(int card, const
err = get_card_name(&list, card);
if (err < 0)
goto __error;
- err = add_card(&list, card);
+ err = add_card(local_config, &list, card);
if (err < 0)
goto __error;
err = snd_card_next(&card);
@@ -600,7 +605,7 @@ int snd_device_name_hint(int card, const
}
}
sprintf(ehints, "namehint.%s", list.siface);
- err = snd_config_search(snd_config, ehints, &conf);
+ err = snd_config_search(local_config, ehints, &conf);
if (err >= 0) {
snd_config_for_each(i, next, conf) {
if (snd_config_get_string(snd_config_iterator_entry(i),
@@ -617,7 +622,6 @@ int snd_device_name_hint(int card, const
snd_device_name_free_hint((void **)list.list);
if (list.cardname)
free(list.cardname);
- return err;
} else {
err = hint_list_add(&list, NULL, NULL);
if (err < 0)
@@ -626,7 +630,11 @@ int snd_device_name_hint(int card, const
if (list.cardname)
free(list.cardname);
}
- return 0;
+ if (local_config)
+ snd_config_delete(local_config);
+ if (local_config_update)
+ snd_config_update_free(local_config_update);
+ return err;
}
/**

View File

@ -0,0 +1,27 @@
From 7f2b2c8c1650a1883b48abfcdb455138943854f9 Mon Sep 17 00:00:00 2001
From: Allan Wirth <allan@allanwirth.com>
Date: Thu, 31 Jan 2013 13:55:33 -0500
Subject: [PATCH 50/50] conf: Fix a memory access violation resulting from
improper error propogation
Fixes an issue where a variable is used undeclared, which can cause seg
faults on some systems if the configuration file is not formatted
properly.
Signed-off-by: Allan Wirth <allan@allanwirth.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
src/conf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/src/conf.c
+++ b/src/conf.c
@@ -3530,7 +3530,7 @@ int snd_config_hook_load(snd_config_t *r
if (err < 0)
goto _err;
}
- } else if (config_file_open(root, fi[idx].name) < 0)
+ } else if ((err = config_file_open(root, fi[idx].name)) < 0)
goto _err;
}
*dst = NULL;

View File

@ -1,3 +1,16 @@
-------------------------------------------------------------------
Fri Feb 1 08:10:43 CET 2013 - tiwai@suse.de
- Backport a few fix patches from upstream, mostly for fixing
crashes in multi-thread programs:
0044-configure-do-not-detect-incorrect-cross-compiler.patch
0045-ucm-Set-uc_mgr-ctl-to-NULL-after-closing-it.patch
0046-snd_pcm_direct_parse_open_conf-use-thread-safe-getgr.patch
0047-Add-snd_lib_error_set_local-to-install-a-thread-loca.patch
0048-snd_device_name_hint-do-not-change-the-global-error-.patch
0049-snd_device_name_hint-do-not-use-global-snd_config.patch
0050-conf-Fix-a-memory-access-violation-resulting-from-im.patch
-------------------------------------------------------------------
Thu Dec 13 10:12:55 CET 2012 - tiwai@suse.de

View File

@ -1,7 +1,7 @@
#
# spec file for package alsa
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -95,6 +95,13 @@ Patch40: 0040-PCM-Fix-conflict-of-_snd_pcm_hw_params-definitions.patch
Patch41: 0041-configure-Quite-AM_CONDITIONAL-arguments.patch
Patch42: 0042-mixer-Don-t-build-simple_abst-when-no-libdl-is-avail.patch
Patch43: 0043-Fix-endian-check-in-local.h.patch
Patch44: 0044-configure-do-not-detect-incorrect-cross-compiler.patch
Patch45: 0045-ucm-Set-uc_mgr-ctl-to-NULL-after-closing-it.patch
Patch46: 0046-snd_pcm_direct_parse_open_conf-use-thread-safe-getgr.patch
Patch47: 0047-Add-snd_lib_error_set_local-to-install-a-thread-loca.patch
Patch48: 0048-snd_device_name_hint-do-not-change-the-global-error-.patch
Patch49: 0049-snd_device_name_hint-do-not-use-global-snd_config.patch
Patch50: 0050-conf-Fix-a-memory-access-violation-resulting-from-im.patch
#
Patch99: alsa-lib-doxygen-avoid-crash-for-11.3.diff
Url: http://www.alsa-project.org/
@ -188,6 +195,13 @@ Architecture.
%patch41 -p1
%patch42 -p1
%patch43 -p1
%patch44 -p1
%patch45 -p1
%patch46 -p1
%patch47 -p1
%patch48 -p1
%patch49 -p1
%patch50 -p1
%if %suse_version == 1130
%patch99 -p1
%endif