From: Jon Mayo <jon.mayo@gmail.com>
To: Mikael Magnusson <mikachu@gmail.com>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: SIGFPE crash
Date: Sat, 7 May 2011 17:05:08 -0700 [thread overview]
Message-ID: <BANLkTik1h5bVd1cnPPYQrd33bEAc7pr2+Q@mail.gmail.com> (raw)
In-Reply-To: <BANLkTikO3QSLA2h-6g9pz=gU_zi3iF6cQA@mail.gmail.com>
On Sat, May 7, 2011 at 3:27 PM, Mikael Magnusson <mikachu@gmail.com> wrote:
> On 8 May 2011 00:19, Jon Mayo <jon.mayo@gmail.com> wrote:
>> On Sat, May 7, 2011 at 3:17 PM, Mikael Magnusson <mikachu@gmail.com> wrote:
>>> On 7 May 2011 23:56, Jon Mayo <jon.mayo@gmail.com> wrote:
>>>> echo $[-9223372036854775808/-1]
>>>>
>>>> this causes zsh to exit immediately with an FPE. Does anyone have a
>>>> patch to fix this?
>>>
>>> diff --git a/Src/math.c b/Src/math.c
>>> index 35b362d..3c08052 100644
>>> --- a/Src/math.c
>>> +++ b/Src/math.c
>>> @@ -1053,8 +1053,12 @@ op(int what)
>>> return;
>>> if (c.type == MN_FLOAT)
>>> c.u.d = a.u.d / b.u.d;
>>> - else
>>> - c.u.l = a.u.l / b.u.l;
>>> + else {
>>> + if (a.u.l == LONG_MIN && b.u.l == -1)
>>
>> should be LLONG_MIN
>>
>>> + c.u.l = 0;
>>
>> LLONG_MAX would be the closest answer, but 1 off. I would switch it
>> from integer to double type in this case, but that might be difficult.
>
> It should probably be neither, zsh does some weird stuff to find a
> suitably long type for .l, which may or may not be a long long.
>
>>> + else
>>> + c.u.l = a.u.l / b.u.l;
>>> + }
>>> break;
>>> case MOD:
>>> case MODEQ:
>>>
>>>
>>> Do we want to print a warning and/or use another value than 0 in this case?
>
> This is assuming we want to do this at all, I am told that only
> division will generate an exception on x86, but presumably other
> arches behave differently, and bash behaves the same way too
> (exception + die). Does some sort of standard have anything to say on
> the matter? I'm guessing someone has thought of it before and clearly
> nobody ever did anything about it.
>
perhaps scripts that care can just use a trap? and all my worrying was
for nothing?
mostly I ran into the issue while I dropped out of vi to do some
calculations, and ended up having zsh crash and had to recover my
editing session. minor annoyance really.
next prev parent reply other threads:[~2011-05-08 0:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-07 21:56 Jon Mayo
2011-05-07 22:17 ` Mikael Magnusson
2011-05-07 22:19 ` Jon Mayo
2011-05-07 22:27 ` Mikael Magnusson
2011-05-07 23:48 ` Phil Pennock
2011-05-08 0:05 ` Jon Mayo [this message]
2011-05-08 0:10 ` Mikael Magnusson
2011-05-08 2:46 ` Bart Schaefer
2011-05-08 7:03 ` Jon Mayo
2011-05-08 17:33 ` Peter Stephenson
2011-05-09 10:21 ` Vincent Lefevre
2011-05-09 10:35 ` Vincent Lefevre
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=BANLkTik1h5bVd1cnPPYQrd33bEAc7pr2+Q@mail.gmail.com \
--to=jon.mayo@gmail.com \
--cc=mikachu@gmail.com \
--cc=zsh-workers@zsh.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 public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).