From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Dynamic modules: emacs-module.c and signaling errors Date: Tue, 24 Nov 2015 21:41:12 +0200 Message-ID: <83k2p7xk13.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1448394133 16815 80.91.229.3 (24 Nov 2015 19:42:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 24 Nov 2015 19:42:13 +0000 (UTC) Cc: emacs-devel@gnu.org To: Philipp Stephani , aurelien.aptel+emacs@gmail.com, tzz@lifelogs.com, dancol@dancol.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 24 20:42:03 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a1JTV-0001lB-6j for ged-emacs-devel@m.gmane.org; Tue, 24 Nov 2015 20:42:01 +0100 Original-Received: from localhost ([::1]:41061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1JTW-0000DL-8o for ged-emacs-devel@m.gmane.org; Tue, 24 Nov 2015 14:42:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1JTE-0000CV-5s for emacs-devel@gnu.org; Tue, 24 Nov 2015 14:41:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1JT9-0007bS-5c for emacs-devel@gnu.org; Tue, 24 Nov 2015 14:41:44 -0500 Original-Received: from mtaout29.012.net.il ([80.179.55.185]:58807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1JT8-0007aS-SL for emacs-devel@gnu.org; Tue, 24 Nov 2015 14:41:39 -0500 Original-Received: from conversion-daemon.mtaout29.012.net.il by mtaout29.012.net.il (HyperSendmail v2007.08) id <0NYC00L003QVG700@mtaout29.012.net.il> for emacs-devel@gnu.org; Tue, 24 Nov 2015 21:40:37 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout29.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NYC00G6R3ZOGY50@mtaout29.012.net.il>; Tue, 24 Nov 2015 21:40:37 +0200 (IST) X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.185 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:195183 Archived-At: 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