From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.bugs Subject: bug#21683: 25.0.50; `advice-add` doesn't work for compiled primitive functions Date: Sun, 18 Oct 2015 14:25:42 -0700 Message-ID: <56240E56.3080504@dancol.org> References: <87wpuqi5cg.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="a5rsBCwE66PFlOnf9MiAlNgAsFDaBwUoP" X-Trace: ger.gmane.org 1445203582 7625 80.91.229.3 (18 Oct 2015 21:26:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 18 Oct 2015 21:26:22 +0000 (UTC) To: Philipp Stephani , Vitalie Spinu , 21683@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 18 23:26:11 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ZnvT1-0002Di-88 for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Oct 2015 23:26:11 +0200 Original-Received: from localhost ([::1]:35591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnvT0-0006Fv-1w for geb-bug-gnu-emacs@m.gmane.org; Sun, 18 Oct 2015 17:26:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42729) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnvSv-0006Fn-Nh for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2015 17:26:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZnvSs-00072O-E7 for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2015 17:26:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36525) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZnvSs-00072K-8V for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2015 17:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZnvSr-0000Jh-UR for bug-gnu-emacs@gnu.org; Sun, 18 Oct 2015 17:26:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Colascione Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 18 Oct 2015 21:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21683 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21683-submit@debbugs.gnu.org id=B21683.14452035511201 (code B ref 21683); Sun, 18 Oct 2015 21:26:01 +0000 Original-Received: (at 21683) by debbugs.gnu.org; 18 Oct 2015 21:25:51 +0000 Original-Received: from localhost ([127.0.0.1]:55466 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZnvSh-0000JI-3R for submit@debbugs.gnu.org; Sun, 18 Oct 2015 17:25:51 -0400 Original-Received: from dancol.org ([96.126.100.184]:50089) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZnvSf-0000J9-3s for 21683@debbugs.gnu.org; Sun, 18 Oct 2015 17:25:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dancol.org; s=x; h=Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject; bh=o1clmhNPmVY8KRxXxHNWhJryFPpN5Y2caeFJjhb1lgM=; b=RGFkB2AInWpF8PW3HLidOvAmQIRIAI/Wx/zKzXU2D0jRW+eKoQ54cIrZihsnFM3j6KAgn7Rcx4iyRAq43CVJ1PN+3q8666g80grjAVWt0+8wuKImDuMXM1miVDV9Y67g9YUTvefZv4DEmkcfroYH/ibWCxoM/nKu73FTarWxeXCh+Ph1evoGxtRvx0vJ2kZ55c/Wx+ZgW4ZT+r4/4fdvuMMOXjUePG0mNYwG+NxdWCRm9BwtW0Y5fgHVtJItv6GoBhUjaoNLeiLXLgUwzdNe0o2hxepxASMwlKPB7Sdi77SqI4Gs9ZsfRA2bDQkrs74eqGt7NgKDxiCVzx+Y44eNEg==; Original-Received: from [2620:10d:c090:180::1:c992] (helo=[IPv6:2620:10d:c081:1101:2ab2:bdff:fe1c:db58]) by dancol.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84) (envelope-from ) id 1ZnvSd-0002U2-Sv; Sun, 18 Oct 2015 14:25:47 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107725 Archived-At: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --a5rsBCwE66PFlOnf9MiAlNgAsFDaBwUoP Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/18/2015 02:16 PM, Philipp Stephani wrote: > This is documented behavior: > https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Name= d-Functions.html > It is possible to advise a primitive (see What Is a Function > ), > but one should typically /not/ do so, for two reasons. Firstly, some > primitives are used by the advice mechanism, and advising them could > cause an infinite recursion. Secondly, many primitives are called > directly from C, and such calls ignore advice; hence, one ends up in a > confusing situation where some calls (occurring from Lisp code) obey th= e > advice and other calls (from C code) do not. If we wanted to allow advising of primitives such that we also redirect direct calls from C, it wouldn't be that hard: the idea is to either 1) insert enough NOPs at the start of every function to encode an absolute jump[1], or 2) associate with every function a Lisp variable and rest it for nil-ness (which would be a very cheap and very predictable test against zero with Qnil being all zero bits) on entry. Option #1 is more clever and thus more fun to write, but option #2 probably suffices. I just haven't had a good reason to want to advise a primitive, but if someone wants to do this work, I wouldn't object to it. [1] You don't actually have to encode enough bytes for an absolute jump. You just need to be able to encode enough bytes for a backward jump to the region before the function; this region can then encode your absolute jump. If we align functions properly, we get this space for free half the time. See http://blogs.msdn.com/b/oldnewthing/archive/2011/09/21/10214405.aspx --a5rsBCwE66PFlOnf9MiAlNgAsFDaBwUoP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCAAGBQJWJA5WAAoJEN4WImmbpWBlxZ4P/03SZHYABFeEVs7xJPdSV25W 4jQF9oMIRogQRv2m1jIK1BaQPZLiLQkZ/OhPtLFpxCV5ULsyuEFSqt7Fo0MP0lVn Kfs9teQ1RnhrSz2Xxpofeif3OizFSDOcdxmLftGdXUGXW3ZeFleTawYZOGaSuEjS LO81si3pnMv4na3qJY4RIGs4oDCEosGTyfu5ICVsEvGZUgNoU8VUdconyARwanh6 MAhS4sNBBHJua6ZT1wndE2kAKPNgxntiBrAr7KspIIeqx9RZMA4rrr+DU+eGjcho U9qjuvk28PZaYjT7bCq0sfhVs1+YZB/ICrPTx8QY91rG1fZJwSOEip4RkWd5qPTw X9zsdIIyzFquX8fbv/gQAPuRys1qDqHovfuLur+Qf2/OxA7XqHkUgYy+tOpa2Cfp +Be61WzwiIVRxMw7o3OFsmV02Y1UHJZtQeQT8XGfD1LxF1/0pqxiL9ncVrsUpA7P JNFlz2/0pwfo2ZuQvrJolNj+gRHdqFoX+59jdMDkMKaIus0nwdbO6b51ZSDC5Uf0 wrz68UF5GRNhxTyMkwlpCJ0HolXsWu+Sqich2JdkeFzaK+EQGii9s4GEwpOm8uMh qB8ZvVEShO6/79uVS+FOqvEqsijAhvG9KQXh4FGCSdgbM9DUSYhaKwK30VVormlZ 5+r1y0YvkQzaCFkWWPQy =4Qn/ -----END PGP SIGNATURE----- --a5rsBCwE66PFlOnf9MiAlNgAsFDaBwUoP--