All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix subtle race in tst-cancel2 / tst-cancelx2
@ 2017-12-08 17:47 Vineet Gupta
  2017-12-08 18:07 ` [PATCH v2] " Vineet Gupta
  0 siblings, 1 reply; 4+ messages in thread
From: Vineet Gupta @ 2017-12-08 17:47 UTC (permalink / raw)
  To: linux-snps-arc

When ran on ARC, these tests would ocassionally fail

| [ARCLinux]# for i in 1 2 3 4 5 ; do ./tst-cancel2; echo $?; done
| write succeeded
| result is wrong: expected 0xffffffff, got 0x1
| 1							<-- fail
| 0							<-- pass
| 0							<--- pass
| 0							<-- pass
| write succeeded
| result is wrong: expected 0xffffffff, got 0x1
| 1							<-- fail

Same test (which originated form glibc) doesn't fail in glibc builds.
Turns out there's a subtle race in uclibc version

The test creates a new thread, makes it do a looong write call, and
parent then cancels the thread, expecting it to unwind out of write
call cleanly. However the write (even for 10k bytes) could fnish befor
eparent gets a chance ti run and/or cancel - causing the occasional
failire.

Cc: Cupertino Miranda <cmiranda at synopsys.com>
Fix this subtelty by making it write not just once but forever.

Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
---
 test/nptl/tst-cancel2.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/test/nptl/tst-cancel2.c b/test/nptl/tst-cancel2.c
index 45c9e8ea957a..08dd13b10f37 100644
--- a/test/nptl/tst-cancel2.c
+++ b/test/nptl/tst-cancel2.c
@@ -32,11 +32,7 @@ tf (void *arg)
      write blocks.  */
   char buf[100000];
 
-  if (write (fd[1], buf, sizeof (buf)) == sizeof (buf))
-    {
-      puts ("write succeeded");
-      return (void *) 1l;
-    }
+  while (write (fd[1], buf, sizeof (buf)) > 0);
 
   return (void *) 42l;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2] Fix subtle race in tst-cancel2 / tst-cancelx2
  2017-12-08 17:47 [PATCH] Fix subtle race in tst-cancel2 / tst-cancelx2 Vineet Gupta
@ 2017-12-08 18:07 ` Vineet Gupta
  2017-12-18 19:18   ` [uclibc-ng-devel] " Vineet Gupta
  0 siblings, 1 reply; 4+ messages in thread
From: Vineet Gupta @ 2017-12-08 18:07 UTC (permalink / raw)
  To: linux-snps-arc

When ran on ARC, these tests would ocassionally fail

| [ARCLinux]# for i in 1 2 3 4 5 ; do ./tst-cancel2; echo $?; done
| write succeeded
| result is wrong: expected 0xffffffff, got 0x1
| 1							<-- fail
| 0							<-- pass
| 0							<--- pass
| 0							<-- pass
| write succeeded
| result is wrong: expected 0xffffffff, got 0x1
| 1							<-- fail

Same test (which originated form glibc) doesn't fail in glibc builds.
Turns out there's a subtle race in uclibc version

The test creates a new thread, makes it do a looong write call, and
parent then cancels the thread, expecting it to unwind out of write
call cleanly. However the write (even for 10k bytes) could finish
before parent gets a chance to resume and/or cancel it, causing the
occasional failure.

Fix this subtelty by making it write not just once but forever.

Cc: Cupertino Miranda <cmiranda at synopsys.com>
Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
---
Change since v1: fix typos in changelogs
---
 test/nptl/tst-cancel2.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/test/nptl/tst-cancel2.c b/test/nptl/tst-cancel2.c
index 45c9e8ea957a..08dd13b10f37 100644
--- a/test/nptl/tst-cancel2.c
+++ b/test/nptl/tst-cancel2.c
@@ -32,11 +32,7 @@ tf (void *arg)
      write blocks.  */
   char buf[100000];
 
-  if (write (fd[1], buf, sizeof (buf)) == sizeof (buf))
-    {
-      puts ("write succeeded");
-      return (void *) 1l;
-    }
+  while (write (fd[1], buf, sizeof (buf)) > 0);
 
   return (void *) 42l;
 }
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [uclibc-ng-devel] [PATCH v2] Fix subtle race in tst-cancel2 / tst-cancelx2
  2017-12-08 18:07 ` [PATCH v2] " Vineet Gupta
@ 2017-12-18 19:18   ` Vineet Gupta
  2017-12-18 19:40     ` Waldemar Brodkorb
  0 siblings, 1 reply; 4+ messages in thread
From: Vineet Gupta @ 2017-12-18 19:18 UTC (permalink / raw)
  To: linux-snps-arc

