Debian 64t transition causes build failure on 32bit arch

Bug #2063340 reported by Peter Van Eynde
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

Hi,

During a rebuild of sbcl 2.3.7 on Debian/unstable, after the https://wiki.debian.org/ReleaseGoals/64bit-time transition, we see a problem for armhf. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1069520

> "obj/from-xc/src/code/late-globaldb.lisp-obj"
>
> debugger invoked on a TYPE-ERROR:
> The value
> 542868266893180929
> is not of type
> (UNSIGNED-BYTE 32)
> when setting slot SB-THREAD::OBSERVED-INTERNAL-REAL-TIME-DELTA-SEC of structure SB-THREAD:THREAD
...
> (GET-INTERNAL-REAL-TIME)
> 0]

This seems to be related to the 64t change as when I try to rebuild on armhf I see a change in the grovelled data:

(sid_armhf-dchroot)pvaneynd@abel:~/sbcl-2.3.7$ diff -u ./crossbuild-runner/backends/arm/stuff-groveled-from-headers.lisp output/stuff-groveled-from-headers.lisp
--- ./crossbuild-runner/backends/arm/stuff-groveled-from-headers.lisp 2023-07-29 07:59:39.000000000 +0000
+++ output/stuff-groveled-from-headers.lisp 2023-07-29 07:59:39.000000000 +0000
@@ -30,7 +30,7 @@
 (define-alien-type off-t (signed 64))
 (define-alien-type size-t (unsigned 32))
 (define-alien-type ssize-t (signed 32))
-(define-alien-type time-t (signed 32))
+(define-alien-type time-t (signed 64))
 (define-alien-type suseconds-t (signed 32))
 (define-alien-type uid-t (unsigned 32))
 ;; Types in src/runtime/wrap.h. See that file for explantion.
@@ -141,6 +141,7 @@
 (defconstant clock-process-cputime-id 2) ; #x2
 (defconstant clock-realtime-alarm 8) ; #x8
 (defconstant clock-realtime-coarse 5) ; #x5
+(defconstant clock-tai 11) ; #xb
 (defconstant clock-monotonic-coarse 6) ; #x6
 (defconstant clock-monotonic-raw 4) ; #x4
 (defconstant clock-boottime 7) ; #x7
@@ -149,11 +150,11 @@
 ;;; structures
 (define-alien-type nil
   (struct timeval
- (tv-sec (signed 32))
- (tv-usec (signed 32))))
+ (tv-sec (signed 64))
+ (tv-usec (signed 64))))
 (define-alien-type nil
   (struct timespec
- (tv-sec (signed 32))
+ (tv-sec (signed 64))
           (tv-nsec (signed 32))))

I think we need to change

❯ git grep observed-internal-real-time-delta-sec
src/code/thread-structs.lisp: #-64-bit (observed-internal-real-time-delta-sec 0 :type sb-vm:word)
src/code/unix.lisp: (sb-thread::thread-observed-internal-real-time-delta-sec thr))

to account for the 64bit nature of tv-sec and friends, even on 32 bit architectures.

Best regards, Peter

Revision history for this message
Douglas Katzman (dougk) wrote :

The easiest solution may be to put some C code in wrap.c that returns a timespec the way lisp expects it to look because I don't see anything in the Lisp side that seems wrong. Nanoseconds are immediately scaled down by 10^6 after calling clock_gettime so that get-internal-real-time remains a fixnum. Therefore anything stored in the 'observed-delta' slot should not be too large.
I'll bet it's a discrepancy in what Lisp thinks a 64-bit integer looks in a C structure in this ABI (is it most-significant half first or second? I don't know). I see no other instance where Lisp cared about that for a 32-bit build. A few kernel types were 64-bit already, but none of them very interesting to Lisp: dev_t, ino_t for example

Revision history for this message
Sean Whitton (spwhitton) wrote :

Hello,

The error output is slightly different with sbcl 2.4.5 but it would seem to be the same bug:

    "obj/from-xc/src/code/late-globaldb.lisp-obj"
    Internal error #88 "Object is not of type UNSIGNED-BYTE-32." at 0x4f859610
 SC: 0, Offset: 0 $1= 0x51267e0f: other pointer
    fatal error encountered in SBCL pid 31092:
    internal error too early in init, can't recover

    Welcome to LDB, a low-level debugger for the Lisp runtime environment.
    ldb>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.