unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Dynamic modules: emacs-module.c and signaling errors
@ 2015-11-24 19:41 Eli Zaretskii
  2015-11-24 19:45 ` Eli Zaretskii
                   ` (2 more replies)
  0 siblings, 3 replies; 59+ messages in thread
From: Eli Zaretskii @ 2015-11-24 19:41 UTC (permalink / raw)
  To: Philipp Stephani, aurelien.aptel+emacs, tzz, dancol; +Cc: emacs-devel

In "emacs -Q", load the modules/mod-test/mod-test module, then try
this:

  M-: (mod-test-sum "1" 2) RET

Result: Emacs aborts.  This happens because the eassert in
module_extract_integer aborts, when that function is called for the
2nd time:

  static intmax_t
  module_extract_integer (emacs_env *env, emacs_value n)
  {
    check_main_thread ();
    eassert (module_non_local_exit_check (env) == emacs_funcall_exit_return);
    Lisp_Object l = value_to_lisp (n);
    if (! INTEGERP (l))
      {
	module_wrong_type (env, Qintegerp, l);
	return 0;
      }

The first call to module_extract_integer correctly detects the wrong
type of argument and calls module_wrong_type.  But module_wrong_type
just records the problem in the env structure, it doesn't signal any
Lisp error, like an Emacs primitive would.  So the actual error goes
undetected, and is masked by the assertion violation (because Emacs is
built with --enable-checking).

Since this obviously works as it was designed, my question is: how
should a module be written so that this kind of errors signal a normal
Lisp error we are accustomed with Emacs primitives?

TIA



^ permalink raw reply	[flat|nested] 59+ messages in thread

end of thread, other threads:[~2015-11-28 23:31 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24 19:41 Dynamic modules: emacs-module.c and signaling errors Eli Zaretskii
2015-11-24 19:45 ` Eli Zaretskii
2015-11-24 20:12 ` Tom Tromey
2015-11-24 20:49   ` Eli Zaretskii
2015-11-24 21:34     ` Paul Eggert
2015-11-24 21:55       ` Daniel Colascione
2015-11-25  6:52         ` Paul Eggert
2015-11-25  7:03           ` Daniel Colascione
2015-11-25  7:14             ` Paul Eggert
2015-11-25  7:18               ` Daniel Colascione
2015-11-25  7:23                 ` Paul Eggert
2015-11-25  7:25                   ` Daniel Colascione
2015-11-25  7:49                     ` Paul Eggert
2015-11-25  7:52                       ` Daniel Colascione
2015-11-25  7:58                         ` Paul Eggert
2015-11-25  8:12                           ` Daniel Colascione
2015-11-25  8:24                             ` Paul Eggert
2015-11-25  8:50                               ` Daniel Colascione
2015-11-25  9:11                                 ` Daniel Colascione
2015-11-25 18:19                                   ` Eli Zaretskii
2015-11-25 18:26                                   ` Philipp Stephani
2015-11-25 19:19                                     ` Eli Zaretskii
2015-11-25 21:52                                       ` Philipp Stephani
2015-11-25 17:34                                 ` Paul Eggert
2015-11-24 22:21       ` Tom Tromey
2015-11-25  6:55         ` Paul Eggert
2015-11-25 17:30           ` Eli Zaretskii
2015-11-25 17:34             ` Paul Eggert
2015-11-25 21:23               ` Stefan Monnier
2015-11-26 15:42                 ` Eli Zaretskii
2015-11-26 16:36                   ` Stefan Monnier
2015-11-26 17:08                     ` Eli Zaretskii
2015-11-26 19:28                       ` Stefan Monnier
2015-11-26 19:34                         ` Eli Zaretskii
2015-11-26 20:11                           ` Stefan Monnier
2015-11-26 20:19                             ` Eli Zaretskii
2015-11-26 21:20                               ` Paul Eggert
2015-11-26 22:29                                 ` Philipp Stephani
2015-11-26 22:33                                   ` Philipp Stephani
2015-11-27  1:06                                   ` Stefan Monnier
2015-11-27  1:10                                     ` Daniel Colascione
2015-11-27 15:06                                       ` Stefan Monnier
2015-11-27  8:12                                     ` Eli Zaretskii
2015-11-27  9:11                                 ` Eli Zaretskii
2015-11-27 12:25                                   ` Aurélien Aptel
2015-11-27 14:44                                     ` Eli Zaretskii
2015-11-28 23:31                                     ` Paul Eggert
2015-11-27  1:21                               ` Stefan Monnier
2015-11-27  8:26                                 ` Eli Zaretskii
2015-11-27 15:15                                   ` Stefan Monnier
2015-11-27 15:57                                     ` Eli Zaretskii
2015-11-27 16:29                                       ` Stefan Monnier
2015-11-27 17:38                                         ` Eli Zaretskii
2015-11-27 17:54                                           ` Stefan Monnier
2015-11-25 18:10           ` Tom Tromey
2015-11-25 18:15         ` Eli Zaretskii
2015-11-25 18:09 ` Philipp Stephani
2015-11-25 21:19   ` Stefan Monnier
2015-11-26 15:41     ` Eli Zaretskii

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).