On 12/08/2017 10:07 AM, Vineet Gupta wrote:
> When ran on ARC, these tests would ocassionally fail
> 
> | [ARCLinux]# for i in 1 2 3 4 5 ; do ./tst-cancel2; echo $?; done
> | write succeeded
> | result is wrong: expected 0xffffffff, got 0x1
> | 1							<-- fail
> | 0							<-- pass
> | 0							<--- pass
> | 0							<-- pass
> | write succeeded
> | result is wrong: expected 0xffffffff, got 0x1
> | 1							<-- fail
> 
> Same test (which originated form glibc) doesn't fail in glibc builds.
> Turns out there's a subtle race in uclibc version
> 
> The test creates a new thread, makes it do a looong write call, and
> parent then cancels the thread, expecting it to unwind out of write
> call cleanly. However the write (even for 10k bytes) could finish
> before parent gets a chance to resume and/or cancel it, causing the
> occasional failure.
> 
> Fix this subtelty by making it write not just once but forever.
> 
> Cc: Cupertino Miranda <cmiranda at synopsys.com>
> Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
> ---
> Change since v1: fix typos in changelogs
> ---

Ping ?


>   test/nptl/tst-cancel2.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/test/nptl/tst-cancel2.c b/test/nptl/tst-cancel2.c
> index 45c9e8ea957a..08dd13b10f37 100644
> --- a/test/nptl/tst-cancel2.c
> +++ b/test/nptl/tst-cancel2.c
> @@ -32,11 +32,7 @@ tf (void *arg)
>        write blocks.  */
>     char buf[100000];
>   
> -  if (write (fd[1], buf, sizeof (buf)) == sizeof (buf))
> -    {
> -      puts ("write succeeded");
> -      return (void *) 1l;
> -    }
> +  while (write (fd[1], buf, sizeof (buf)) > 0);
>   
>     return (void *) 42l;
>   }
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [uclibc-ng-devel] [PATCH v2] Fix subtle race in tst-cancel2 / tst-cancelx2
  2017-12-18 19:18   ` [uclibc-ng-devel] " Vineet Gupta
@ 2017-12-18 19:40     ` Waldemar Brodkorb
  0 siblings, 0 replies; 4+ messages in thread
From: Waldemar Brodkorb @ 2017-12-18 19:40 UTC (permalink / raw)
  To: linux-snps-arc

Hi,

patch applied and pushed,
just forgot the mail,

 best regards
  Waldemar 

> Am 18.12.2017 um 20:18 schrieb Vineet Gupta <Vineet.Gupta1 at synopsys.com>:
> 
>> On 12/08/2017 10:07 AM, Vineet Gupta wrote:
>> When ran on ARC, these tests would ocassionally fail
>> | [ARCLinux]# for i in 1 2 3 4 5 ; do ./tst-cancel2; echo $?; done
>> | write succeeded
>> | result is wrong: expected 0xffffffff, got 0x1
>> | 1                            <-- fail
>> | 0                            <-- pass
>> | 0                            <--- pass
>> | 0                            <-- pass
>> | write succeeded
>> | result is wrong: expected 0xffffffff, got 0x1
>> | 1                            <-- fail
>> Same test (which originated form glibc) doesn't fail in glibc builds.
>> Turns out there's a subtle race in uclibc version
>> The test creates a new thread, makes it do a looong write call, and
>> parent then cancels the thread, expecting it to unwind out of write
>> call cleanly. However the write (even for 10k bytes) could finish
>> before parent gets a chance to resume and/or cancel it, causing the
>> occasional failure.
>> Fix this subtelty by making it write not just once but forever.
>> Cc: Cupertino Miranda <cmiranda at synopsys.com>
>> Signed-off-by: Vineet Gupta <vgupta at synopsys.com>
>> ---
>> Change since v1: fix typos in changelogs
>> ---
> 
> Ping ?
> 
> 
>>  test/nptl/tst-cancel2.c | 6 +-----
>>  1 file changed, 1 insertion(+), 5 deletions(-)
>> diff --git a/test/nptl/tst-cancel2.c b/test/nptl/tst-cancel2.c
>> index 45c9e8ea957a..08dd13b10f37 100644
>> --- a/test/nptl/tst-cancel2.c
>> +++ b/test/nptl/tst-cancel2.c
>> @@ -32,11 +32,7 @@ tf (void *arg)
>>       write blocks.  */
>>    char buf[100000];
>>  -  if (write (fd[1], buf, sizeof (buf)) == sizeof (buf))
>> -    {
>> -      puts ("write succeeded");
>> -      return (void *) 1l;
>> -    }
>> +  while (write (fd[1], buf, sizeof (buf)) > 0);
>>      return (void *) 42l;
>>  }
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-18 19:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-08 17:47 [PATCH] Fix subtle race in tst-cancel2 / tst-cancelx2 Vineet Gupta
2017-12-08 18:07 ` [PATCH v2] " Vineet Gupta
2017-12-18 19:18   ` [uclibc-ng-devel] " Vineet Gupta
2017-12-18 19:40     ` Waldemar Brodkorb

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.