From owner-freebsd-hackers Thu Jan 9 6:47:40 2003 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 819AB37B401 for ; Thu, 9 Jan 2003 06:47:36 -0800 (PST) Received: from fafoe.dyndns.org (chello212186121237.14.vie.surfer.at [212.186.121.237]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8DA1643F1E for ; Thu, 9 Jan 2003 06:47:35 -0800 (PST) (envelope-from stefan@fafoe.dyndns.org) Received: from frog.fafoe (frog.fafoe [192.168.2.101]) by fafoe.dyndns.org (Postfix) with ESMTP id 7BAB03FC6; Thu, 9 Jan 2003 15:47:28 +0100 (CET) Received: by frog.fafoe (Postfix, from userid 1001) id 4A8136BB; Thu, 9 Jan 2003 15:47:25 +0100 (CET) Date: Thu, 9 Jan 2003 15:47:25 +0100 From: Stefan Farfeleder To: Pawel Jakub Dawidek Cc: freebsd-hackers@freebsd.org Subject: Re: Exceptions via setjmp/longjmp in kernel. Message-ID: <20030109144724.GA611@frog.fafoe> References: <20030109143059.GC47263@prioris.mini.pw.edu.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030109143059.GC47263@prioris.mini.pw.edu.pl> User-Agent: Mutt/1.5.3i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Jan 09, 2003 at 03:30:59PM +0100, Pawel Jakub Dawidek wrote: > I got strange problem when trying to implement something like exceptions > with setjmp()/longjmp() functions. > > [...] > int ret; > jmpbuf buf; > [...] > ret = setjmp(buf); > KASSERT(ret != 1, ("I never return 1 with longjmp().")); > [...] > longjmp(buf, value_diffrent_than_1); > [...] > > And setjmp() returns only 0 or 1 (when longjmp() is called), but never > returns value that I've put in longjmp() call. > > There could be some other problems in using setjmp()/longjmp() > in kernel? I'm paying attention on memory leaks and locks that are > done before longjmp(). The usage of the setjmp macro in an assignment is not defined by ISO C, which might or might not be your problem. 7.13.1.1 The setjmp macro An invocation of the setjmp macro shall appear only in one of the following contexts: -- the entire controlling expression of a selection or iteration statement; -- one operand of a relational or equality operator with the other operand an integer constant expression, with the resulting expression being the entire controlling expression of a selection or iteration statement; -- the operand of a unary ! operator with the resulting expression being the entire controlling expression of a selection or iteration statement; or -- the entire expression of an expression statement (possibly cast to void). OTOH, vinum and ficl use setjmp in the same way. Stefan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message