Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp15723imu; Tue, 27 Nov 2018 07:13:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/X3F1lHTdxZcfFUK1nrHZdsz2KJYgs9ME8bmIAwsiDuEbyyr1kPrtgsfu2GtNkpXMK9aYFD X-Received: by 2002:a62:482:: with SMTP id 124-v6mr29660pfe.156.1543331612140; Tue, 27 Nov 2018 07:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543331612; cv=none; d=google.com; s=arc-20160816; b=ycekTR2lbaAJYY2L/RW5HUPLReq64IPIOPGF4J7uio1wWW0IWGsQNIZZe/u7Uf6Lu8 Nvvl9OOw6ZNpCUMAJUlSxk/NvsOneSHO1Vzay+o4Gi+rWIAlfp5HK2lIVyMMTjH5nH+m fZ0VSJYKpSt7iM0A3cMd7hMa5OQHYKcjC6VgCAcF3Rxc4iP+yp9vTOrt4kPiiC45JIaD L82lcdJZV4RtBt+euapATP6srQuBixiD3t/Bbe8T24CiAxsC1PD3nBMOTRDW7wZ9v8ow TPNLIdH/bBPM09pOPi0gFqGI2HD/OiS0G2HEPa2EYDvXj2pGuo/qArbA+jNw4CDHGuVM VhkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:spamdiagnosticmetadata :spamdiagnosticoutput:content-language:accept-language:reply-to :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from:dkim-signature; bh=aniIEqc+WY2PvSsd46gUT4u2YB7P+qfzarIUj6djIv8=; b=UeJKHg5xOaSE62PM0qAeKll9WKjUu/BDGIAgNSINplj09MiIDfNjOUmOJBar+suZ1E GOdmiafwZfaKlzT+DC9G+Se4Iboi4DJYvjzT9XM6ZH7xTnFyY4Cdxmuuk+iFdNth7sUI s/YwxzK8Knwa2cNbPZdFDzb5ToV0ktdgy5I/A2hKy/k2rU/evV+OQvuS8jBmP7rcjotx SRg2folWjolGm4NypvjrFPEJK12xO63VCF/Pb5U/m5R8ATu6lx3mFZBf8YEkPP4qRg4T 2EpCBUGBH5pf+Kz68FHQx3TQqNCVLWrIwJtvTYpEkexeIpbWdPEz07Agv8A7owQ5CXM9 Fw2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@concurrentrt.onmicrosoft.com header.s=selector1-concurrentrt-com02e header.b=KavCw79L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4-v6si4289737pla.189.2018.11.27.07.12.48; Tue, 27 Nov 2018 07:13:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@concurrentrt.onmicrosoft.com header.s=selector1-concurrentrt-com02e header.b=KavCw79L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729437AbeK1CIZ (ORCPT + 99 others); Tue, 27 Nov 2018 21:08:25 -0500 Received: from mail-eopbgr700122.outbound.protection.outlook.com ([40.107.70.122]:12352 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729274AbeK1CIZ (ORCPT ); Tue, 27 Nov 2018 21:08:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=concurrentrt.onmicrosoft.com; s=selector1-concurrentrt-com02e; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aniIEqc+WY2PvSsd46gUT4u2YB7P+qfzarIUj6djIv8=; b=KavCw79LHKACUKqt6Ht6wXQ1XVYAIUWiqwrVF1hOYl1ZjtJEDAlLgBe1+R37Wh7uag2AzDkwVSZkUqSFe5LACoxtheFgtYjcco57Q6UfHtxo60JlcpqGJHcQ/OGY0KB06aflGrTrCyq6cmFxbeITRtyaSXhCSaB9UnmKXob3C6c= Received: from DM6PR11MB2570.namprd11.prod.outlook.com (20.176.99.12) by DM6PR11MB2891.namprd11.prod.outlook.com (20.177.216.88) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.20; Tue, 27 Nov 2018 15:10:07 +0000 Received: from DM6PR11MB2570.namprd11.prod.outlook.com ([fe80::186f:6fba:5a0c:69ec]) by DM6PR11MB2570.namprd11.prod.outlook.com ([fe80::186f:6fba:5a0c:69ec%4]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 15:10:07 +0000 From: Joe Korty To: Clark Williams CC: Steven Rostedt , "julia@ni.com" , "tglx@linutronix.de" , "bigeasy@linutronix.de" , "oleg@redhat.com" , "linux-rt-users@vger.kernel.org" , "linux-kernel@vger.kernel.org" , John Kacur Subject: Re: [ptrace, rt] erratic behaviour in PTRACE_SINGLESET on 4.13-rt and later. Thread-Topic: [ptrace, rt] erratic behaviour in PTRACE_SINGLESET on 4.13-rt and later. Thread-Index: AQHUgECMj/wXEoj7Wkyq0VvWdFU8Ow== Date: Tue, 27 Nov 2018 15:10:07 +0000 Message-ID: <20181127151004.GB15742@zipoli.concurrent-rt.com> References: <20181119194619.GA32121@zipoli.concurrent-rt.com> <20181120122900.625b1d98@gandalf.local.home> <20181127085819.7e0865ee@tagon> In-Reply-To: <20181127085819.7e0865ee@tagon> Reply-To: Joe Korty Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-clientproxiedby: BN4PR13CA0013.namprd13.prod.outlook.com (2603:10b6:403:3::23) To DM6PR11MB2570.namprd11.prod.outlook.com (2603:10b6:5:c6::12) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Joe.Korty@concurrent-rt.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [12.220.59.2] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM6PR11MB2891;6:VlpywIr0nRmU0fwJq8o79zNR4fcpiwoHyxCE0+gWrN+oxL/gqDXa9HHGFSDbP/2Vn7RF3lndRC/xQvPGR3MYFMFf0cfeJf+MlrknUx2Es3yupFPf0eLJDztbTaED0GRqiWl5cV+a5xy0e/1vRdUqugzgDrUGwcLizoiURjnPAl7nKo20aeo8FoEPqghsEv0Hyy8VPthO9zO/DhJdSGDmRn5hzNGdd3Wh9BK1aMqij+JLzxpbmhW8d50Cel1hfplzLXxEpYE63lzVcVSth2VPB8DRycFz7ieiQdVMcLqpFlLIVjsrg3yyy3C7z56Vm1epegdZyuXen0k3R0sxQdRrDLdr8mhI6GvQvcTIYG15AL6komPdVvtQFA53DwShwrd+omYuc70xrO2ZO4S7VIuhbFxZuTB1MlKraEzp/5FZsntfDtBdBzlk7odgi6FS1ZtWobB2tNk0T3xtS3x6mzKEHw==;5:nSnlPT0/dni/7m2Q5jQTWni8g/NyfOFzUC4gRHbVKtXoHhrTb0mrhZ5u1Xrl4/LyJ3vxIXdy5kIdYnK/EqrQtlJ/r09LoOF5GndUhIhtPHHD/+cbDTCJ0LraXyktFfQxpNDgX//9vjF6Ikqhf4M98yPomI/tZ/DoU7fq0Yakob8=;7:ShGXDlQ8Ufk6HyKNYYDAxPfaULXuhj1lFYVxLwcTw6WYOp5RpkUhmS1so0y77ga1Gr3AoxNnkcDmnJe5VhhYsyzg2Bt/hmPAwgekViWvNeaAiYWZk7hUV4GXsz5L8v7VUQwFktczKO+9zVVzL1Ji+Q== x-ms-office365-filtering-correlation-id: 99397572-3d98-46be-b5ef-08d6547a6ab2 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600074)(711020)(2017052603328)(7153060)(49563074)(7193020);SRVR:DM6PR11MB2891; x-ms-traffictypediagnostic: DM6PR11MB2891: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(102415395)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231443)(944501410)(4983020)(52105112)(3002001)(148016)(149066)(150057)(6041310)(20161123560045)(2016111802025)(20161123564045)(20161123562045)(20161123558120)(6043046)(201708071742011)(7699051)(76991095);SRVR:DM6PR11MB2891;BCL:0;PCL:0;RULEID:;SRVR:DM6PR11MB2891; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(136003)(366004)(39840400004)(396003)(346002)(199004)(189003)(5660300001)(486006)(2906002)(44832011)(4326008)(86362001)(68736007)(14454004)(8936002)(6246003)(476003)(66066001)(446003)(3846002)(6116002)(1076002)(97736004)(106356001)(6916009)(3450700001)(105586002)(6436002)(11346002)(99936001)(6512007)(53946003)(6486002)(229853002)(4744004)(71200400001)(71190400001)(316002)(53936002)(99286004)(508600001)(14444005)(256004)(5024004)(43066004)(33656002)(54906003)(102836004)(305945005)(6506007)(386003)(81166006)(81156014)(7736002)(186003)(72206003)(26005)(52116002)(25786009)(8676002)(76176011)(21314003);DIR:OUT;SFP:1102;SCL:1;SRVR:DM6PR11MB2891;H:DM6PR11MB2570.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: concurrent-rt.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: oYToheSt4/ay7zljMFZm3+YelGGOI4FCnJK3kC1V3+mnoZ4NC0aTQjrOj6V39xJRDO53+e6TFlXewqwc8yjE+hSy4sAkKWo3PWitXldYN4cedUsHibzF3dB93mHIu6XFmooY3eZWxho5W6sujPzETiPXhKJHeEabdNN6QfqthPhzxdyf+JrF69foyNg1L5NUkNTJ3w9nBgDeHZNtHASoUT9kGgPsIrtYfxKjdjqd4otZifFBjv7Vy/+IjgBevfqy98rChJOyUay/JjABXYAF4ceYRln1AhjuuawJjklRjTiTtwaOd68dEm3s8/Ph2WZ3cH2Akr+2XJjrx35f4h0dGPLEmeewSiXtO5qq4aZq2aQ= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: multipart/mixed; boundary="_002_20181127151004GB15742zipoliconcurrentrtcom_" MIME-Version: 1.0 X-OriginatorOrg: concurrent-rt.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99397572-3d98-46be-b5ef-08d6547a6ab2 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 15:10:07.6094 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 38747689-e6b0-4933-86c0-1116ee3ef93e X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB2891 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --_002_20181127151004GB15742zipoliconcurrentrtcom_ Content-Type: text/plain; charset="us-ascii" Content-ID: <5D7AB52A8E7A7C40BF08813EB22A1D4D@namprd11.prod.outlook.com> Content-Transfer-Encoding: quoted-printable On Tue, Nov 27, 2018 at 08:58:19AM -0600, Clark Williams wrote: > Joe, >=20 > This looks interesting. Do you have a git repo where I can pull the > source? >=20 > Clark Hi Clark, No I don't, sorry. I am attaching the LAG version, it is a few dozen lines shorter than the version I first sent out to the mailing list. Joe PS: Oh, I forgot to do.... Signed-off-by: Joe Korty > On Tue, 20 Nov 2018 12:29:00 -0500 > Steven Rostedt wrote: >=20 > > [ Adding Clark and John who manage the rt-tests repo ] > >=20 > > -- Steve > >=20 > > On Mon, 19 Nov 2018 19:46:23 +0000 > > Joe Korty wrote: > >=20 > > > Hi Julia & the RT team, > > >=20 > > > The following program might make a good addition to the rt > > > test suite. It tests the reliability of PTRACE_SINGLESTEP. > > > It does by default 10,000 ssteps against a simple, > > > spinner tracee. Also by default, it spins off ten of these > > > tracer/tracee pairs, all of which are to run concurrently. > > >=20 > > > Starting with 4.13-rt, this test occasionally encounters a > > > sstep whose waitpid returns a WIFSIGNALED (signal SIGTRAP) > > > rather than a WIFSTOPPED. This usually happens after > > > thousands of ssteps have executed. Having multiple > > > tracer/tracee pairs running dramatically increases the > > > chances of failure. > > >=20 > > > The is what the test output looks like for a good run: > > >=20 > > > #forks: 10 > > > #steps: 10000 > > > =20 > > > forktest#0/22872: STARTING > > > forktest#7/22879: STARTING > > > forktest#8/22880: STARTING > > > forktest#6/22878: STARTING > > > forktest#5/22877: STARTING > > > forktest#3/22875: STARTING > > > forktest#4/22876: STARTING > > > forktest#9/22882: STARTING > > > forktest#2/22874: STARTING > > > forktest#1/22873: STARTING > > > forktest#0/22872: EXITING, no error > > > forktest#8/22880: EXITING, no error > > > forktest#3/22875: EXITING, no error > > > forktest#7/22879: EXITING, no error > > > forktest#6/22878: EXITING, no error > > > forktest#5/22877: EXITING, no error > > > forktest#2/22874: EXITING, no error > > > forktest#4/22876: EXITING, no error > > > forktest#9/22882: EXITING, no error > > > forktest#1/22873: EXITING, no error > > > All tests PASSED. > > >=20 > > > This is what the test output looks like for a failing run: > > >=20 > > > #forks: 10 > > > #steps: 10000 > > > =20 > > > forktest#0/22906: STARTING > > > forktest#1/22907: STARTING > > > forktest#2/22909: STARTING > > > forktest#3/22911: STARTING > > > forktest#4/22912: STARTING > > > forktest#5/22915: STARTING > > > forktest#6/22916: STARTING > > > forktest#7/22919: STARTING > > > forktest#8/22920: STARTING > > > forktest#9/22923: STARTING > > > forktest#2/22909: EXITING, ERROR: wait on PTRACE_SINGLESTEP #9: wan= ted STATE_STOPPED, saw STATE_SIGNALED instead (and saw signo 5 too) > > > forktest#5/22915: EXITING, no error > > > forktest#3/22911: EXITING, ERROR: wait on PTRACE_SINGLESTEP #7953: = wanted STATE_STOPPED, saw STATE_SIGNALED instead (and saw signo 5 too) > > > forktest#0/22906: EXITING, ERROR: wait on PTRACE_SINGLESTEP #5072: = wanted STATE_STOPPED, saw STATE_SIGNALED instead (and saw signo 5 too) > > > forktest#9/22923: EXITING, ERROR: wait on PTRACE_SINGLESTEP #7992: = wanted STATE_STOPPED, saw STATE_SIGNALED instead (and saw signo 5 too) > > > forktest#4/22912: EXITING, ERROR: wait on PTRACE_SINGLESTEP #9923: = wanted STATE_STOPPED, saw STATE_SIGNALED instead (and saw signo 5 too) > > > forktest#1/22907: EXITING, ERROR: wait on PTRACE_SINGLESTEP #7723: = wanted STATE_STOPPED, saw STATE_SIGNALED instead (and saw signo 5 too) > > > forktest#7/22919: EXITING, ERROR: wait on PTRACE_SINGLESTEP #5036: = wanted STATE_STOPPED, saw STATE_SIGNALED instead (and saw signo 5 too) > > > forktest#8/22920: EXITING, ERROR: wait on PTRACE_SINGLESTEP #4943: = wanted STATE_STOPPED, saw STATE_SIGNALED instead (and saw signo 5 too) > > > forktest#6/22916: EXITING, no error > > > One or more tests FAILED. > > >=20 > > > Here are the observations from my testing so far: > > >=20 > > > - It has never failed when confined to a single cpu. > > > - It has never failed on !rt kernels. > > > - It has never failed on any kernel prior to 4.13. > > > - More failures than what chance would dictate happen > > > near the end of a test run (ie, if a test of 10,000=20 > > > steps is run, the failure will be at the 9,xxx'th step, > > > if 100,000 steps are run, the failure will be at > > > the 9x,xxx'th step). > > >=20 > > > The above results are from kernels 4.{4,9,11,13,14,19}-rt > > > and some !rt's of these as well. > > >=20 > > > I have yet to see or hear of this bug, if it is a bug, > > > giving anyone a problem in a debug session. It might not > > > even be a bug but merely expected behaviour. And of course > > > there is the possibility of a misuse of ptrace/waitpid in > > > my test program. Its API, after all, is rather convoluted. > > >=20 > > > Regards, > > > Joe > > >=20 > > >=20 > > >=20 > > >=20 > > > /* > > > * Have a tracer do a bunch of PTRACE_SINGLESTEPs against > > > * a tracee as fast as possible. Create several of these > > > * tracer/tracee pairs and see if they can be made to > > > * interfere with each other. > > > * > > > * Usage: > > > * ssdd nforks niters > > > * Where: > > > * nforks - number of tracer/tracee pairs to fork off. > > > * default 10. > > > * niters - number of PTRACE_SINGLESTEP iterations to > > > * do before declaring success, for each tracer/ > > > * tracee pair set up. Default 10,000. > > > * > > > * The tracee waits on each PTRACE_SINGLESTEP with a waitpid(2) > > > * and checks that waitpid's return values for correctness. > > > */ > > > #include > > > #include > > > #include > > > #include > > > #include > > > #include > > > #include > > >=20 > > > #include > > > #include > > > #include > > >=20 > > > /* do_wait return values */ > > > #define STATE_EXITED 1 > > > #define STATE_STOPPED 2 > > > #define STATE_SIGNALED 3 > > > #define STATE_UNKNOWN 4 > > > #define STATE_ECHILD 5 > > > #define STATE_EXITED_TSIG 6 /* exited with termination signal */ > > > #define STATE_EXITED_ERRSTAT 7 /* exited with non-zero status */ > > >=20 > > > char *state_name[] =3D { > > > [STATE_EXITED] =3D "STATE_EXITED", > > > [STATE_STOPPED] =3D "STATE_STOPPED", > > > [STATE_SIGNALED] =3D "STATE_SIGNALED", > > > [STATE_UNKNOWN] =3D "STATE_UNKNOWN", > > > [STATE_ECHILD] =3D "STATE_ECHILD", > > > [STATE_EXITED_TSIG] =3D "STATE_EXITED_TSIG", > > > [STATE_EXITED_ERRSTAT] =3D "STATE_EXITED_ERRSTAT" > > > }; > > >=20 > > > const char *get_state_name(int state) > > > { > > > if (state < STATE_EXITED || state > STATE_EXITED_ERRSTAT) > > > return "?"; > > > return state_name[state]; > > > } > > >=20 > > > #define unused __attribute__((unused)) > > >=20 > > > static int got_sigchld; > > >=20 > > > static int do_wait(pid_t *wait_pid, int *ret_sig) > > > { > > > int status, child_status; > > >=20 > > > *ret_sig =3D -1; /* initially mark 'nothing returned' */ > > >=20 > > > while (1) { > > > status =3D waitpid(-1, &child_status, WUNTRACED | __WALL); > > > if (status =3D=3D -1) { > > > if (errno =3D=3D EINTR) > > > continue; > > > if (errno =3D=3D ECHILD) { > > > *wait_pid =3D (pid_t)0; > > > return STATE_ECHILD; > > > } > > > printf("do_wait/%d: EXITING, ERROR: " > > > "waitpid() returned errno %d\n", > > > getpid(), errno); > > > exit(1); > > > } > > > break; > > > } > > > *wait_pid =3D (pid_t)status; > > >=20 > > > if (WIFEXITED(child_status)) { > > > if (WIFSIGNALED(child_status)) > > > return STATE_EXITED_TSIG; > > > if (WEXITSTATUS(child_status)) > > > return STATE_EXITED_ERRSTAT; > > > return STATE_EXITED; > > > } > > > if (WIFSTOPPED(child_status)) { > > > *ret_sig =3D WSTOPSIG(child_status); > > > return STATE_STOPPED; > > > } > > > if (WIFSIGNALED(child_status)) { > > > *ret_sig =3D WTERMSIG(child_status); > > > return STATE_SIGNALED; > > > } > > > return STATE_UNKNOWN; > > > } > > >=20 > > > int check_sigchld(void) > > > { > > > int i; > > > /* > > > * The signal is asynchronous so give it some > > > * time to arrive. > > > */ > > > for (i =3D 0; i < 10 && !got_sigchld; i++) > > > usleep(1000); /* 10 msecs */ > > > for (i =3D 0; i < 10 && !got_sigchld; i++) > > > usleep(2000); /* 20 + 10 =3D 30 msecs */ > > > for (i =3D 0; i < 10 && !got_sigchld; i++) > > > usleep(4000); /* 40 + 30 =3D 70 msecs */ > > > for (i =3D 0; i < 10 && !got_sigchld; i++) > > > usleep(8000); /* 80 + 40 =3D 150 msecs */ > > > for (i =3D 0; i < 10 && !got_sigchld; i++) > > > usleep(16000); /* 160 + 150 =3D 310 msecs */ > > > for (i =3D 0; i < 10 && !got_sigchld; i++) > > > usleep(32000); /* 320 + 310 =3D 630 msecs */ > > >=20 > > > return got_sigchld; > > > } > > >=20 > > > pid_t parent; > > > int nforks =3D 10; > > > int nsteps =3D 10000; > > >=20 > > > static void sigchld(int sig, unused siginfo_t * info, unused void *ar= g) > > > { > > > got_sigchld =3D 1; > > > } > > >=20 > > > static void child_process(void) > > > { > > > unused volatile int i; > > >=20 > > > /* wait for ptrace attach */ > > > usleep(100000); > > > while (1) > > > i =3D 0; > > > } > > >=20 > > > static int forktests(int testid) > > > { > > > int i, status, ret_sig; > > > long pstatus; > > > pid_t child, wait_pid; > > > struct sigaction act, oact; > > >=20 > > > parent =3D getpid(); > > > printf("forktest#%d/%d: STARTING\n", testid, parent); > > >=20 > > > child =3D fork(); > > > if (child =3D=3D -1) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "fork returned errno %d\n", testid, parent, errno); > > > exit(1); > > > } > > > if (!child) > > > child_process(); > > >=20 > > > act.sa_sigaction =3D sigchld; > > > sigemptyset(&act.sa_mask); > > > act.sa_flags =3D SA_SIGINFO; > > > status =3D sigaction(SIGCHLD, &act, &oact); > > > if (status) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "sigaction returned %d, errno %d\n", > > > testid, parent, status, errno); > > > exit(1); > > > } > > >=20 > > > /* give both our child and parent time to set things up */ > > > usleep(125000); > > >=20 > > > /* > > > * Attach to the child. > > > */ > > > pstatus =3D ptrace(PTRACE_ATTACH, child, NULL, NULL); > > > if (pstatus =3D=3D ~0l) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "attach failed. errno %d\n", > > > testid, getpid(), errno); > > > exit(1); > > > } > > >=20 > > > /* > > > * The attach should cause the child to receive a signal. > > > */ > > > status =3D do_wait(&wait_pid, &ret_sig); > > > if (wait_pid !=3D child) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "attach: Unexpected wait pid %d\n", > > > testid, getpid(), wait_pid); > > > exit(1); > > > } > > > if (status !=3D STATE_STOPPED) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "attach: wait on PTRACE_ATTACH returned %d " > > > "[%s, wanted STATE_STOPPED], signo %d\n", > > > testid, getpid(), status, get_state_name(status), > > > ret_sig); > > > exit(1); > > > } > > > else if (!check_sigchld()) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "wait on PTRACE_ATTACH saw a SIGCHLD count of %d, should be = 1\n", > > > testid, getpid(), got_sigchld); > > > exit(1); > > > } > > > got_sigchld =3D 0; > > >=20 > > >=20 > > > /* > > > * Generate 'nsteps' PTRACE_SINGLESTEPs, make sure they all actually= step > > > * the tracee. > > > */ > > > for (i =3D 0; i < nsteps; i++) { > > > pstatus =3D ptrace(PTRACE_SINGLESTEP, child, NULL, NULL); > > >=20 > > > if (pstatus) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "PTRACE_SINGLESTEP #%d: returned status %ld, " > > > "errno %d, signo %d\n", > > > testid, getpid(), i, pstatus, errno, ret_sig); > > > exit(1); > > > } > > >=20 > > > status =3D do_wait(&wait_pid, &ret_sig); > > > if (wait_pid !=3D child) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "wait on PTRACE_SINGLESTEP #%d: returned wrong pid %d, " > > > "expected %d\n", > > > testid, getpid(), i, wait_pid, child); > > > exit(1); > > > } > > > if (status !=3D STATE_STOPPED) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "wait on PTRACE_SINGLESTEP #%d: wanted STATE_STOPPED, " > > > "saw %s instead (and saw signo %d too)\n", > > > testid, getpid(), i, > > > get_state_name(status), ret_sig); > > > exit(1); > > > } > > > if (ret_sig !=3D SIGTRAP) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "wait on PTRACE_SINGLESTEP #%d: returned signal %d, " > > > "wanted SIGTRAP\n", > > > testid, getpid(), i, ret_sig); > > > exit(1); > > > } > > > if (!check_sigchld()) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "wait on PTRACE_SINGLESTEP #%d: no SIGCHLD seen " > > > "(signal count =3D=3D 0), signo %d\n", > > > testid, getpid(), i, ret_sig); > > > exit(1); > > > } > > > got_sigchld =3D 0; > > > } > > >=20 > > > /* > > > * We are all done, kill the tracee and wait for it to die. We test > > > * the killing results as much as the above attach and sstep results= , > > > * though failure here really isn't the point of this test. > > > */ > > > status =3D kill(child, SIGKILL); > > >=20 > > > if (status) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "kill of child %d returned %d\n", > > > testid, getpid(), child, errno); > > > exit(1); > > > } > > >=20 > > > status =3D do_wait(&wait_pid, &ret_sig); > > > if (wait_pid !=3D child) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "kill: Unexpected wait pid %d\n", > > > testid, getpid(), wait_pid); > > > exit(1); > > > } > > > if (status !=3D STATE_SIGNALED) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "kill: Unexpected child, do_wait status %d " > > > "[%s, wanted STATE_SIGNALED]\n", > > > testid, getpid(), status, get_state_name(status)); > > > exit(1); > > > } > > > if (ret_sig !=3D SIGKILL) { > > > printf("forktest#%d/%d: EXITING, ERROR: " > > > "kill: Unexpected child signal %d\n", > > > testid, getpid(), ret_sig); > > > exit(1); > > > } > > >=20 > > > printf("forktest#%d/%d: EXITING, no error\n", testid, parent); > > > exit(0); > > > } > > >=20 > > > int main(int argc, char **argv) > > > { > > > int i, ret_sig, status; > > > pid_t child =3D 0, wait_pid; > > > int error =3D 0; > > >=20 > > > setbuf(stdout, NULL); > > >=20 > > > argc--, argv++; > > > if (argc) { > > > nforks =3D atoi(*argv); > > > argc--, argv++; > > > if (argc) > > > nsteps =3D atoi(*argv); > > > } > > > printf("#forks: %d\n", nforks); > > > printf("#steps: %d\n", nsteps); > > > printf("\n"); > > >=20 > > > for (i =3D 0; i < nforks; i++) { > > > child =3D fork(); > > > if (child =3D=3D -1) { > > > printf("main: fork returned errno %d\n", errno); > > > exit(1); > > > } > > > if (!child) > > > forktests(i); > > > } > > >=20 > > > for (i =3D 0; i < nforks; i++) { > > > status =3D do_wait(&wait_pid, &ret_sig); > > > if (status !=3D STATE_EXITED) { > > > if (0) printf("main/%d: ERROR: " > > > "forktest#%d unexpected do_wait status %d " > > > "[%s, wanted STATE_EXITED]\n", > > > getpid(), wait_pid, status, > > > get_state_name(status)); > > > error =3D 1; > > > } > > > } > > >=20 > > > printf("%s.\n", error ? > > > "One or more tests FAILED" : > > > "All tests PASSED"); > > > exit(error); > > > } =20 > >=20 >=20 >=20 > --=20 > The United States Coast Guard > Ruining Natural Selection since 1790 --_002_20181127151004GB15742zipoliconcurrentrtcom_ Content-Type: text/plain; name="ssdd.c" Content-Description: ssdd.c Content-Disposition: attachment; filename="ssdd.c"; size=8043; creation-date="Tue, 27 Nov 2018 15:10:07 GMT"; modification-date="Tue, 27 Nov 2018 15:10:07 GMT" Content-ID: <29A51744C386C846839CFCAB252F3F37@namprd11.prod.outlook.com> Content-Transfer-Encoding: base64 LyoNCiAqIEhhdmUgYSB0cmFjZXIgZG8gYSBidW5jaCBvZiBQVFJBQ0VfU0lOR0xFU1RFUHMgYWdh aW5zdA0KICogYSB0cmFjZWUgYXMgZmFzdCBhcyBwb3NzaWJsZS4gIENyZWF0ZSBzZXZlcmFsIG9m IHRoZXNlDQogKiB0cmFjZXIvdHJhY2VlIHBhaXJzIGFuZCBzZWUgaWYgdGhleSBjYW4gYmUgbWFk ZSB0bw0KICogaW50ZXJmZXJlIHdpdGggZWFjaCBvdGhlci4NCiAqDQogKiBVc2FnZToNCiAqICAg c3NkZCBuZm9ya3Mgbml0ZXJzDQogKiBXaGVyZToNCiAqICAgbmZvcmtzIC0gbnVtYmVyIG9mIHRy YWNlci90cmFjZWUgcGFpcnMgdG8gZm9yayBvZmYuDQogKiAgICAgICAgICAgIGRlZmF1bHQgMTAu DQogKiAgIG5pdGVycyAtIG51bWJlciBvZiBQVFJBQ0VfU0lOR0xFU1RFUCBpdGVyYXRpb25zIHRv DQogKiAgICAgICAgICAgIGRvIGJlZm9yZSBkZWNsYXJpbmcgc3VjY2VzcywgZm9yIGVhY2ggdHJh Y2VyLw0KICogICAgICAgICAgICB0cmFjZWUgcGFpciBzZXQgdXAuICBEZWZhdWx0IDEwLDAwMC4N CiAqDQogKiBUaGUgdHJhY2VyIHdhaXRzIG9uIGVhY2ggUFRSQUNFX1NJTkdMRVNURVAgd2l0aCBh IHdhaXRwaWQoMikNCiAqIGFuZCBjaGVja3MgdGhhdCB3YWl0cGlkJ3MgcmV0dXJuIHZhbHVlcyBm b3IgY29ycmVjdG5lc3MuDQogKi8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