[PATCH] Fix crash in ipc_sem test

Dmitry V. Levin ldv at altlinux.org
Wed Mar 11 17:54:49 UTC 2015


On Wed, Mar 11, 2015 at 01:08:58PM +0100, Andreas Schwab wrote:
> Properly use union semun as argument of semctl.

Indeed, on some architectures, union of a pointer is not the same as a pointer.

> --- a/tests/ipc_sem.c
> +++ b/tests/ipc_sem.c
> @@ -2,10 +2,19 @@
>  #include <errno.h>
>  #include <sys/sem.h>
>  
> +union semun {
> +  int              val;    /* Value for SETVAL */
> +  struct semid_ds *buf;    /* Buffer for IPC_STAT, IPC_SET */
> +  unsigned short  *array;  /* Array for GETALL, SETALL */
> +  struct seminfo  *__buf;  /* Buffer for IPC_INFO
> +			      (Linux-specific) */
> +};
> +

Is it intended that this declaration is indented differently from the rest
of this file?

>  int
>  main(void)
>  {
>  	int rc, id;
> +	union semun un;
>  	struct semid_ds ds;
>  	struct seminfo info;


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20150311/043c432a/attachment.bin>


More information about the Strace-devel mailing list