If I define SCM_DEBUG_TYPING_STRICTNESS to 0 to disable type checking, I see 
the same fault as Adrian on powerpc:
https://lists.gnu.org/archive/html/guile-devel/2020-12/msg00003.html

Core was generated by 
`/home/dave/debian/guile-3.0/guile-3.0-3.0.4/libguile/.libs/guile -e (@@ 
(guild)'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0xf769ba54 in scm_sum (x=0, y=6) at numbers.c:7569
7569      else if (SCM_BIGP (x))
[Current thread is 1 (Thread 0xf7afdb40 (LWP 29473))]
(gdb) ptype x
type = unsigned int
(gdb) bt
#0  0xf769ba54 in scm_sum (x=0, y=6) at numbers.c:7569
#1  0xf768074c in add_immediate (a=0, b=<optimized out>) at intrinsics.c:80
#2  0xf7706754 in vm_regular_engine (thread=0xf7aaee00) at vm-engine.c:1583
#3  0xf77091b4 in scm_call_n (proc=536870911, argv=0x0, nargs=6) at vm.c:1608
#4  0xf7656224 in scm_call_0 (proc=<optimized out>) at eval.c:490
#5  0xf768b628 in scm_primitive_load_path (args=<optimized out>) at load.c:1259
#6  0xf768bcb8 in scm_c_primitive_load_path (filename=<optimized out>)
    at load.c:1275
#7  0xf767abf8 in scm_load_startup_files () at init.c:223
#8  0xf767b39c in scm_i_init_guile (base=<optimized out>) at init.c:507
#9  0xf76f8938 in scm_i_init_thread_for_guile (base=0x0, dynamic_state=6)
    at threads.c:570
#10 0xf76f8acc in scm_i_init_thread_for_guile (dynamic_state=536870911,
    base=0x0) at threads.c:677
#11 with_guile (base=0x0, data=0x6) at threads.c:638
#12 0xf62674d4 in GC_call_with_stack_base ()
   from /usr/lib/hppa-linux-gnu/libgc.so.1
#13 0xf76f9058 in scm_i_with_guile (dynamic_state=<optimized out>,
    data=<optimized out>, func=<optimized out>) at threads.c:688
#14 scm_with_guile (func=<optimized out>, data=<optimized out>)
    at threads.c:694
#15 0xf767ac8c in scm_boot_guile (argc=69930, argv=0x6,
    main_func=<error reading variable>, closure=0xf7756928) at init.c:291
--Type <RET> for more, q to quit, c to continue without paging--
#16 0x0001070c in main (argc=-143337176, argv=0x6) at guile.c:95
(gdb) disass $pc-16,$pc+16
Dump of assembler code from 0xf769ba44 to 0xf769ba64:
   0xf769ba44 <scm_sum+228>:    ldi 6,r20
   0xf769ba48 <scm_sum+232>:    and r26,r20,r21
   0xf769ba4c <scm_sum+236>:    cmpib,<> 0,r21,0xf769bba0 <scm_sum+576>
   0xf769ba50 <scm_sum+240>:    addil L%5800,r19,r1
=> 0xf769ba54 <scm_sum+244>:    ldw 0(r26),r22
   0xf769ba58 <scm_sum+248>:    ldi 117,r21
   0xf769ba5c <scm_sum+252>:    extrw,u r22,31,16,r22
   0xf769ba60 <scm_sum+256>:    cmpb,= r21,r22,0xf769bbc0 <scm_sum+608>
End of assembler dump.
(gdb) p/x $r26
$1 = 0x0
(gdb) p/x x
$2 = 0x0
(gdb) p/x $r21
$3 = 0x0

/* Each bignum is just an mpz_t stored in a double cell starting at word 1. */
#define SCM_I_BIG_MPZ(x) (*((mpz_t *) (SCM_CELL_OBJECT_LOC((x),1))))
#define SCM_BIGP(x) (SCM_HAS_TYP16 (x, scm_tc16_big))

#define SCM_HAS_TYP16(x, tag)   (SCM_HAS_HEAP_TYPE (x, SCM_TYP16, tag))

#define SCM_HAS_HEAP_TYPE(x, type, tag)                         \
  (SCM_NIMP (x) && type (x) == (tag))

/* Checking if a SCM variable holds an immediate or a heap object.  This
   check can either be performed by checking for tc3==000 or tc3==00x,
   since for a SCM variable it is known that tc1==0.  */
#define SCM_IMP(x)              (6 & SCM_UNPACK (x))
#define SCM_NIMP(x)             (!SCM_IMP (x))

# define SCM_UNPACK(x) (x)

So, SCM_NIMP(x) is true.  The segmentation fault must be in the check: type (x) 
== (tag).

/* Definitions for tc16: */
#define SCM_TYP16(x)            (0xffff & SCM_CELL_TYPE (x))

#define SCM_CELL_TYPE(x) SCM_CELL_WORD_0 (x)

#define SCM_CELL_WORD(x, n) SCM_GC_CELL_WORD ((x), (n))
#define SCM_CELL_WORD_0(x) SCM_CELL_WORD ((x), 0)

#define SCM_GC_CELL_OBJECT(x, n) (((SCM *)SCM2PTR (x)) [n])
#define SCM_GC_CELL_WORD(x, n)   (SCM_UNPACK (SCM_GC_CELL_OBJECT ((x), (n))))

/* FIXME: deprecate. */
#define PTR2SCM(x) (SCM_PACK_POINTER (x))
#define SCM2PTR(x) ((scm_t_cell *) (SCM_UNPACK_POINTER (x)))

/* Packing SCM objects into and out of pointers.  */
#define SCM_UNPACK_POINTER(x) ((scm_t_bits *) (SCM_UNPACK (x)))
#define SCM_PACK_POINTER(x) (SCM_PACK ((scm_t_bits) (x)))

The SCM_GC_CELL_WORD define explains the segfault.  x is cast to a pointer and 
this
is used to access cell word.

The value x=0 passed to scm_sum is either wrong or there is a bug in SCM_BIGP.

Regards,
Dave anglin

-- 
John David Anglin  dave.ang...@bell.net

Reply via email to