SB-ALIEN violates type correctness

Bug #1514023 reported by Douglas Katzman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

If SBCL is built without either evaluator, so that SB-ALIEN::COERCE-TO-INTERPRETED-FUNCTION means the same as COMPILE, then at least one test in foreign.test.sh will fail, and it's not clear whether the test is wrong or the ALIEN routines are deliberately trying to be sloppy about types.
The failure occurs because COMPILE (as opposed to eval) obeys declarations - as does sb-fasteval which similarly fails, but which can be ruled out as the cause of the failure.
Specifically, in this test, COMPUTE-DEPORT-LAMBDA asserts that it receives a value of type (ALIEN (STRUCT <something>)) when it in fact receives a value of type (* (ALIEN (STRUCT <something>))).

;;; Test case
  (define-alien-type inner (struct inner (var (unsigned 32))))
  (define-alien-type outer (struct outer (one inner) (two inner)))
  (defvar *outer* (make-alien outer))
  (defvar *inner* (make-alien inner))
  (setf (slot *inner* 'var) 20)
  (setf (slot *outer* 'one) *inner*)
=>
debugger invoked on a TYPE-ERROR in thread
#<THREAD "main thread" RUNNING {1002A94D63}>:
  The value
    #<ALIEN-VALUE :SAP #X00644BF0 :TYPE (* (STRUCT INNER (VAR # :OFFSET 0)))>
  is not of type
    (ALIEN (STRUCT INNER (VAR (UNSIGNED 32) :OFFSET 0))).

Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1002A94D63}>
0: ((LAMBDA (VALUE SAP OFFSET IGNORE)) #<ALIEN-VALUE :SAP #X00644BF0 :TYPE (* (STRUCT INNER (VAR (UNSIGNED 32) :OFFSET 0)))> #.(INT-SAP #X00644BD0) 0 #<unavailable a\
rgument>)
1: ((SETF %ALIEN-VALUE) #<ALIEN-VALUE :SAP #X00644BF0 :TYPE (* (STRUCT INNER (VAR (UNSIGNED 32) :OFFSET 0)))> #.(INT-SAP #X00644BD0) 0 #<ALIEN-RECORD-TYPE (STRUCT IN\
NER (VAR (UNSIGNED 32) :OFFSET 0))>)
2: (SIMPLE-EVAL-IN-LEXENV (SETF (SLOT *OUTER* (QUOTE ONE)) *INNER*) #<NULL-LEXENV>)
3: (EVAL (SETF (SLOT *OUTER* (QUOTE ONE)) *INNER*))

Note that:
(type-of *inner*) => (ALIEN (* (STRUCT INNER (VAR (UNSIGNED 32) :OFFSET 0))))
And it works if you do: (setf (slot *outer* 'one) (DEREF *inner*))

I'm not sure whether that's supposed to be mandatory to deref the right hand side.

Revision history for this message
Stas Boukarev (stassats) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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