unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: [Emacs-diffs] master bc78ff2 2/2: Use 0 for Qnil
       [not found] ` <E1Y8CBN-0005MY-1J@vcs.savannah.gnu.org>
@ 2015-01-07 21:57   ` Herbert J. Skuhra
  2015-01-08  2:10     ` Paul Eggert
  2015-01-08  5:23     ` YAMAMOTO Mitsuharu
  0 siblings, 2 replies; 5+ messages in thread
From: Herbert J. Skuhra @ 2015-01-07 21:57 UTC (permalink / raw)
  To: emacs-devel, Paul Eggert

Hi,

after this commit I can no longer build Emacs on Mac OS X (10.10.2):

Loading /Users/herbert/source/emacs/lisp/help.el (source)...
Loading /Users/herbert/source/emacs/lisp/jka-cmpr-hook.el (source)...
Loading /Users/herbert/source/emacs/lisp/epa-hook.el (source)...
Loading /Users/herbert/source/emacs/lisp/international/mule-cmds.el
(source)...
Loading /Users/herbert/source/emacs/lisp/case-table.el (source)...
Loading /Users/herbert/source/emacs/lisp/international/characters.el
(source)...
make[2]: *** [bootstrap-emacs] Illegal instruction: 4
make[1]: *** [src] Error 2
make: *** [bootstrap] Error 2

Building with Homebrew also fails.

58f2d6e does compile.

Sorry, if this a known issue!

-- 
Herbert



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

* Re: [Emacs-diffs] master bc78ff2 2/2: Use 0 for Qnil
  2015-01-07 21:57   ` [Emacs-diffs] master bc78ff2 2/2: Use 0 for Qnil Herbert J. Skuhra
@ 2015-01-08  2:10     ` Paul Eggert
  2015-01-08  2:29       ` Perry E. Metzger
  2015-01-08  5:23     ` YAMAMOTO Mitsuharu
  1 sibling, 1 reply; 5+ messages in thread
From: Paul Eggert @ 2015-01-08  2:10 UTC (permalink / raw)
  To: Herbert J. Skuhra, emacs-devel; +Cc: Perry E. Metzger

Herbert J. Skuhra wrote:

> Loading /Users/herbert/source/emacs/lisp/international/characters.el
> (source)...
> make[2]: *** [bootstrap-emacs] Illegal instruction: 4

Thanks, I reproduced the problem on FreeBSD 9 x86.  Could you please try it with 
the latest master (commit ad5ac01471b6795a5168b5e6fb7230adb08f3217)?  That fixed 
the problem for me.



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

* Re: [Emacs-diffs] master bc78ff2 2/2: Use 0 for Qnil
  2015-01-08  2:10     ` Paul Eggert
@ 2015-01-08  2:29       ` Perry E. Metzger
  0 siblings, 0 replies; 5+ messages in thread
From: Perry E. Metzger @ 2015-01-08  2:29 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Herbert J. Skuhra, emacs-devel

On Wed, 07 Jan 2015 18:10:49 -0800 Paul Eggert <eggert@cs.ucla.edu>
wrote:
> Herbert J. Skuhra wrote:
> 
> > Loading /Users/herbert/source/emacs/lisp/international/characters.el
> > (source)...
> > make[2]: *** [bootstrap-emacs] Illegal instruction: 4
> 
> Thanks, I reproduced the problem on FreeBSD 9 x86.  Could you
> please try it with the latest master (commit
> ad5ac01471b6795a5168b5e6fb7230adb08f3217)?  That fixed the problem
> for me.
> 

Build still fails for me on ad5ac01471b6795a5168b5e6fb7230adb08f3217

Loading /Users/perry/src/emacs/emacs/lisp/case-table.el (source)...
Loading /Users/perry/src/emacs/emacs/lisp/international/characters.el
(source)... make[1]: *** [bootstrap-emacs] Illegal instruction: 4
(core dumped) make: *** [src] Error 2

-- 
Perry E. Metzger		perry@piermont.com



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

* Re: [Emacs-diffs] master bc78ff2 2/2: Use 0 for Qnil
  2015-01-07 21:57   ` [Emacs-diffs] master bc78ff2 2/2: Use 0 for Qnil Herbert J. Skuhra
  2015-01-08  2:10     ` Paul Eggert
@ 2015-01-08  5:23     ` YAMAMOTO Mitsuharu
  2015-01-08  7:05       ` Paul Eggert
  1 sibling, 1 reply; 5+ messages in thread
From: YAMAMOTO Mitsuharu @ 2015-01-08  5:23 UTC (permalink / raw)
  To: Herbert J. Skuhra; +Cc: Paul Eggert, emacs-devel

>>>>> On Wed, 7 Jan 2015 22:57:59 +0100, "Herbert J. Skuhra" <herbert@oslo.ath.cx> said:

> Hi,
> after this commit I can no longer build Emacs on Mac OS X (10.10.2):

> Loading /Users/herbert/source/emacs/lisp/help.el (source)...
> Loading /Users/herbert/source/emacs/lisp/jka-cmpr-hook.el (source)...
> Loading /Users/herbert/source/emacs/lisp/epa-hook.el (source)...
> Loading /Users/herbert/source/emacs/lisp/international/mule-cmds.el
> (source)...
> Loading /Users/herbert/source/emacs/lisp/case-table.el (source)...
> Loading /Users/herbert/source/emacs/lisp/international/characters.el
> (source)...
> make[2]: *** [bootstrap-emacs] Illegal instruction: 4
> make[1]: *** [src] Error 2
> make: *** [bootstrap] Error 2

