From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Stephen J. Turnbull" Newsgroups: gmane.emacs.devel Subject: Re: Intervals crash Date: Fri, 24 Sep 2010 15:12:34 +0900 Message-ID: <87bp7n3c19.fsf@uwakimon.sk.tsukuba.ac.jp> References: <87aan82uar.fsf@stupidchicken.com> <83bp7ouw2u.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1285310903 15628 80.91.229.12 (24 Sep 2010 06:48:23 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 24 Sep 2010 06:48:23 +0000 (UTC) Cc: Chong Yidong , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 24 08:48:21 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Oz24v-0005pY-7f for ged-emacs-devel@m.gmane.org; Fri, 24 Sep 2010 08:48:18 +0200 Original-Received: from localhost ([127.0.0.1]:60849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oz24t-0003so-C4 for ged-emacs-devel@m.gmane.org; Fri, 24 Sep 2010 02:48:15 -0400 Original-Received: from [140.186.70.92] (port=44539 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oz24C-0003aA-Iy for emacs-devel@gnu.org; Fri, 24 Sep 2010 02:47:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oz1wB-0000mK-T5 for emacs-devel@gnu.org; Fri, 24 Sep 2010 02:39:17 -0400 Original-Received: from [130.158.254.171] (port=33788 helo=dmail02.cc.tsukuba.ac.jp) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oz1w9-0000l1-QP; Fri, 24 Sep 2010 02:39:14 -0400 Original-Received: from imss12.cc.tsukuba.ac.jp (unknown [130.158.254.130]) by dmail02.cc.tsukuba.ac.jp (Postfix) with ESMTP id 49BC8F4A01; Fri, 24 Sep 2010 15:20:31 +0900 (JST) Original-Received: from imss12.cc.tsukuba.ac.jp (imss12.cc.tsukuba.ac.jp [127.0.0.1]) by postfix.imss71 (Postfix) with ESMTP id 9D5D12AF544; Fri, 24 Sep 2010 15:20:16 +0900 (JST) Original-Received: from mgmt1.sk.tsukuba.ac.jp (unknown [130.158.97.223]) by imss12.cc.tsukuba.ac.jp (Postfix) with ESMTP id 8E80D2AF542; Fri, 24 Sep 2010 15:20:16 +0900 (JST) Original-Received: from uwakimon.sk.tsukuba.ac.jp (uwakimon.sk.tsukuba.ac.jp [130.158.99.156]) by mgmt1.sk.tsukuba.ac.jp (Postfix) with ESMTP id 8D8B13FA01D6; Fri, 24 Sep 2010 15:20:16 +0900 (JST) Original-Received: by uwakimon.sk.tsukuba.ac.jp (Postfix, from userid 1000) id C6F9712A578; Fri, 24 Sep 2010 15:12:34 +0900 (JST) In-Reply-To: <83bp7ouw2u.fsf@gnu.org> X-Mailer: VM undefined under 21.5 (beta29) "garbanzo" ed3b274cc037 XEmacs Lucid (x86_64-unknown-linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:130727 Archived-At: Eli Zaretskii writes: > > From: Chong Yidong > > Date: Thu, 23 Sep 2010 14:23:24 -0400 > > Cc: emacs-devel@gnu.org > > > > I'm getting a crash due to your recent EMACS_UINT change. > > Sorry. > > > The LENGTH macro in intervals.h:114 has to be able to return a > > negative number. This is probably worth reverting, until you > > come up with a proper fix. > I'd rather fix it properly. I replaced all EMACS_UINT with > EMACS_INT in intervals.c, it couldn't be worse than int it used > before. You should just do that everywhere. EMACS_UINT is a bad idea, and should be avoided. First, unsigned-ness tends to propagate because of C coercion rules, which is rarely desired; I've never seen an instance where that it useful in Emacsen source code. Second, unsigned integers are basically useless: ((unsigned) 0 - 1) is not a error, it is a very big number. This means that declaring a non-negative variable to be unsigned buys you nothing in terms of type-checking. OTOH, the extra bit of precision is almost never of interest in Emacs work. Third, the Unix convention of using negative return values to indicate error states mixes very badly with the first two facts: it's very easy to inadvertantly turn a flat-out error into a big success. The conclusion is that unsigneds (eg, size_t's) should be treated the same way you treat legacy-encoded external text input: hazardous material that you should convert to some sane internal type as soon as possible, and to be produced only just before use in external APIs. As such, there's really no need for EMACS_UINT. FWIW, when Ben removed all unsigneds not required by external APIs from XEmacs, not only did he fix two crashes which were associated with an earlier misguided attempt to use size_t consistently for non-negative variables, but two other crashes disappeared and have never been seen again.