ltp: Fix races in mmap1
PATCH 1/1 ltp: Fix races in mmap1
Make map_address a volatile pointer so that it is dereferenced in read_mem() after read_lock is set.
Also read_lock must protect the verbose printf that reads from map_address as well.
testcases/kernel/mem/mtest06/mmap1.c +5 -3
@@ -62,7 +62,7 @@ }while (0 ) static int verbose_print = 0; -static char *map_address; +static char *volatile map_address;static jmp_buf jmpbuf;static volatile char read_lock =0 ;
@@ -228,11 +228,13 @@ void *read_mem(void *ptr)tst_resm (TINFO ,"page fault occurred due to " "a read after an unmap" ); }else { -if (verbose_print) +if (verbose_print) { + read_lock =1 ;tst_resm (TINFO ,"read_mem(): content of memory: %s" , (char *)map_address); - + read_lock =0 ; + }for (j =0 ; j < args[1 ]; j++) { read_lock =1 ;if (map_address[j] !='a' )
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 40 lines · Dave Kleikamp
Make
map_addressa volatile pointer so that it is dereferenced inread_mem()afterread_lockis set.Also
read_lockmust protect the verbose printf that reads frommap_addressas well.Signed-off-by Dave Kleikamp <[email protected]>testcases/kernel/mem/mtest06/mmap1.c +5
-4@@ -62,7 +62,7 @@ }while (0 ) static int verbose_print = 0; -static char *map_address; +static char *volatile map_address;static jmp_buf jmpbuf;static volatile char read_lock =0 ;@@ -228,11 +228,13 @@ void *read_mem(void *ptr)tst_resm (TINFO ,"page fault occurred due to " "a read after an unmap" ); }else { -if (verbose_print) +if (verbose_print) { + read_lock =1 ;tst_resm (TINFO ,"read_mem(): content of memory: %s" , (char *)map_address); - + read_lock =0 ; + }for (j =0 ; j < args[1 ]; j++) { read_lock =1 ;if (map_address[j] !='a' ) ------------------------------------------------------------------------------Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Quoted 8 lines
Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Just in case.. To reproduce failures we need to invoke the test this way, for example:
./mmap1 -v -s 10
and then wait few minutes (it depends...)
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
testcases/kernel/mem/mtest06/mmap1.c line 65
Quoted 3 lines
static int
verbose_print= 0;testcases/kernel/mem/mtest06/mmap1.c +1
-1-static char *map_address; +static char *volatile map_address;
Ok.
Quoted 9 lines
static
jmp_bufjmpbuf;
static volatile charread_lock= 0;testcases/kernel/mem/mtest06/mmap1.c +1
-1@@ -228,11 +228,13 @@ void *read_mem(void *ptr)tst_resm (TINFO ,"page fault occurred due to " "a read after an unmap" ); }else { -if (verbose_print) +if (verbose_print) {
testcases/kernel/mem/mtest06/mmap1.c void *read_mem(void *ptr) · line 240
Quoted 10 lines
testcases/kernel/mem/mtest06/mmap1.c +3
-1+ read_lock =1 ;tst_resm (TINFO ,"read_mem(): content of memory: %s" , (char *)map_address); - + read_lock =0 ; + }for (j =0 ; j < args[1 ]; j++) { read_lock =1 ;if (map_address[j] !='a' )
Good catch, I've overlooked the tst_resm() when I was fixing the testcase.
Commited, thanks.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list