unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Dmitry Antipov <dmantipov@yandex.ru>, emacs-devel@gnu.org
Subject: Re: ptrdiff_t misuse [was :Re: (empty)]
Date: Sat, 30 Jun 2012 08:14:19 -0500	[thread overview]
Message-ID: <4FEEFBAB.6000404@cs.ucla.edu> (raw)
In-Reply-To: <jwvpq8huhq0.fsf-monnier+emacs@gnu.org>

On 06/30/2012 07:07 AM, Stefan Monnier wrote:
> But "fixing" the code like you have will just make it run "correctly"
> and so super-extra slow that the user will just think it's frozen.

If Emacs simply cannot handle large hscroll values, how
about if we ceiling them out at some suitably-large value,
say 1000?  That would make this discussion moot and would
make Emacs more robust in practice, as it'd prevent some
freezes.  Emacs already limits tab width in this way, so
there's precedent.  I can work on writing up a patch along
these lines if you like.

If we can't impose an arbitrary limit, then here are some
more thoughts about the point at issue.

Although it's true that in some cases Emacs happened to run
incorrectly and quickly without the fix, in other cases
Emacs ran incorrectly and froze whereas it now runs
correctly and quickly (e.g., if the new hscroll is
sufficiently negative).  Since the patch fixes this bug
without introducing new bugs it seems like a win.

Besides, the previous paragraph assumes that signed integer
overflow silently wraps around.  This was formerly true of
Emacs porting targets but is no longer true: overflow has
undefined behavior, and can dump core or worse.  Maybe the
unfixed code happens to wrap around or dump core on all our
porting targets when overflow occurs (which appears to be
"acceptable" behavior here), but maybe it has even worse
behavior, and it's not feasible to test whether it does.
The fixed code doesn't have this problem.

I sense a larger worry here that if we methodically change
Emacs to prevent all cases of undefined behavior triggerable
by converting Emacs fixnums to C integer values, then we'll
have to add lots of checks that contort the C code so much
as to make Emacs unmaintainable.  If that's the worry, then
there should be no need for concern, as no rewrite should be
needed: the Emacs source code already has the desired
property, modulo whatever minor bugs in this area still need
fixing.




  reply	other threads:[~2012-06-30 13:14 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29 13:20 (unknown) Eli Zaretskii
2012-06-29 14:18 ` ptrdiff_t misuse [was :Re: (empty)] Dmitry Antipov
2012-06-29 17:07   ` Stefan Monnier
2012-06-30  7:13     ` Paul Eggert
2012-06-30  7:27       ` Eli Zaretskii
2012-06-30 13:12         ` Paul Eggert
2012-06-30 14:23           ` Stefan Monnier
2012-06-30 12:07       ` Stefan Monnier
2012-06-30 13:14         ` Paul Eggert [this message]
2012-06-30 14:23           ` Stefan Monnier
2012-07-04  6:25             ` Paul Eggert
2012-07-04 16:39               ` Eli Zaretskii
2012-07-04 18:19                 ` Paul Eggert
2012-07-05 16:31                   ` Eli Zaretskii
2012-07-05 19:34                     ` Eli Zaretskii
2012-07-06  0:08                       ` Paul Eggert
2012-07-06  6:43                         ` Eli Zaretskii
2012-07-06  7:32                           ` Paul Eggert
2012-07-06  8:34                             ` ptrdiff_t misuse Eli Zaretskii
2012-07-06 14:51                               ` Paul Eggert
2012-07-06 21:30                               ` Stefan Monnier
2012-07-06 21:33                                 ` Samuel Bronson
2012-07-07 10:59                                   ` Stefan Monnier
2012-07-07 15:34                                     ` Paul Eggert
2012-07-06  8:46                             ` Eli Zaretskii
2012-07-06 10:19                               ` Stephen J. Turnbull
2012-07-06 11:01                                 ` Eli Zaretskii
2012-07-06 12:02                                   ` Stephen J. Turnbull
2012-07-06 13:37                                     ` Eli Zaretskii
2012-07-06 16:25                                       ` Stephen J. Turnbull
2012-07-06 14:56                                   ` Paul Eggert
2012-07-06 15:43                                     ` Eli Zaretskii
2012-07-06 15:56                                       ` Paul Eggert
2012-07-06 16:00                                         ` Eli Zaretskii
2012-07-06 16:42                                           ` Dmitry Antipov
2012-07-06 17:39                                             ` Paul Eggert
2012-07-07  1:31                               ` Chong Yidong
2012-06-29 18:54   ` ptrdiff_t misuse [was :Re: (empty)] 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=4FEEFBAB.6000404@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=dmantipov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).