* [LTP] [PATCH] sendmsg02: fix parameter passed to semctl(SETVAL)
@ 2014-08-22 13:03 Jan Stancek
2014-08-25 12:48 ` chrubis
0 siblings, 1 reply; 3+ messages in thread
From: Jan Stancek @ 2014-08-22 13:03 UTC (permalink / raw)
To: ltp-list
The fourth has the type union semun.
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/syscalls/sendmsg/sendmsg02.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/sendmsg/sendmsg02.c b/testcases/kernel/syscalls/sendmsg/sendmsg02.c
index 669af20..d96e10c 100644
--- a/testcases/kernel/syscalls/sendmsg/sendmsg02.c
+++ b/testcases/kernel/syscalls/sendmsg/sendmsg02.c
@@ -46,6 +46,12 @@
#include "usctest.h"
#include "safe_macros.h"
+union semun {
+ int val;
+ struct semid_ds *buf;
+ unsigned short int *array;
+};
+
char *TCID = "sendmsg02";
static int sem_id;
@@ -126,10 +132,12 @@ static void reproduce(int seconds)
int child_count = 0;
int *child_pids;
int child_pid;
+ union semun u;
child_pids = SAFE_MALLOC(cleanup, sizeof(int) * child_pairs * 2);
- if (semctl(sem_id, 0, SETVAL, 1) == -1)
+ u.val = 1;
+ if (semctl(sem_id, 0, SETVAL, u) == -1)
tst_brkm(TBROK | TERRNO, cleanup, "couldn't set semval to 1");
/* fork child for each client/server pair */
@@ -168,7 +176,8 @@ static void reproduce(int seconds)
if (child_count == child_pairs*2)
sleep(seconds);
- if (semctl(sem_id, 0, SETVAL, 0) == -1) {
+ u.val = 0;
+ if (semctl(sem_id, 0, SETVAL, u) == -1) {
/* kill children if setting semval failed */
for (i = 0; i < child_count; i++)
kill(child_pids[i], SIGKILL);
--
1.7.1
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] sendmsg02: fix parameter passed to semctl(SETVAL)
2014-08-22 13:03 [LTP] [PATCH] sendmsg02: fix parameter passed to semctl(SETVAL) Jan Stancek
@ 2014-08-25 12:48 ` chrubis
[not found] ` <1583769408.12443176.1408972372985.JavaMail.zimbra@redhat.com>
0 siblings, 1 reply; 3+ messages in thread
From: chrubis @ 2014-08-25 12:48 UTC (permalink / raw)
To: Jan Stancek; +Cc: ltp-list
Hi!
> The fourth has the type union semun.
The change looks good. I guess that this may have been failing on some
big endian machine where sizeof(void*) != sizeof(int), am I right?
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] sendmsg02: fix parameter passed to semctl(SETVAL)
[not found] ` <1583769408.12443176.1408972372985.JavaMail.zimbra@redhat.com>
@ 2014-08-25 13:27 ` Jan Stancek
0 siblings, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2014-08-25 13:27 UTC (permalink / raw)
To: ltp-list
----- Original Message -----
> From: "Jan Stancek" <jstancek@redhat.com>
> To: chrubis@suse.cz
> Cc: ltp-list@lists.sourceforge.net
> Sent: Monday, 25 August, 2014 3:12:52 PM
> Subject: Re: [LTP] [PATCH] sendmsg02: fix parameter passed to semctl(SETVAL)
>
>
>
>
>
> ----- Original Message -----
> > From: chrubis@suse.cz
> > To: "Jan Stancek" <jstancek@redhat.com>
> > Cc: ltp-list@lists.sourceforge.net
> > Sent: Monday, 25 August, 2014 2:48:38 PM
> > Subject: Re: [LTP] [PATCH] sendmsg02: fix parameter passed to
> > semctl(SETVAL)
> >
> > Hi!
> > > The fourth has the type union semun.
> >
> > The change looks good. I guess that this may have been failing on some
> > big endian machine where sizeof(void*) != sizeof(int), am I right?
>
> You're right it was big endian machine, but with sizeof(void *) == 4 and
> sizeof(int) == 4.
>
> Fourth parameter is expected to be passed by reference,
> so it was actually crashing on RHEL5.10 ppc:
>
> void func()
> {
> union semun a;
> a.val = 0;
> semctl(123, 456, SETVAL, a);
> }
>
> (gdb) disassemble func
> Dump of assembler code for function func:
> 0x1000047c <func+0>: stwu r1,-48(r1)
> 0x10000480 <func+4>: mflr r0
> 0x10000484 <func+8>: stw r31,44(r1)
> 0x10000488 <func+12>: stw r0,52(r1)
> 0x1000048c <func+16>: mr r31,r1
> 0x10000490 <func+20>: li r0,0
> 0x10000494 <func+24>: stw r0,8(r31)
> 0x10000498 <func+28>: lwz r0,8(r31)
> 0x1000049c <func+32>: stw r0,24(r31)
> 0x100004a0 <func+36>: addi r0,r31,24
> 0x100004a4 <func+40>: li r3,123
> 0x100004a8 <func+44>: li r4,456
> 0x100004ac <func+48>: li r5,16
> 0x100004b0 <func+52>: mr r6,r0
> 0x100004b4 <func+56>: crclr 4*cr1+eq
> 0x100004b8 <func+60>: bl 0x10000870 <semctl@plt>
> 0x100004bc <func+64>: lwz r11,0(r1)
> 0x100004c0 <func+68>: lwz r0,4(r11)
> 0x100004c4 <func+72>: mtlr r0
> 0x100004c8 <func+76>: lwz r31,-4(r11)
> 0x100004cc <func+80>: mr r1,r11
> 0x100004d0 <func+84>: blr
> End of assembler dump.
>
> (gdb) b *0x100004b8
> Breakpoint 1 at 0x100004b8: file a.c, line 18.
>
> (gdb) r
> Starting program:
> /mnt/tests/scratch/jstancek2/ltp-full-20140820/testcases/kernel/syscalls/sendmsg/a.out
>
> Breakpoint 1, 0x100004b8 in func () at a.c:18
> 18 semctl(123, 456, SETVAL, a);
>
> (gdb) p &a
> $1 = (union semun *) 0xffacf488
>
> (gdb) p/x $r6
> $2 = 0xffacf498
Patch pushed.
Regards,
Jan
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds. Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
>
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-08-25 13:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-22 13:03 [LTP] [PATCH] sendmsg02: fix parameter passed to semctl(SETVAL) Jan Stancek
2014-08-25 12:48 ` chrubis
[not found] ` <1583769408.12443176.1408972372985.JavaMail.zimbra@redhat.com>
2014-08-25 13:27 ` Jan Stancek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.