Bug 12649 - reproducer for races of expect incomplete reads
Summary: reproducer for races of expect incomplete reads
Status: ASSIGNED
Alias: None
Product: gdb
Classification: Unclassified
Component: testsuite (show other bugs)
Version: HEAD
: P2 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 12647
  Show dependency treegraph
 
Reported: 2011-04-07 08:08 UTC by Jan Kratochvil
Modified: 2014-08-20 18:23 UTC (History)
2 users (show)

See Also:
Host:
Target: i686-fedora15-linux-gnu
Build:
Last reconfirmed:


Attachments
PASSes->FAILs after this reproducer. (6.81 KB, text/plain)
2011-04-07 08:08 UTC, Jan Kratochvil
Details
gdb_test_timeout *= 20 (279 bytes, patch)
2011-04-07 08:22 UTC, Jan Kratochvil
Details | Diff
writew: A different reproducer - delaying the GDB writes. (745 bytes, text/plain)
2011-10-29 14:00 UTC, Jan Kratochvil
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2011-04-07 08:08:27 UTC
Created attachment 5649 [details]
PASSes->FAILs after this reproducer.

Excercise any incomplete reads handling in the testsuite by simulating read() always returns just 1 character.

#define _GNU_SOURCE 1
#include <dlfcn.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
ssize_t
read (int fd, void *buf, size_t count)
{
  static ssize_t (*read2) (int fd, void *buf, size_t count) = NULL;
  if (read2 == NULL)
    {
      unsetenv ("LD_PRELOAD");
      read2 = dlsym (RTLD_NEXT, "read");
    }
  if (count > 0 && isatty (fd) >= 1)
    count = 1;
  return read2 (fd, buf, count);
}

gcc -o /usr/local/lib/read1.so read1.c -Wall -g -shared -fPIC

/usr/local/bin/runtest:
#! /bin/sh
export EXPECT=/usr/local/bin/expect-read1
exec /usr/bin/runtest "$@"

/usr/local/bin/expect-read1:
#! /bin/sh
export LD_PRELOAD=/usr/local/lib/read1.so
exec /usr/bin/expect "$@"

-# of expected passes           19875
+# of expected passes           19701
-# of unexpected failures       69
+# of unexpected failures       173
+# of unknown successes         9
+# of known failures            71
+# of unresolved testcases      9

(Some of the differences in the attachment may be unrelated to this Bug.)
Comment 1 Jan Kratochvil 2011-04-07 08:16:10 UTC
*** Bug 12647 has been marked as a duplicate of this bug. ***
Comment 2 Jan Kratochvil 2011-04-07 08:22:00 UTC
Created attachment 5650 [details]
gdb_test_timeout *= 20

And be careful with multiarch, /usr/local/lib/read1.so has only single arch.
Comment 3 Pedro Alves 2011-04-07 10:35:19 UTC
Brilliant!
Comment 4 cvs-commit@gcc.gnu.org 2011-05-02 17:52:31 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	palves@sourceware.org	2011-05-02 17:52:28

Modified files:
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.base: completion.exp 

Log message:
	2011-05-02  Pedro Alves  <pedro@codesourcery.com>
	
	PR testsuite/12649
	Fix races.
	
	* gdb.base/completion.exp: Remove all sleep calls.  Remove
	unnecessary regexs.  Don't explicitly expect anything after the
	prompt.  Eat the prompt if necessary.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2687&r2=1.2688
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/completion.exp.diff?cvsroot=src&r1=1.50&r2=1.51
Comment 5 Marek Polacek 2011-05-27 14:41:18 UTC
Just a little status report, where are we at.

These tests were already race-fixed:
 * gdb.base/commands.exp
 * gdb.base/completion.exp
 * gdb.base/pointers.exp
 * gdb.base/pr10179.exp
 * gdb.base/setshow.exp
 * gdb.cp/cpcompletion.exp
 * gdb.cp/static-print-quit.exp
 * gdb.mi/mi-basics.exp
 * gdb.mi/mi-nonstop-exit.exp
 * gdb.mi/mi-nonstop.exp
 * gdb.mi/mi-ns-stale-regcache.exp
 * gdb.mi/mi-nsthrexec.exp

