all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG][PATCH] emacs23, make bootstrap failed on x86_64 systems
@ 2008-04-04  7:27 Dan Kruchinin
  2008-04-04  8:49 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Kruchinin @ 2008-04-04  7:27 UTC (permalink / raw)
  To: emacs-devel

Hi all.

There is a problem with making bootstrap on emacs23 from cvs:
Emacs hangups during the byte compilation of *.el files.
The reason of this problem is an infinite loop that occurs while emacs is
trying to compile calendar/cal-china.el.
cal-china.el requires cal-dst.el which contains the following code:

---
(defun calendar-current-time-zone ()
"quite long doc-string(skipped)"
  (unless calendar-current-time-zone-cache
    (setq calendar-current-time-zone-cache (calendar-dst-find-data))))

(calendar-current-time-zone)
---

After emacs sees direct function call in the required file, it tries to 
evaluate met  function.
It evaluates most of code quite well except of those that was modified 
in the revision #1.42.
It's a loop that executes until 'current-time-zone' function will not 
return nil. This can happen
only if its arguments(integers) are too big, i.e. if lisp_time_argument 
function will return 'false'.
But it'll never return false on _LP64 systems(on which EMACS_INT is long 
and sizeof(long) == 8),
because it uses low bitwise operations expecting that sizeof(EMACS_INT) 
== 4:

--- src/editfns.c: lisp_time_argument ---
      *result = (XINT (high) << 16) + (XINT (low) & 0xffff);
      return *result >> 16 == XINT (high);
---

Here is a quick'n'dirty patch to fix this problem (src/editfns.c, 
revision #1.458):

---patch---
--- src/editfns.c 2008-04-04 11:15:28.000000000 +0400
+++ src/editfns.c.patched  2008-04-04 10:37:16.000000000 +0400
@@ -1519,6 +1519,7 @@
   else
     {
       Lisp_Object high, low;
+      int half_word = BITS_PER_EMACS_INT >> 1;
       high = Fcar (specified_time);
       CHECK_NUMBER (high);
       low = Fcdr (specified_time);
@@ -1542,8 +1543,8 @@
       else if (usec)
         *usec = 0;
       CHECK_NUMBER (low);
-      *result = (XINT (high) << 16) + (XINT (low) & 0xffff);
-      return *result >> 16 == XINT (high);
+      *result = (XINT (high) << half_word) + (XINT (low) & (INTMASK >> 
half_word));
+      return *result >> half_word == XINT (high);
     }
 }
----------------

W.B.R.
Dan Kruchinin.




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

* Re: [BUG][PATCH] emacs23, make bootstrap failed on x86_64 systems
  2008-04-04  7:27 [BUG][PATCH] emacs23, make bootstrap failed on x86_64 systems Dan Kruchinin
@ 2008-04-04  8:49 ` Andreas Schwab
  2008-04-04  9:46   ` Dan Kruchinin
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2008-04-04  8:49 UTC (permalink / raw)
  To: Dan Kruchinin; +Cc: emacs-devel

Dan Kruchinin <dan.kruchinin@gmail.com> writes:

> But it'll never return false on _LP64 systems(on which EMACS_INT is long
> and sizeof(long) == 8),
> because it uses low bitwise operations expecting that sizeof(EMACS_INT) ==
> 4:
>
> --- src/editfns.c: lisp_time_argument ---
>      *result = (XINT (high) << 16) + (XINT (low) & 0xffff);
>      return *result >> 16 == XINT (high);

Where does this assume a 32bit EMACS_INT?

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




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

* Re: [BUG][PATCH] emacs23, make bootstrap failed on x86_64 systems
  2008-04-04  8:49 ` Andreas Schwab
@ 2008-04-04  9:46   ` Dan Kruchinin
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Kruchinin @ 2008-04-04  9:46 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel

Andreas Schwab wrote:
> Dan Kruchinin <dan.kruchinin@gmail.com> writes:
>
>   
>> But it'll never return false on _LP64 systems(on which EMACS_INT is long
>> and sizeof(long) == 8),
>> because it uses low bitwise operations expecting that sizeof(EMACS_INT) ==
>> 4:
>>
>> --- src/editfns.c: lisp_time_argument ---
>>      *result = (XINT (high) << 16) + (XINT (low) & 0xffff);
>>      return *result >> 16 == XINT (high);
>>     
>
> Where does this assume a 32bit EMACS_INT?
>
> Andreas.
>
>   
I looked more closely at src/editfns.c and how it works with date and 
time, so
1st: yep, my patch was invalid
2nd:
All functions use int data type for holding seconds. Here for example 
code from current-time
function:

--
  EMACS_TIME t;

  EMACS_GET_TIME (t);
  return list3 (make_number ((EMACS_SECS (t) >> 16) & 0xffff),
      make_number ((EMACS_SECS (t) >> 0)  & 0xffff),
      make_number (EMACS_USECS (t)));
--

or from get-internal-run-time:
--
int secs, usecs;
...
  return list3 (make_number ((secs >> 16) & 0xffff),
      make_number ((secs >> 0)  & 0xffff),
      make_number (usecs));
--

It implies that both HIGH and LOW have size = 2 bytes.
It also implies that they are not depend on how big is int: 32 or 64 bits.

But in the function lisp_time_argument 'high' can be greater than 2 bytes
because XINT(high) returns long(8 bytes on _LP64) and
"*result = (XINT (high) << 16) + (XINT (low) & 0xffff)"
will not truncate it because 'result' has type time_t which can be > 
than 4 bytes. (8 bytes on _LP64).

Something like this seems to be valid:
"*result = ((XINT (high) & 0xffff) << 16) + (XINT (low) & 0xffff);"
or like this:
"*result &= 0xffffffff;"

Anyway if "seconds" have some size restriction, lisp_time_argument 
should check it correctly.

W.B.R.
Dan Kruchinin.





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

end of thread, other threads:[~2008-04-04  9:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-04  7:27 [BUG][PATCH] emacs23, make bootstrap failed on x86_64 systems Dan Kruchinin
2008-04-04  8:49 ` Andreas Schwab
2008-04-04  9:46   ` Dan Kruchinin

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.