Subject: 24.3; dbus-register-signal misparses :argN arguments
From: Joel Ray Holveck <[email-masked]>
To: [email-masked]
Date: Thu, 21 Apr 2016 20:39:04 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

The following expression raises an error of type "wrong-type-argument":

     (dbus-register-signal :system "com.ubuntu.Upstart" 
"/com/ubuntu/Upstart/jobs/network_2dinterface" 
"com.ubuntu.Upstart0_6.Job" "InstanceAdded" 'rwv-handle-intf-up :arg0 
"/com/ubuntu/Upstart/jobs/network_2dinterface/cscotun0")

(Note that this particular call is incorrect for reasons dealing with 
the
Upstart API, but that is irrelevant to this bug.)

If you evaluate the defun for dbus-register-signal (instead of using
the .elc's compiled version) and then evaluate that expression, you can
easily see where the problem is:

     Debugger entered--Lisp error: (wrong-type-argument 
number-or-marker-p "0")
       <=("0" 63)
       (and (<= counter 63) (stringp value))

This happens on line 647 of dbus.el.  You can see that counter was set 
on
line 644 to a string, but then is compared against an integer.

As a workaround, it's possible to use the backward-compatibility
no-keywords style for :argN options, but not for :pathN options.

The following patch fixes the issue:

--- dbus.el.~1~ 2016-04-21 20:28:14.373278122 -0700
+++ dbus.el     2016-04-21 20:28:23.877255431 -0700
@@ -641,7 +641,8 @@
                       (string-match
                        "^:\\(arg\\|path\\)\\([[:digit:]]+\\)$"
                        (symbol-name key)))