Remaining:
 * gdb.mi/mi-nsintrall.exp
 * gdb.mi/mi-nsmoribund.exp
 * gdb.mi/mi-return.exp
 * gdb.mi/mi-var-display.exp
 * gdb.mi/mi2-basics.exp
 * gdb.mi/mi2-console.exp
 * gdb.mi/mi2-return.exp
 * gdb.mi/mi2-var-display.exp
 * gdb.python/py-evthreads.exp
 * gdb.python/python.exp
Comment 6 Jan Kratochvil 2011-10-29 14:00:24 UTC
Created attachment 6039 [details]
writew: A different reproducer - delaying the GDB writes.

It could reproduce:
FAIL: gdb.mi/mi-nonstop.exp: breakpoint at marker
from:
[patch] testsuite: MI: racy results in async mode #2
http://sourceware.org/ml/gdb-patches/2011-10/msg00797.html
Comment 7 cvs-commit@gcc.gnu.org 2011-11-25 23:50:21 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	jkratoch@sourceware.org	2011-11-25 23:50:16

Modified files:
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.reverse: i386-sse-reverse.exp 

Log message:
	gdb/testsuite/
	PR testsuite/12649
	* gdb.reverse/i386-sse-reverse.exp (continue to end of sse_test #2):
	Wrap send_gdb into a new gdb_test.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2946&r2=1.2947
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.reverse/i386-sse-reverse.exp.diff?cvsroot=src&r1=1.6&r2=1.7
Comment 8 cvs-commit@gcc.gnu.org 2011-12-02 12:43:34 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	jkratoch@sourceware.org	2011-12-02 12:43:30

Modified files:
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.trace: collection.exp tspeed.exp tstatus.exp 

Log message:
	gdb/testsuite/
	PR testsuite/12649
	* gdb.trace/collection.exp (gdb_collect_return_test): Import gdb_prompt.
	Protect gdb_test_multiple by final $gdb_prompt match.
	* gdb.trace/tspeed.exp (gdb_fast_trace_speed_test): Likewise.
	* gdb.trace/tstatus.exp (run_trace_experiment): Likewise.
	(test_tracepoints): Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2955&r2=1.2956
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.trace/collection.exp.diff?cvsroot=src&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.trace/tspeed.exp.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.trace/tstatus.exp.diff?cvsroot=src&r1=1.1&r2=1.2
Comment 9 cvs-commit@gcc.gnu.org 2011-12-10 23:05:13 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	jkratoch@sourceware.org	2011-12-10 23:05:08

Modified files:
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.trace: ftrace.exp 

Log message:
	gdb/testsuite/
	PR testsuite/12649
	* gdb.trace/ftrace.exp (test_fast_tracepoints): Import gdb_prompt.
	Protect gdb_test_multiple by final $gdb_prompt match.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2975&r2=1.2976
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.trace/ftrace.exp.diff?cvsroot=src&r1=1.1&r2=1.2
Comment 10 cvs-commit@gcc.gnu.org 2012-05-15 13:09:06 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	jkratoch@sourceware.org	2012-05-15 13:08:58

Modified files:
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.base: dprintf.exp 

Log message:
	gdb/testsuite/
	PR testsuite/12649
	* gdb.base/dprintf.exp: Replace gdb_run_cmd by runto main.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3189&r2=1.3190
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/dprintf.exp.diff?cvsroot=src&r1=1.1&r2=1.2
Comment 11 cvs-commit@gcc.gnu.org 2012-07-04 14:57:31 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	jkratoch@sourceware.org	2012-07-04 14:57:24

Modified files:
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.base: dprintf.exp 

Log message:
	gdb/testsuite/
	PR 12649
	* gdb.base/dprintf.exp (Set dprintf style to agent): Add missing
	gdb_test_multiple $gdb_prompt terminator.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3274&r2=1.3275
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/dprintf.exp.diff?cvsroot=src&r1=1.4&r2=1.5
Comment 12 cvs-commit@gcc.gnu.org 2013-05-21 15:00:34 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	jkratoch@sourceware.org	2013-05-21 15:00:33

Modified files:
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.mi: mi-dprintf.exp 

Log message:
	gdb/testsuite/
	PR testsuite/12649
	* gdb.mi/mi-dprintf.exp (mi_continue_dprintf): Fix expect strings for
	racy matches.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3669&r2=1.3670
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.mi/mi-dprintf.exp.diff?cvsroot=src&r1=1.1&r2=1.2
Comment 13 cvs-commit@gcc.gnu.org 2013-05-24 15:37:26 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	jkratoch@sourceware.org	2013-05-24 15:37:25

Modified files:
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.mi: mi-dprintf.exp 

Log message:
	gdb/testsuite/
	PR testsuite/12649
	* gdb.mi/mi-dprintf.exp (mi_continue_dprintf) (mi 2nd dprintf): Replace
	$mi_gdb_prompt expectation by mi_expect_stop.
	(mi 1st dprintf, agent, mi 2nd dprintf, agent)
	(mi info dprintf second time): Replace them by mi_send_resuming_command
	and mi_expect_stop.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.3680&r2=1.3681
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.mi/mi-dprintf.exp.diff?cvsroot=src&r1=1.2&r2=1.3
Comment 14 Marek Polacek 2014-06-02 15:22:38 UTC
Unassigning.
Comment 15 cvs-commit@gcc.gnu.org 2014-08-20 18:23:04 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  2a31c6236de308f7109720230e70b96c5d5b966a (commit)
      from  469a34932ae4208240e98c843b01ea1f00892137 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2a31c6236de308f7109720230e70b96c5d5b966a

commit 2a31c6236de308f7109720230e70b96c5d5b966a
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Aug 20 18:55:54 2014 +0100

    Integrate PR 12649's race detector directly in the testsuite machinery
    
    This integrates Jan Kratochvil's nice race reproducer from PR
    testsuite/12649 into the testsuite infrustructure directly.
    
    With this, one only has to do either 'make check-read1' or 'make check
    READ1="1"' to preload the read1.so library into expect.
    
    Currently only enabled for glibc/GNU systems, and if
    build==host==target.
    
    gdb/testsuite/ChangeLog:
    
    	* Makefile.in (EXTRA_RULES, CC): New variables, get from
    	configure.
    	(EXPECT): Handle READ1 being set.
    	(all): Depend on EXTRA_RULES.
    	(check-read1, expect-read1, read1.so, read1): New rules.
    	* README (Testsuite Parameters): Document the READ1 make variable.
    	(Race detection): New section.
    	* configure: Regenerate.
    	* configure.ac: If build==host==target, and running under a
    	GNU/glibc system, add read1 to the extra Makefile rules.
    	(EXTRA_RULES): AC_SUBST it.
    	* lib/read1.c: New file.
    
    gdb/ChangeLog:
    
    	* Makefile.in (check-read1): New rule.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                                      |    4 ++
 gdb/Makefile.in                                    |    8 ++++
 gdb/testsuite/ChangeLog                            |   16 +++++++
 gdb/testsuite/Makefile.in                          |   44 ++++++++++++++++++--
 gdb/testsuite/README                               |   41 ++++++++++++++++++
 gdb/testsuite/configure                            |   10 ++++
 gdb/testsuite/configure.ac                         |    9 ++++
 .../expect-read1.c => testsuite/lib/read1.c}       |   16 ++++----
 8 files changed, 136 insertions(+), 12 deletions(-)
 copy gdb/{contrib/expect-read1.c => testsuite/lib/read1.c} (80%)