Type-checking of alien structure slots

Bug #734259 reported by Stas Boukarev
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SBCL
Confirmed
Low
Unassigned

Bug Description

tests/foreign.test.sh has a test named "struct offsets",
it fails when SBCL is built without sb-eval.
The following is an extraction which triggers it:

(define-alien-type a (struct a (x (unsigned 32))))
(define-alien-type b (struct b (y a)))
(setf (slot (make-alien b) 'y) (make-alien a))

=>

#<SB-ALIEN-INTERNALS:ALIEN-VALUE :SAP #X008CC500 :TYPE (* (STRUCT A #))>
is not of type (ALIEN (STRUCT A (X #)))

(a quick way to get it fail without recompiling with sb-eval disabled
 is to remove (let ((*evaluator-mode* :interpret)) ...)
 in sb-alien::coerce-to-interpreted-function)

When B is defined as (define-alien-type b (struct b (y (* a)))),
everything works.

So, the questions are:
* Should it be defined as (* a)?
* If so, should it signal an error even when *evaluator-mode* is :interpret?
** I would think it should, because it doesn't even when it's clearly
a wrong type, e.g. (setf (slot (make-alien b) 'y) (make-alien int)) succeeds.

Tags: alien
Revision history for this message
Nikodemus Siivola (nikodemus) wrote :

Marking as confirmed, but not commenting on what exactly should be done.

Alien pointer types are IIRC somewhat magical, but the details of how escape me -- and I'm not sure I ever figured out the "why".

Changed in sbcl:
importance: Undecided → Low
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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