From owner-svn-src-all@FreeBSD.ORG Thu Sep 2 08:35:00 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0C88106571C; Thu, 2 Sep 2010 08:35:00 +0000 (UTC) (envelope-from davidxu@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A3BAA8FC12; Thu, 2 Sep 2010 08:35:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o828YwlQ070530; Thu, 2 Sep 2010 08:34:59 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4C7FD232.9080100@freebsd.org> Date: Thu, 02 Sep 2010 16:34:58 +0000 From: David Xu User-Agent: Thunderbird 2.0.0.24 (X11/20100630) MIME-Version: 1.0 To: Kostik Belousov References: <201009010218.o812IX5G048257@svn.freebsd.org> <20100902081136.GG2396@deviant.kiev.zoral.com.ua> In-Reply-To: <20100902081136.GG2396@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r212076 - head/lib/libthr/thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Sep 2010 08:35:00 -0000 Kostik Belousov wrote: > On Wed, Sep 01, 2010 at 02:18:33AM +0000, David Xu wrote: >> Author: davidxu >> Date: Wed Sep 1 02:18:33 2010 >> New Revision: 212076 >> URL: http://svn.freebsd.org/changeset/base/212076 >> >> Log: >> Add signal handler wrapper, the reason to add it becauses there are >> some cases we want to improve: >> 1) if a thread signal got a signal while in cancellation point, >> it is possible the TDP_WAKEUP may be eaten by signal handler >> if the handler called some interruptibly system calls. >> 2) In signal handler, we want to disable cancellation. >> 3) When thread holding some low level locks, it is better to >> disable signal, those code need not to worry reentrancy, >> sigprocmask system call is avoided because it is a bit expensive. >> The signal handler wrapper works in this way: >> 1) libthr installs its signal handler if user code invokes sigaction >> to install its handler, the user handler is recorded in internal >> array. >> 2) when a signal is delivered, libthr's signal handler is invoke, >> libthr checks if thread holds some low level lock or is in critical >> region, if it is true, the signal is buffered, and all signals are >> masked, once the thread leaves critical region, correct signal >> mask is restored and buffered signal is processed. >> 3) before user signal handler is invoked, cancellation is temporarily >> disabled, after user signal handler is returned, cancellation state >> is restored, and pending cancellation is rescheduled. > >> +static void >> +thr_sighandler(int sig, siginfo_t *info, void *_ucp) >> +{ > >> + if ((actp->sa_flags & SA_SIGINFO) != 0) >> + (*(sigfunc))(sig, info, ucp); >> + else { >> + ((ohandler)(*sigfunc))( >> + sig, info->si_code, (struct sigcontext *)ucp, >> + info->si_addr, (__sighandler_t *)sigfunc); >> + } > > I do not think this is very important, but freebsd old-style signal > handler fourth argument is usually the faulted %eip value. This is > most likely irrelevant for any source that is linked with libthr.so > new enough to contain this change. Isn't the si_addr in siginfo a fault address ? I remembered I saved the fault address in ksiginfo_t which is converted to userland siginfo, and fault address should be there. what's wrong here ?