Skip to content

Commit

Permalink
pcm: Fix segfault with 32bit libs
Browse files Browse the repository at this point in the history
The recent rearrangement of header inclusion order caused a regression
showing segfaults on 32bit Arm.  The primary reason is the
inconsistent compile condition depending on the inclusion of config.h;
while most of other code include pcm_local.h (that implicitly includes
config.h) at first, pcm_direct.c doesn't do it, hence the access with
direct plugins crashes.

For fixing it, we need to include config.h at the beginning.  But,
it's better to include pcm_local.h for all relevant code for
consistency.  The patch does it, and also it adds the guard in
pcm_local.h for double inclusions.

Fixes: ad3a8b8 ("reshuffle included files to include config.h as first")
Link: #352
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
tiwai committed Sep 9, 2023
1 parent 10bd599 commit 0e3dfb9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/pcm/pcm_direct.c
Expand Up @@ -19,6 +19,7 @@
*
*/

#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
Expand Down
2 changes: 1 addition & 1 deletion src/pcm/pcm_dmix.c
Expand Up @@ -26,7 +26,7 @@
*
*/

#include "config.h"
#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
Expand Down
1 change: 1 addition & 0 deletions src/pcm/pcm_dshare.c
Expand Up @@ -26,6 +26,7 @@
*
*/

#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
Expand Down
1 change: 1 addition & 0 deletions src/pcm/pcm_dsnoop.c
Expand Up @@ -26,6 +26,7 @@
*
*/

#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
Expand Down
5 changes: 5 additions & 0 deletions src/pcm/pcm_local.h
Expand Up @@ -20,6 +20,9 @@
*
*/

#ifndef __PCM_LOCAL_H
#define __PCM_LOCAL_H

#include "config.h"

#include <stdio.h>
Expand Down Expand Up @@ -1223,3 +1226,5 @@ static inline void snd_pcm_unlock(snd_pcm_t *pcm)
#define snd_pcm_lock(pcm) do {} while (0)
#define snd_pcm_unlock(pcm) do {} while (0)
#endif /* THREAD_SAFE_API */

#endif /* __PCM_LOCAL_H */
1 change: 1 addition & 0 deletions src/pcm/pcm_shm.c
Expand Up @@ -26,6 +26,7 @@
*
*/

#include "pcm_local.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
Expand Down

0 comments on commit 0e3dfb9

Please sign in to comment.