GNU bug report logs - #19768
json.el: end-of-file errors untrappable

Previous Next

Package: emacs;

Reported by: era eriksson <era <at> iki.fi>

Date: Wed, 4 Feb 2015 14:00:02 UTC

Severity: normal

Found in version 24.3.1

Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>

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 19768 in the body.
You can then email your comments to 19768 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to era+emacs <at> iki.fi, bug-gnu-emacs <at> gnu.org:
bug#19768; Package emacs. (Wed, 04 Feb 2015 14:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to era eriksson <era <at> iki.fi>:
New bug report received and forwarded. Copy sent to era+emacs <at> iki.fi, bug-gnu-emacs <at> gnu.org. (Wed, 04 Feb 2015 14:00:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: era eriksson <era <at> iki.fi>
To: submit <at> debbugs.gnu.org
Subject: json.el: end-of-file errors untrappable
Date: Wed, 04 Feb 2015 15:59:43 +0200
Package: emacs
Version: 24.3.1
X-Debbugs-Cc: era+emacs <at> iki.fi

The code in json.el uses (signal 'end-of-file) in many scenarios. 
Unfortunately, the default value of debug-ignore-errors causes these
errors to bypass any error checking, and unhelpfully land in the
*Messages* buffer with little indication as to what went wrong or which
code path caused this message.

Once you know this, debugging json-read is easy; but the fix is
unobvious, and might have unintended side effects.

Steps to repro:

    (require 'json)
    (setq debug-on-error t)
    (json-read-from-string "")

Expected result:

*Backtrace* showing where something went wrong

Actual result:

json-read: End of file during parsing

(The "json-read:" prefix is not visible in the minibuffer message for
me, but it lands in the *Messages* buffer.)

Workaround:

    (let (debug-ignore-errors)
      (json-read-from-string ""))

I'm not sure what the proper fix should be.  Maybe these occurrences
could be changed to json-end-of-file or something?  Or maybe json-read
could include the 'let' form from the workaround.

See also:
http://stackoverflow.com/questions/28317081/debug-on-error-vs-debug-on-signal-in-json-el-in-particular

/* era */

-- 
If this were a real .signature, it would suck less.  Well, maybe not.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19768; Package emacs. (Wed, 04 Feb 2015 15:36:02 GMT) Full text and rfc822 format available.

Message #8 received at 19768 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: era eriksson <era <at> iki.fi>
Cc: 19768 <at> debbugs.gnu.org, era+emacs <at> iki.fi
Subject: Re: bug#19768: json.el: end-of-file errors untrappable
Date: Wed, 04 Feb 2015 10:34:58 -0500
> I'm not sure what the proper fix should be.  Maybe these occurrences
> could be changed to json-end-of-file or something?

That sounds right.  If we define json-end-of-file as an error which as
`end-of-file' as parent, it should give us the best of both worlds.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#19768; Package emacs. (Thu, 05 Feb 2015 11:52:02 GMT) Full text and rfc822 format available.

Message #11 received at 19768 <at> debbugs.gnu.org (full text, mbox):

From: era eriksson <era+emacs <at> iki.fi>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 19768 <at> debbugs.gnu.org
Subject: Re: bug#19768: json.el: end-of-file errors untrappable
Date: Thu, 05 Feb 2015 13:51:30 +0200
On Wed, Feb 4, 2015, at 17:34, Stefan Monnier wrote:
> > I'm not sure what the proper fix should be.  Maybe these occurrences
> > could be changed to json-end-of-file or something?
> 
> That sounds right.  If we define json-end-of-file as an error which as
> `end-of-file' as parent, it should give us the best of both worlds.

https://github.com/tripleee/emacs/tree/bug19768 contains a simple patch
which implements this, but I am uncertain how to test it.  Also, I am
having second thoughts about defining the new error symbol as a child of
'end-of-file when all the other error symbols neatly inherit from
'json-error.  Anyway, feel free to review and/or pull and/or ignore. (-:

/* era */

-- 
If this were a real .signature, it would suck less.  Well, maybe not.




Reply sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
You have taken responsibility. (Thu, 05 Feb 2015 19:53:02 GMT) Full text and rfc822 format available.

Notification sent to era eriksson <era <at> iki.fi>:
bug acknowledged by developer. (Thu, 05 Feb 2015 19:53:02 GMT) Full text and rfc822 format available.

Message #16 received at 19768-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: era eriksson <era+emacs <at> iki.fi>
Cc: 19768-done <at> debbugs.gnu.org
Subject: Re: bug#19768: json.el: end-of-file errors untrappable
Date: Thu, 05 Feb 2015 14:52:39 -0500
> https://github.com/tripleee/emacs/tree/bug19768 contains a simple patch
> which implements this, but I am uncertain how to test it.  Also, I am
> having second thoughts about defining the new error symbol as a child of
> 'end-of-file when all the other error symbols neatly inherit from
> 'json-error.  Anyway, feel free to review and/or pull and/or ignore. (-:

Installed, making it inherit from both kinds of errors ;-)


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 06 Mar 2015 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 168 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.