-                (setq counter (match-string 2 (symbol-name key))
+                (setq counter (string-to-number
+                                (match-string 2 (symbol-name key)))
                        args (cdr args)
                        value (car args))
                  (unless (and (<= counter 63) (stringp value))

In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
  of 2014-03-07 on lamiak, modified by Debian
Windowing system distributor `The X.Org Foundation', version 
11.0.11501000
System Description:	Ubuntu 14.04.4 LTS

Configured using:
  `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
  '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
  '--localstatedir=/var/lib' '--infodir=/usr/share/info'
  '--mandir=/usr/share/man' '--with-pop=yes'
  
'--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
  '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=yes'
  '--with-x-toolkit=lucid' '--with-toolkit-scroll-bars' '--without-gconf'
  '--without-gsettings' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2
  -fstack-protector --param=ssp-buffer-size=4 -Wformat
  -Werror=format-security -Wall' 'LDFLAGS=-Wl,-Bsymbolic-functions
  -Wl,-z,relro' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
   value of $LANG: en_US.UTF-8
   value of $XMODIFIERS: @im=none
   locale-coding-system: utf-8-unix
   default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
   eldoc-mode: t
   minibuffer-electric-default-mode: t
   mail-abbrevs-mode: t
   iswitchb-mode: t
   desktop-save-mode: t
   savehist-mode: t
   which-function-mode: t
   auto-insert-mode: t
   show-paren-mode: t
   display-time-mode: t
   recentf-mode: t
   msb-mode: t
   shell-dirtrack-mode: t
   tooltip-mode: t
   mouse-wheel-mode: t
   tool-bar-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   blink-cursor-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   column-number-mode: t
   line-number-mode: t
   transient-mark-mode: t

Recent messages:
DBus-Event (dbus-event :system 2 260 org.freedesktop.DBus nil nil nil 
dbus-call-method-handler :1.0) [3 times]
Fdbus_message_internal: DBUS_MESSAGE_TYPE_METHOD_CALL :system 
org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus AddMatch 
dbus-call-method-handler
Fdbus_message_internal: Parameter3 
type='signal',sender=':1.0',interface='com.ubuntu.Upstart0_6.Job',member='InstanceAdded',path='/com/ubuntu/Upstart/jobs/network_2dinterface',arg0='/com/ubuntu/Upstart/jobs/network_2dinterface/cscotun0'
xd_signature: s
xd_append_arg: s 
type='signal',sender=':1.0',interface='com.ubuntu.Upstart0_6.Job',member='InstanceAdded',path='/com/ubuntu/Upstart/jobs/network_2dinterface',arg0='/com/ubuntu/Upstart/jobs/network_2dinterface/cscotun0'
Fdbus_message_internal: Message sent: (:serial :system 261)
xd_read_message_1: Event received: DBUS_MESSAGE_TYPE_METHOD_RETURN 261 
org.freedesktop.DBus (null) (null) (null) nil
xd_read_message_1: Event stored: (:system 2 261 org.freedesktop.DBus nil 
nil nil dbus-call-method-handler)
DBus-Event (dbus-event :system 2 261 org.freedesktop.DBus nil nil nil 
dbus-call-method-handler) [3 times]
Matching rule 
"type='signal',sender=':1.0',interface='com.ubuntu.Upstart0_6.Job',member='InstanceAdded',path='/com/ubuntu/Upstart/jobs/network_2dinterface',arg0='/com/ubuntu/Upstart/jobs/network_2dinterface/cscotun0'" 
created

Load-path shadows:
~/src/elisp/loaddefs hides ~/share/emacs/site-lisp/loaddefs
/usr/share/emacs/24.3/site-lisp/debian-startup hides 
/usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs24/site-lisp/cmake-data/cmake-mode hides 
/usr/share/emacs/site-lisp/cmake-mode
~/src/elisp/loaddefs hides /usr/share/emacs/24.3/lisp/loaddefs
/usr/share/emacs/site-lisp/rst hides 
/usr/share/emacs/24.3/lisp/textmodes/rst
/usr/share/emacs24/site-lisp/prolog-el/prolog hides 
/usr/share/emacs/24.3/lisp/progmodes/prolog

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mail-utils hippie-exp edebug dbus xml debug
info org-taskjuggler org-odt org-lparse org-latex org-export-latex
org-beamer org-icalendar org-docbook footnote org-ascii cus-edit
nroff-mode help-mode org-wl org-w3m org-vm org-rmail org-mhe org-mew
org-irc org-jsinfo org-infojs org-html org-exp ob-exp org-exp-blocks
org-agenda org-info org-gnus org-docview org-bibtex bibtex org-bbdb grep
dired-aux dired-x dired misearch multi-isearch add-log semantic/imenu
semantic/sb semantic/db-file data-debug cedet-files vc-git
semantic/wisent/python semantic/decorate/include semantic/decorate/mode
semantic/decorate pulse semantic/dep semantic/wisent/python-wy
semantic/wisent semantic/wisent/wisent python rx eldoc jka-compr
minibuf-eldef mailabbrev iswitchb icomplete desktop cus-start cus-load
savehist vcursor disp-table org-protocol org ob-tangle ob-ref ob-lob
ob-table org-footnote org-src ob-comint ob-keys org-pcomplete org-list
org-faces org-entities noutline outline easy-mmode org-version
ob-emacs-lisp ob org-compat org-macs ob-eval org-loaddefs find-func
cal-menu calendar cal-loaddefs derived which-func imenu autoinsert
cl-macs avoid paren time festival server cl tramp-cache tramp-sh recentf
tree-widget msb tramp tramp-compat auth-source gnus-util mm-util
mail-prsvr password-cache tramp-loaddefs shell pcomplete format-spec
uniquify printing ps-print ps-def lpr midnight slime-autoloads pylint
haskell-mode-autoloads ecb warnings edmacro kmacro ecb-symboldef
ecb-analyse ecb-compatibility ecb-winman-support ecb-autogen autoload
ecb-tod ecb-cycle ecb-eshell ecb-help ecb-jde ecb-method-browser
hideshow ecb-semantic ecb-file-browser ecb-speedbar ecb-layout compile
comint ansi-color ecb-create-layout advice help-fns cl-lib
advice-preload ecb-compilation ecb-common-browser assoc speedbar
sb-image dframe ecb-navigate ecb-mode-line ecb-face tree-buffer
ecb-upgrade ecb-cedet-wrapper semantic/db-mode semantic/db-find
semantic/db-ref semantic/analyze semantic/sort semantic/scope
semantic/analyze/fcn semantic/db gv eieio-base semantic/format ezimage
semantic/tag-ls semantic/find semantic/ctxt semantic/util-modes easymenu
semantic/util semantic semantic/tag semantic/lex semantic/fw eieio
byte-opt bytecomp byte-compile cconv mode-local cedet wid-edit ecb-util
ring thingatpt devhelp time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting font-render-setting
x-toolkit x multi-tty emacs)