From owner-freebsd-current@FreeBSD.ORG Fri Jul 13 09:01:24 2007 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2232416A400 for ; Fri, 13 Jul 2007 09:01:24 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by mx1.freebsd.org (Postfix) with ESMTP id A4B3B13C441 for ; Fri, 13 Jul 2007 09:01:23 +0000 (UTC) (envelope-from asmrookie@gmail.com) Received: by ug-out-1314.google.com with SMTP id o4so587645uge for ; Fri, 13 Jul 2007 02:01:22 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=nINwMILCNEQkvVYYQlDRxHaEnCMLHC5F6X5UthGcExndP611GjdKGHCNFvN4mE3yE8rrzMHVh/rkamT0a48q8kKjUCv0TRT7sDbndJePDpAyHnfNebPdysasygXeHyWwaQe0wKiho7NBbWfKyjd3CYClNkRtM+d19pUO1vVoJys= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:reply-to:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=Ie+JYPTDH+2Q3APe6yTcWba0XXBkzpJ0HkRFolvDzV0c5wE3XnvxU558t0Y+vYKWFf0/Ht9Y7mEXhH28I6I9ALW8DVD44zlEyNqdqd3IQIqSWSoXmJ8grb0trSSgBR/TAVtyCIowQpd0iz8zJyt8LskVRo3ejLO1lZQkW2FEETo= Received: by 10.67.97.18 with SMTP id z18mr1870448ugl.1184317282445; Fri, 13 Jul 2007 02:01:22 -0700 (PDT) Received: from ?172.31.5.25? ( [89.97.252.178]) by mx.google.com with ESMTP id h7sm6296199nfh.2007.07.13.02.01.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 13 Jul 2007 02:01:22 -0700 (PDT) Message-ID: <46973F39.2050508@FreeBSD.org> Date: Fri, 13 Jul 2007 11:00:41 +0200 From: Attilio Rao User-Agent: Thunderbird 1.5 (X11/20060526) MIME-Version: 1.0 To: Hans Petter Selasky References: <46970DF7.3000803@elischer.org> <200707131021.59966.hselasky@c2i.net> <46973708.2040401@FreeBSD.org> <200707131055.12084.hselasky@c2i.net> In-Reply-To: <200707131055.12084.hselasky@c2i.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Attilio Rao Cc: freebsd-current@freebsd.org, Julian Elischer , FreeBSD Current Subject: Re: crash in tty code in 6.1.. fixed since? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: attilio@FreeBSD.org List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2007 09:01:24 -0000 Hans Petter Selasky wrote: > On Friday 13 July 2007 10:25, Attilio Rao wrote: >> Hans Petter Selasky wrote: >>> If TTY was not Giant locked, you would have had an error there if another >>> mutex was locked, and the problem would have been solved years ago :-) >> Not sure what you mean, but the first evidence is that you would have >> explicitly drop/pickup the mutex so that you would have handled the race >> not trasparently as Giant does. >> Moreover, it seems that tty should be partially locked with a sleeping >> primitive (sx probabilly). >> > > If you lock a mutex first and then a sx-lock, you should get a warning, right? No, a panic. What I mean is that if you had a mutex here instead than Giant what would have probabilly happened is having code like this: mtx_lock(&tty_mtx); ... if (tp->t_session) { mtx_unlock(&tty_mtx); sx_slock(&proctree_lock); mtx_lock(&tty_mtx); if (tp->t_session && tp->t_session->s_leader) { struct proc *p; What changes really here is that you explicitly check again the state of t_session ptr since it can be changed while dropping/pickingup again the tty_mtx. Since you used a mutex differently from Giant you know you have to do that. With Giant the problem is that the dropping/pickingup happens implicitly in our primitives so you can just make (easy) mistakes like these. Attilio