Subject: Re: guile segfaults on 32-bit big-endian targets

From: John David Anglin <[email-masked]>
Date: Tue, 9 Feb 2021 08:03:02 -0500

On 2021-02-08 6:24 p.m., John David Anglin wrote:
> We need to investigate why scm_sum is passed "x=x@entry=0x0".   SCM_BIGP (x) will fault on it.   Maybe SP_REF is broken.
To be more specific, this is the type of sp:

(gdb) ptype sp
type = union scm_vm_stack_element {
    uintptr_t as_uint;
    uint32_t *as_vcode;
    uint8_t *as_mcode;
    SCM as_scm;
    double as_f64;
    uint64_t as_u64;
    int64_t as_s64;
    void *as_ptr;
    scm_t_bits as_bits;
} *
(gdb) p/x &((union scm_vm_stack_element *)$r26)[0].as_scm
$11 = 0xf34147f0
(gdb) p/x &((union scm_vm_stack_element *)$r26)[1].as_scm
$12 = 0xf34147f8
(gdb) x/x 0xf34147f0
0xf34147f0:     0x00000001
(gdb) x/x 0xf34147f8
0xf34147f8:     0x0090020d
(gdb) p/x ((union scm_vm_stack_element *)$r26)[1].as_scm
$13 = 0x90020d
(gdb) p/x ((union scm_vm_stack_element *)$r26)[0].as_scm
$14 = 0x1
(gdb) x/8x 0xf34147f0
0xf34147f0:     0x00000001      0x00002c56      0x0090020d      0x0000097c
0xf3414800:     0x00000007      0x00000c83      0x0000097d      0x000d007f

There are endian aspects to consider in accessing the scm_vm_stack_element struct.

Dave

-- 
John David Anglin  [email-masked]