Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 182381 Details for
Bug 248532
utrace: tkill(SIGCONT) is not reported by waitpid() under ptrace
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
test case that counts failures, exits success/fail after many iterations
stopped-sigcont-hang-2.c (text/x-csrc), 4.01 KB, created by
Roland McGrath
on 2007-08-31 01:46:02 UTC
(
hide
)
Description:
test case that counts failures, exits success/fail after many iterations
Filename:
MIME Type:
Creator:
Roland McGrath
Created:
2007-08-31 01:46:02 UTC
Size:
4.01 KB
patch
obsolete
>/* Copyright 2007 Free Software Foundation, Inc. > > This program is free software; you can redistribute it and/or modify > it under the terms of the GNU General Public License as published by > the Free Software Foundation; either version 2 of the License, or > (at your option) any later version. > > This program is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > GNU General Public License for more details. > > You should have received a copy of the GNU General Public License > along with this program; if not, write to the Free Software > Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ > >#define _GNU_SOURCE >#include <signal.h> >#include <unistd.h> >#include <string.h> >#include <stdio.h> >#include <stdlib.h> >#include <errno.h> >#include <sys/wait.h> >#include <sys/ptrace.h> >#include <assert.h> >#include <fcntl.h> >#include <limits.h> >#include <ctype.h> >#include <linux/ptrace.h> > >#include <asm/unistd.h> >#include <unistd.h> >#define tkill(tid, sig) syscall (__NR_tkill, (tid), (sig)) > >#define DELAY() usleep (1000000 / 10) >/* Failure occurs either immediately or in about 20 runs. */ >#define LOOPS 10000 > >static pid_t child; > >static void >cleanup (void) >{ > if (child != 0) > kill (child, SIGKILL); >} > >static void >handler_fail (int signo) >{ > cleanup (); > > signal (SIGABRT, SIG_DFL); > abort (); >} > >int main (void) >{ > pid_t got_pid; > int status; > int loops; > > setbuf (stdout, NULL); > atexit (cleanup); > signal (SIGABRT, handler_fail); > signal (SIGALRM, handler_fail); > > int bad = 0; > for (loops = 0; loops < LOOPS; loops++) > { > child = fork (); > switch (child) > { > case -1: > abort (); > case 0: > raise (SIGSTOP); > for (;;) > pause (); > /* NOTREACHED */ > default: > break; > } > alarm (1); > > /* We must never WAITPID/WAITID on the child for this testcase. */ > > /* This delay is important as CHILD should become stopped in the meantime. > We could also check `/proc/${child}/status'. */ > DELAY (); > > /* Here is a point where we - as a debugger - start to attach. */ > errno = 0; > ptrace (PTRACE_ATTACH, child, NULL, NULL); > assert_perror (errno); > > /* This delay has no real effect here, just a proof it does not make > a difference. */ > DELAY (); > > /* `PTRACE_CONT, SIGSTOP' does not work in 100% cases as sometimes SIGSTOP > gets remembered by kernel during the first PTRACE_CONT later and we get > spurious SIGSTOP event. Expecting the signal may get delivered to > a different task of the thread group. > `tkill (SIGSTOP)' has no effect in this moment (it is already stopped). */ > errno = 0; > tkill (child, SIGCONT); > assert_perror (errno); > > /* Here must not be any DELAY(); utrace-specific, not understood why. */ > > got_pid = waitpid (child, &status, 0); > assert (got_pid == child); > assert (WIFSTOPPED (status)); > /* If we got SIGSTOP here it is a bug of the patch > https://bugzilla.redhat.com/show_bug.cgi?id=248532#c5 > tkill (SIGCONT) above should clear all the pending SIGSTOPs. */ > if (WSTOPSIG (status) != SIGCONT) > { > error (0, 0, "%s after %d iterations", > strsignal (WSTOPSIG (status)), loops); > ++bad; > } > else > { > /* This point is no longer a part of the test, if we want to validate > ptrace(2) below here also must be no DELAY(). */ > > /* At this moment we should be already able to ptrace(2) the inferior. > After the fix of Bug 248532 Comment 5 above there should be no problem > here. */ > errno = 0; > ptrace (PTRACE_PEEKUSR, child, (void *) 0UL, NULL); > assert_perror (errno); > } > > /* Cleanup. */ > errno = 0; > kill (child, SIGKILL); > assert_perror (errno); > > got_pid = waitpid (child, &status, 0); > assert (got_pid == child); > > alarm (0); > } > > printf ("%d bad in %d iterations: %.2f%%\n", > bad, LOOPS, 100.0 * bad / LOOPS); > if (bad) > return 1; > > puts ("PASS"); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 248532
:
159411
|
179961
|
181161
|
182321
| 182381 |
185931
|
187231
|
191741