all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Stephen J. Turnbull" <stephen@xemacs.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Chong Yidong <cyd@stupidchicken.com>, emacs-devel@gnu.org
Subject: Re: Intervals crash
Date: Fri, 24 Sep 2010 15:12:34 +0900	[thread overview]
Message-ID: <87bp7n3c19.fsf@uwakimon.sk.tsukuba.ac.jp> (raw)
In-Reply-To: <83bp7ouw2u.fsf@gnu.org>

Eli Zaretskii writes:

 > > From: Chong Yidong <cyd@stupidchicken.com>
 > > 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.




  reply	other threads:[~2010-09-24  6:12 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-23 18:23 Intervals crash Chong Yidong
2010-09-23 18:52 ` Chong Yidong
2010-09-23 19:01   ` Eli Zaretskii
2010-09-23 19:09     ` Chong Yidong
2010-09-23 19:32       ` Eli Zaretskii
2010-09-23 18:57 ` Eli Zaretskii
2010-09-24  6:12   ` Stephen J. Turnbull [this message]
2010-09-24  8:16     ` Eli Zaretskii
2010-09-24  8:52       ` Stephen J. Turnbull
2010-09-24 10:03         ` Eli Zaretskii
2010-09-25 14:34           ` Stephen J. Turnbull
2010-09-25 16:10             ` Eli Zaretskii
2010-09-25 18:54               ` Stephen J. Turnbull
2010-09-25 22:07                 ` Eli Zaretskii
2010-09-26 13:08                   ` Stephen J. Turnbull
2010-09-26 19:22                     ` Miles Bader
2010-09-26 19:33                       ` David Kastrup
2010-09-27  4:53                       ` Stephen J. Turnbull
2010-09-27  6:55                         ` David Kastrup
2010-09-27  7:42                           ` Jan Djärv
2010-09-27  8:34                             ` Eli Zaretskii
2010-09-27  9:02                               ` David Kastrup
2010-09-27 11:02                                 ` Eli Zaretskii
2010-09-27  8:36                           ` Eli Zaretskii
2010-09-27  8:50                           ` Stephen J. Turnbull
2010-09-27  9:39                             ` David Kastrup
2010-09-27  9:45                               ` Lars Magne Ingebrigtsen
2010-09-27 10:11                               ` Stephen J. Turnbull
2010-09-24 10:31 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bp7n3c19.fsf@uwakimon.sk.tsukuba.ac.jp \
    --to=stephen@xemacs.org \
    --cc=cyd@stupidchicken.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.