GNU bug report logs -
#17681
24.3.91; "Arithmetic Error" in hide-ifdef mode when using shift operators
Previous Next
Reported by: David Engster <deng <at> randomsample.de>
Date: Tue, 3 Jun 2014 19:14:02 UTC
Severity: normal
Found in version 24.3.91
Fixed in version 25.0.95
Done: Noam Postavsky <npostavs <at> users.sourceforge.net>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17681 in the body.
You can then email your comments to 17681 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17681
; Package
emacs
.
(Tue, 03 Jun 2014 19:14:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
David Engster <deng <at> randomsample.de>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 03 Jun 2014 19:14:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Recipe:
- Create a file "test.h" containing the following (this is from
the file 'jiffies.h' in the Linux kernel):
#if !((((NSEC_PER_SEC << 2) / TICK_NSEC) << (SEC_JIFFIE_SC - 2)) & 0x80000000)
#endif
- emacs -Q
- Load the file, activate hide-ifdef-mode
- C-c @ h (hide-ifdefs)
The minibuffer will show "Arithmetic Error". Here is the backtrace:
Debugger entered--Lisp error: (arith-error)
hif-divide(0 nil)
(hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2))
(hif-logand (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2)) 2147483648.0)
(hif-not (hif-logand (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2)) 2147483648.0))
eval((hif-not (hif-logand (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2)) 2147483648.0)))
hif-possibly-hide()
hide-ifdef-guts()
hide-ifdefs()
Earlier Emacsen did not throw an error here (although it is very
possible that the above line wasn't calculated correctly). Still, this
probably qualifies as a regression.
-David
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17681
; Package
emacs
.
(Thu, 05 Jun 2014 22:27:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 17681 <at> debbugs.gnu.org (full text, mbox):
Luke, could you take a look at this report please?
http://debbugs.gnu.org/17681
An artificial but smaller example might be:
#if 1 / FOO
#endif
David Engster wrote:
> Recipe:
>
> - Create a file "test.h" containing the following (this is from
> the file 'jiffies.h' in the Linux kernel):
>
> #if !((((NSEC_PER_SEC << 2) / TICK_NSEC) << (SEC_JIFFIE_SC - 2)) & 0x80000000)
> #endif
>
> - emacs -Q
>
> - Load the file, activate hide-ifdef-mode
>
> - C-c @ h (hide-ifdefs)
>
> The minibuffer will show "Arithmetic Error". Here is the backtrace:
>
> Debugger entered--Lisp error: (arith-error)
> hif-divide(0 nil)
> (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2))
> (hif-logand (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2)) 2147483648.0)
> (hif-not (hif-logand (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2)) 2147483648.0))
> eval((hif-not (hif-logand (hif-shiftleft (hif-divide (hif-shiftleft (hif-lookup (quote NSEC_PER_SEC)) 2) (hif-lookup (quote TICK_NSEC))) (hif-minus (hif-lookup (quote SEC_JIFFIE_SC)) 2)) 2147483648.0)))
> hif-possibly-hide()
> hide-ifdef-guts()
> hide-ifdefs()
>
> Earlier Emacsen did not throw an error here (although it is very
> possible that the above line wasn't calculated correctly). Still, this
> probably qualifies as a regression.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17681
; Package
emacs
.
(Fri, 06 Jun 2014 01:05:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 17681 <at> debbugs.gnu.org (full text, mbox):
> Luke, could you take a look at this report please?
> http://debbugs.gnu.org/17681
> An artificial but smaller example might be:
> #if 1 / FOO
> #endif
I think he already sent me a patch fixing this problem (which IIUC is
a problem I introduced, BTW).
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17681
; Package
emacs
.
(Fri, 06 Jun 2014 06:10:03 GMT)
Full text and
rfc822 format available.
Message #14 received at 17681 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>I think he already sent me a patch fixing this problem
Yes, I think my new patch fixed that problem. However, if you're trying to
hide
jiffies.h it will eventually failed at some other place due to the
"unsigned long"
integer postfix (i.e. the "UL" in 100000UL), which hideif still consider it
a "TODO".
#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
2014-06-06 9:04 GMT+08:00 Stefan Monnier <monnier <at> iro.umontreal.ca>:
> > Luke, could you take a look at this report please?
>
> > http://debbugs.gnu.org/17681
>
> > An artificial but smaller example might be:
>
> > #if 1 / FOO
> > #endif
>
> I think he already sent me a patch fixing this problem (which IIUC is
> a problem I introduced, BTW).
>
>
> Stefan
>
--
Best regards,
Luke Lee
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17681
; Package
emacs
.
(Fri, 06 Jun 2014 07:18:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 17681 <at> debbugs.gnu.org (full text, mbox):
Luke Lee wrote:
>>I think he already sent me a patch fixing this problem
>
> Yes, I think my new patch fixed that problem.
Is this patch posted anywhere?
> However, if you're trying to hide jiffies.h it will eventually failed
> at some other place due to the "unsigned long" integer postfix (i.e.
> the "UL" in 100000UL), which hideif still consider it a "TODO".
>
> #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
When you say fail, do you mean it will give an error?
If so, why not ignore-errors around these evaluations?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17681
; Package
emacs
.
(Fri, 06 Jun 2014 11:12:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 17681 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
>Is this patch posted anywhere?
I only send it to Stefan for review since it's a set of patches
that forms the complete work of
http://www.emacswiki.org/emacs/hideif.el.
Patch set #1 has already been submitted into Emacs trunk
while patch set #2 is still under Stefan's reviewing. Patchset
#3 to come. All 3 patches forms the hideif.el posted on
EmacsWiki. You can try this version.
>When you say fail, do you mean it will give an error?
>If so, why not ignore-errors around these evaluations?
Different versions of Emacs seems to behave
differently. On my Linux machine it's Emacs 24.3.50.2
and it does not throw any error. On Cygwin Emacs
24.3.2 it throw an error. It seems that others' submitted
`hif-string-to-number' introduced some difference.
On Cygwin's Emacs version the `split-string' function
used in `hif-string-to-number' take no more than 3
arguments but it takes 4 arguments in my Linux
Emacs 24.3.50.2. After fixing this they still behave
differently. I'm focusing on Linux version so I did
not investigate what makes the difference.
Due to the internal behavior of hideif sometimes it's
not so easy to just ignore some errors then continue.
There are still some cases that hideif will throw an
error. To prevent hideif from throwing any errors, it's
actually another TODO item. I'll first complete the
reviewing of the remaining patch set.
2014-06-06 15:17 GMT+08:00 Glenn Morris <rgm <at> gnu.org>:
> Luke Lee wrote:
>
> >>I think he already sent me a patch fixing this problem
> >
> > Yes, I think my new patch fixed that problem.
>
> Is this patch posted anywhere?
>
> > However, if you're trying to hide jiffies.h it will eventually failed
> > at some other place due to the "unsigned long" integer postfix (i.e.
> > the "UL" in 100000UL), which hideif still consider it a "TODO".
> >
> > #define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
>
> When you say fail, do you mean it will give an error?
> If so, why not ignore-errors around these evaluations?
>
--
Best regards,
Luke Lee
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17681
; Package
emacs
.
(Fri, 06 Jun 2014 15:21:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 17681 <at> debbugs.gnu.org (full text, mbox):
Luke Lee wrote:
> Different versions of Emacs seems to behave differently. On my Linux
> machine it's Emacs 24.3.50.2 and it does not throw any error. On
> Cygwin Emacs 24.3.2 it throw an error.
The relevant version at the moment is the Emacs 24.3.91 pretest.
http://alpha.gnu.org/gnu/emacs/pretest/emacs-24.3.91.tar.xz
24.3.50 is an old development version and should not be used any more.
> It seems that others' submitted `hif-string-to-number' introduced some
> difference.
Apart from your 2014-01-28 changes, I see no changes to hideif.el in
Emacs 24.3.91 since 2012-10-02. hif-string-to-number is only in the
Emacs trunk, not the emacs-24 branch, so doesn't affect this report.
Reply sent
to
Noam Postavsky <npostavs <at> users.sourceforge.net>
:
You have taken responsibility.
(Sun, 26 Jun 2016 04:54:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
David Engster <deng <at> randomsample.de>
:
bug acknowledged by developer.
(Sun, 26 Jun 2016 04:54:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 17681-done <at> debbugs.gnu.org (full text, mbox):
Version: 25.0.95
I see the problem in Emacs 24.5, but not Emacs 25.0.95, so it seems to
have been fixed sometime in between.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 24 Jul 2016 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 305 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.