NetBSD Problem Report #49662
From www@NetBSD.org Fri Feb 13 12:16:46 2015
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 69EFCA654B
for <gnats-bugs@gnats.NetBSD.org>; Fri, 13 Feb 2015 12:16:46 +0000 (UTC)
Message-Id: <20150213121644.DAA38A65BB@mollari.NetBSD.org>
Date: Fri, 13 Feb 2015 12:16:44 +0000 (UTC)
From: prlw1@cam.ac.uk
Reply-To: prlw1@cam.ac.uk
To: gnats-bugs@NetBSD.org
Subject: gdb has trouble with threaded programs
X-Send-Pr-Version: www-1.0
>Number: 49662
>Category: bin
>Synopsis: gdb has trouble with threaded programs
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kamil
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Feb 13 12:20:00 +0000 2015
>Closed-Date: Tue Jun 04 12:55:33 +0000 2019
>Last-Modified: Tue Jun 04 12:55:33 +0000 2019
>Originator: Patrick Welche
>Release: NetBSD-7.99.4/amd64 (9 Feb 2015)
>Organization:
>Environment:
>Description:
gdb looses track debugging the following "simple" test case.
>How-To-Repeat:
Find a trivial program with a bug, ioctltest.c:
#include <sys/ioctl.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
int fd, owner;
fd = open("/dev/zero", O_RDONLY);
/* should set ENOTTY */
if (ioctl(fd, FIOGETOWN, &owner) == -1)
err(1, NULL);
printf("/dev/zero is owned by uid %d.\n", owner);
close(fd);
return 0;
}
Aim to find out what is up with the ioctl() call, so fire up a rump server:
rump_allserver unix:///tmp/sock
e.g. for /bin/sh, set
export RUMP_SERVER=unix:///tmp/sock
export LD_PRELOAD=/usr/lib/librumphijack.so
export RUMPHIJACK_RETRYCONNECT=inftime
export RUMPHIJACK=path=/rump,blanket=/dev/zero
$ gdb ioctltest
GNU gdb (GDB) 7.7.1
...
(gdb) break ioctl
Breakpoint 1 at 0x400800
(gdb) run
Starting program: /home/prlw1/NetBSD/thread/ioctltest
[Switching to LWP 1]
Breakpoint 1, ioctl (fd=131, cmd=1074030203)
at /usr/src/lib/librumphijack/hijack.c:1326
1326 if (fd_isrump(fd)) {
(gdb) n
1327 fd = fd_host2rump(fd);
(gdb)
1328 op_ioctl = GETSYSCALL(rump, IOCTL);
(gdb)
1333 va_start(ap, cmd);
(gdb)
1334 rv = op_ioctl(fd, cmd, va_arg(ap, void *));
(gdb) s
rump___sysimpl_ioctl (fd=3, com=1074030203, data=0x7f7fffffda68)
at /usr/src/lib/librumpclient/../../sys/rump/librump/rumpkern/rump_syscalls.c:970
970 int error = 0;
(gdb) n
971 int rv = -1;
(gdb)
974 memset(&callarg, 0, sizeof(callarg));
(gdb)
975 SPARG(&callarg, fd) = fd;
(gdb)
976 SPARG(&callarg, com) = com;
(gdb)
977 SPARG(&callarg, data) = data;
(gdb)
979 error = rsys_syscall(SYS_ioctl, &callarg, sizeof(callarg), retval);
(gdb) s
rumpclient_syscall (sysnum=54, data=0x7f7fffffd910, dlen=24,
retval=0x7f7fffffd930) at /usr/src/lib/librumpclient/rumpclient.c:583
583 pthread_sigmask(SIG_SETMASK, &fullset, &omask);
(gdb)
Now watch the debugged program chew 100% CPU, and ctl-C in gdb fails.
Sending a STOP to the debugged program gives:
Program received signal SIGSTOP, Stopped (signal).
0x00007f7ff680daf1 in syscall_req (spc=0x7f7ff6a13580, omask=0x7f7fffffd8c0,
sysnum=54, data=0x7f7fffffd910, dlen=24, resp=0xffffd8b8)
at /usr/src/lib/librumpclient/rumpclient.c:382
382 *resp = rw.rw_data;
(gdb) c
Continuing.
goes back to 100% CPU usage, rather than the expected:
ioctltest: Operation not supported by device
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: bin-bug-people->kamil
Responsible-Changed-By: kamil@NetBSD.org
Responsible-Changed-When: Sat, 07 Oct 2017 00:03:02 +0200
Responsible-Changed-Why:
Take.
State-Changed-From-To: open->closed
State-Changed-By: kamil@NetBSD.org
State-Changed-When: Tue, 04 Jun 2019 14:55:33 +0200
State-Changed-Why:
The reported issue and reproducer no longer causes issues in NetBSD as of 2019-06-04 in HEAD.
The program runs without 100% CPU consumption in GDB until completion.
If there are still any issues, please file a new report.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.