From owner-cvs-all@FreeBSD.ORG Wed May 28 01:12:46 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 15D1437B401; Wed, 28 May 2003 01:12:46 -0700 (PDT) Received: from gw.catspoiler.org (217-ip-163.nccn.net [209.79.217.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 21C0A43F3F; Wed, 28 May 2003 01:12:45 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Received: from FreeBSD.org (mousie.catspoiler.org [192.168.101.2]) by gw.catspoiler.org (8.12.9/8.12.9) with ESMTP id h4S8CWM7091020; Wed, 28 May 2003 01:12:36 -0700 (PDT) (envelope-from truckman@FreeBSD.org) Message-Id: <200305280812.h4S8CWM7091020@gw.catspoiler.org> Date: Wed, 28 May 2003 01:12:32 -0700 (PDT) From: Don Lewis To: mtm@identd.net In-Reply-To: <20030528074607.PASI4805.out003.verizon.net@kokeb.ambesa.net> MIME-Version: 1.0 Content-Type: TEXT/plain; charset=us-ascii cc: src-committers@FreeBSD.org cc: dcs@tcoip.com.br cc: julian@elischer.org cc: cvs-src@FreeBSD.org cc: ak03@gte.com cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/lib/libthr/thread thr_join.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 May 2003 08:12:46 -0000 On 28 May, Mike Makonnen wrote: > On Tue, 27 May 2003 18:55:52 -0400 > Alexander Kabaev wrote: > >> >> konsole has similar problems when run with libkse. The ktrace + source >> code inspection convinced me that it simply abort()'a itself, because >> ttyname() function returns NULL in makePty() function. > > Yes, seems like it. More comments below. > >> >> I do not think either threading library has anything to do with the >> failure. > > It doesn't look like it's a threading issue, but since libc_r doesn't bring out > this behaviour in Konsole, they must be doing (or not doing) something (directly > or indirectly) that triggers it. > > I have finally taken the plunge and installed KDE, and I can reproduce the bug. > However, it is unclear to me exactly what the problem is. To complicate things > even further it doesn't even look look Konsole uses threads, and instead plays > games with fork(2). I think we need someone who is familiar with the code to > help out because I am having a hard time following it. Just to add a couple of > data points: > > It crashes because tcgetattr(3) called from libc/ttyname_unthreaded() returns > ENOTTY to TEPty::makePty(). > > When it does crash it is also usually preceded by: > konsole: cannot chown /dev/ttypc. > Reason: Operation not permitted > which is as a result of this code snippet from TEPty.cpp:openPty() > > if (openpty(&master_fd, &slave_fd, NULL, NULL, NULL) == 0) { > m_MasterFd = master_fd; > m_SlaveFd = slave_fd; > #ifdef HAVE_PTSNAME > strncpy(ptynam, ptsname(master_fd), 50); > ... > [snip] > ... > if (fchown(slave_fd, (uid_t) -1, gid) < 0) > { > m_bNeedGrantPty = true; > fprintf(stderr,"konsole: cannot chown %s.\n",ttynam); > perror("Reason"); > } > > > The fact that it works sometimes and abort()s at others suggests that there may > be a race somewhere, but where... According to the openpty() and fchown() man pages, the fchown() call will fail with that error if konsole isn't running with an effective UID of super-user at that point. AND The slave device either isn't owned by the user or gid isn't a member of the user's group.