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 191741 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.
Raceless testcase from Comment 16.
stopped-sigcont-hang-4.c (text/plain), 4.47 KB, created by
Jan Kratochvil
on 2007-09-10 15:57:53 UTC
(
hide
)
Description:
Raceless testcase from Comment 16.
Filename:
MIME Type:
Creator:
Jan Kratochvil
Created:
2007-09-10 15:57:53 UTC
Size:
4.47 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 <error.h> > >#include <asm/unistd.h> >#include <unistd.h> >#define tkill(tid, sig) syscall (__NR_tkill, (tid), (sig)) > >/* 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); > /* Be careful with SIGALRM / ALARM due to false positives under load. */ > > 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; > } > > /* We must never WAITPID/WAITID on the child for this testcase. */ > > /* We need to wait till CHILD becomes stopped. Any DELAY may be > * race-prone, check its `/proc/${child}/status'. */ > alarm (60); > for (;;) > { > char buf[0x1000]; > ssize_t got; > int fd, i; > > snprintf (buf, sizeof buf, "/proc/%d/status", (int) child); > fd = open (buf, O_RDONLY); > assert (fd != -1); > got = read (fd, buf, sizeof buf); > assert (got > 0); > assert (got < sizeof buf); > buf[got] = 0; > i = close (fd); > assert (i == 0); > if (strstr (buf, "\nState:\tT (stopped)\n")) > break; > } > alarm (0); > > /* Here is a point where we - as a debugger - start to attach. */ > errno = 0; > ptrace (PTRACE_ATTACH, child, NULL, NULL); > assert_perror (errno); > > /* Any DELAY makes no difference here. */ > > /* `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() to properly test utrace. The bug was > that WAITPID reported a previous job-control-stop condition even > though SIGCONT has cleared the TASK_STOPPED state. */ > > 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); > } > > 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