jcbeaudoin / MKCL

ManKai Common Lisp
Other
33 stars 8 forks source link

&rest processing for mk_si_make_structure and mk_si_put_properties #21

Closed davidmullen closed 6 months ago

davidmullen commented 6 months ago

When I saw that a defstruct with 63 or more slots wasn't processed correctly, I suspected that it was hitting a stack limit, namely si:c-arguments-limit. Adjusting the min_arg argument to mkcl_setup_for_rest solves the problem, as it calls mkcl_va_start to set the stack pointer. A similar fix is for si:put-properties.

jcbeaudoin commented 6 months ago

This one requires some more serious investigation to figure out how I messed up, in case it could affect more locations in the rest of the code. Would you have a small piece of code that triggers the bug? I would find that useful here. Thanks.

davidmullen commented 6 months ago

The trigger is a structure with at least 63 slots:

(eval `(defstruct test-struct
         ,@(loop for i from 0 to 70
                 collect `(,(make-symbol (format nil "SLOT-~D" i))
                           ,(format nil "~R" i)))))

Then (make-test-struct) should give:

#S(TEST-STRUCT :SLOT-0 "zero" :SLOT-1 "one" ...)

But instead, it ends up with wrong values in the slots:

#S(TEST-STRUCT :SLOT-0 #<The STRUCTURE-CLASS TEST-STRUCT 140243168666272> :SLOT-1 "zero" ...)