> Building with Homebrew also fails.

> 58f2d6e does compile.

In src/lisp.h, we have:

# define lisp_h_XUNTAG(a, type) XUNTAGBASE (a, type, 0)
# define lisp_h_XUNTAGBASE(a, type, base) \
    ((void *) ((char *) (base) - (type) + (intptr_t) XLI (a)))

With the above macros, XUNTAG (a, type) is expanded to:

  ((void *) ((char *) (0) - (type) + (intptr_t) XLI (a)))

It is relative to the NULL pointer and clang seems to treat its
dereference as an undefined behavior.  Reverting the definition of
lisp_h_XUNTAG to the previous version works for me.

# define lisp_h_XUNTAG(a, type) ((void *) (XLI (a) - (type)))

				     YAMAMOTO Mitsuharu
				mituharu@math.s.chiba-u.ac.jp



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

* Re: [Emacs-diffs] master bc78ff2 2/2: Use 0 for Qnil
  2015-01-08  5:23     ` YAMAMOTO Mitsuharu
@ 2015-01-08  7:05       ` Paul Eggert
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Eggert @ 2015-01-08  7:05 UTC (permalink / raw)
  To: YAMAMOTO Mitsuharu, Herbert J. Skuhra; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 492 bytes --]

YAMAMOTO Mitsuharu wrote:
> With the above macros, XUNTAG (a, type) is expanded to:
>
>    ((void *) ((char *) (0) - (type) + (intptr_t) XLI (a)))
>
> It is relative to the NULL pointer and clang seems to treat its
> dereference as an undefined behavior.

Thanks for diagnosing that.  This is arguably a bug in clang, but it's easy 
enough to work around as you suggest.  I reproduced the problem with Fedora 21 
x86-64 (clang 3.5.0) and installed the attached patch, which fixed it for me.


[-- Attachment #2: 0001-Port-Qnil-0-XUNTAG-to-clang.patch --]
[-- Type: text/x-patch, Size: 2082 bytes --]

From 8d025fa15493be4079d05629e9ca8b7ae325fc58 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 7 Jan 2015 23:02:01 -0800
Subject: [PATCH] Port Qnil==0 XUNTAG to clang

clang has undefined behavior if the program subtracts an integer
from (char *) 0.  Problem reported by YAMAMOTO Mitsuharu in:
http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00132.html
* lisp.h (lisp_h_XUNTAG) [USE_LSB_TAG]:
(XUNTAG) [!USE_LSB_TAG]: Port to clang 3.5.0.
---
 src/ChangeLog | 7 +++++++
 src/lisp.h    | 5 +++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index eae16c2..817483b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
 2015-01-08  Paul Eggert  <eggert@cs.ucla.edu>
 
+	Port Qnil==0 XUNTAG to clang
+	clang has undefined behavior if the program subtracts an integer
+	from (char *) 0.  Problem reported by YAMAMOTO Mitsuharu in:
+	http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00132.html
+	* lisp.h (lisp_h_XUNTAG) [USE_LSB_TAG]:
+	(XUNTAG) [!USE_LSB_TAG]: Port to clang 3.5.0.
+
 	Port GFileMonitor * hack to Qnil==0 platforms
 	Reported by Glenn Morris in: http://bugs.gnu.org/15880#112
 	* gfilenotify.c (monitor_to_lisp, lisp_to_monitor): New functions.
diff --git a/src/lisp.h b/src/lisp.h
index 1f18b5e..b9263f8 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -368,7 +368,7 @@ error !;
 # define lisp_h_XFASTINT(a) XINT (a)
 # define lisp_h_XINT(a) (XLI (a) >> INTTYPEBITS)
 # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
-# define lisp_h_XUNTAG(a, type) XUNTAGBASE (a, type, 0)
+# define lisp_h_XUNTAG(a, type) ((void *) (intptr_t) (XLI (a) - (type)))
 # define lisp_h_XUNTAGBASE(a, type, base) \
     ((void *) ((char *) (base) - (type) + (intptr_t) XLI (a)))
 #endif
@@ -905,7 +905,8 @@ XUNTAGBASE (Lisp_Object a, int type, void *base)
 INLINE void *
 XUNTAG (Lisp_Object a, int type)
 {
-  return XUNTAGBASE (a, type, 0);
+  intptr_t i = USE_LSB_TAG ? XLI (a) - type : XLI (a) & VALMASK;
+  return (void *) i;
 }
 
 #endif /* ! USE_LSB_TAG */
-- 
2.1.0


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

end of thread, other threads:[~2015-01-08  7:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20150105181510.19723.18782@vcs.savannah.gnu.org>
     [not found] ` <E1Y8CBN-0005MY-1J@vcs.savannah.gnu.org>
2015-01-07 21:57   ` [Emacs-diffs] master bc78ff2 2/2: Use 0 for Qnil Herbert J. Skuhra
2015-01-08  2:10     ` Paul Eggert
2015-01-08  2:29       ` Perry E. Metzger
2015-01-08  5:23     ` YAMAMOTO Mitsuharu
2015-01-08  7:05       ` Paul Eggert

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