gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Fatal error in BIT-AND on rank 0 array - Fix


From: Peter Wood
Subject: Re: [Gcl-devel] Fatal error in BIT-AND on rank 0 array - Fix
Date: Mon, 27 Jan 2003 20:31:38 +0100
User-agent: Mutt/1.4i

Hi,
On Sun, Jan 26, 2003 at 08:09:59PM -0600, Paul F. Dietz wrote:
> address@hidden ansi-tests]$ gcl
> GCL (GNU Common Lisp)  Version(2.5.0) Fri Jan 24 21:23:56 CST 2003
> Licensed under GNU Library General Public License
> Contains Enhancements by W. Schelter
> 
> Use (help) to get some basic information on how to use GCL.
> 
> >(defun make-bit0-array (i) (make-array nil :element-type 'bit 
> :initial-element i))
> 
> MAKE-BIT0-ARRAY
> 
> >(make-bit0-array 0)
> 
> #0A0
> 
> >(bit-and (make-bit0-array 0) (make-bit0-array 0))
> 
> Error in BIT-AND [or a callee]:
> Error in CONDITIONS::CLCS-UNIVERSAL-ERROR-HANDLER [or a callee]: Caught 
> fatal error [memory may be damaged]
> 
> Fast links are on: do (use-fast-links nil) for debugging
> Broken at PCL::PRINT-STD-INSTANCE.
>  1 (Abort) Return to debug level 1.
>  2 Return to top level.
> dbl:>>>
> 
> 
> I have tests of the various BIT-* functions; they cause the test
> suite to abort fatally when run due to this bug.  I will check
> the changes in anyway, since they are passing on CMUCL.  If you
> want to run the suite without them comment out the load forms
> in gclload2.lsp.
> 

CLISP barfs (yes, really!) on this as well.  I have a fix, but be
warned that I don't claim to properly understand the way GCL does
arrays.  I have not looked at this before.

In o/num_log.c, in the function siLbit_array_op(), the relevant code
section is labelled L2 and looks like this:

        L2:
                if (r == Cnil) {
                  object b[F_ARG_LIMIT];
                  for (i = 0;  i < x->a.a_rank;  i++)
                    b[i] = (make_fixnum(x->a.a_dims[i]));
                  r=Iapply_fun_n1(fSmake_array1,5,x->a.a_rank,
                               aet_bit,
                               Cnil,
                               small_fixnum(0),
                               Cnil,
                               Cnil,
                                 b);
                }

Iapply_fun_n1() is not correctly setting the 6th arg to fSmake_array
to nil.  In fact, I think, it is not consistently setting it to
anything (but I'm not sure).  I don't see why we even need to call
Iapply_fun_n1 since the 6th arg can be set here.(fSmake_array1 only
takes 6 args, so we certainly don't need to mix up va_args in this)
This is what I've done, and it appears to work (reread caveat,
above!):

        L2:
                if (r == Cnil) {
                  object dim_arg;
                  dim_arg = Cnil;
                  for (i = 0;  i < x->a.a_rank;  i++)
                    dim_arg = MMcons((make_fixnum(x->a.a_dims[i])), dim_arg);
                  r = fSmake_array1(aet_bit, Cnil, small_fixnum(0), Cnil, Cnil, 
dim_arg);
                }

Note that this results in a warning from GCC when compiling since the
5th arg should be an integer not Cnil, but this is _NOT_ something I
have introduced.  The compiler just wasn't catching it before when
fSmake_array1 was being called via Iapply_fun_n1. (at least thats my
current explanation :-)

> (defun make-bit0-array (i) (make-array nil :element-type 'bit
:initial-element i))

MAKE-BIT0-ARRAY

> (bit-and (make-bit0-array 0) (make-bit0-array 0))

#0A0

> 

Regards,
Peter





reply via email to

[Prev in Thread] Current Thread [Next in Thread]