Comment 1 for bug 622339

Revision history for this message
Naofumi Honda (honda-c) wrote :

This happens with a recent ccl under linux 32 bits env, and not occure under linux 64, etc.
By this wrong alignment problem, for example, cl-gtk2's demo crashes.
The reason is very clear. As you know, gcc under linux 32 has 64 bits alignment for the long-long type. But
there is an exception that, in a struct or union, it becomes 32 bits alignment. However,
ccl:foreign-type-alignment always returns 64 for the long-long type (of course, it is theoretically true
and internally ccl uses proper alignment (=32) for the record type).

Therefore the following patch is needed:
*** ./src/cffi-openmcl.lisp.org 2012-09-25 00:48:14.000000000 +0900
--- ./src/cffi-openmcl.lisp 2012-09-25 00:51:09.000000000 +0900
***************
*** 222,227 ****
--- 222,231 ----
  ;; http://clozure.com/pipermail/openmcl-devel/2005-June/002777.html
  (defun %foreign-type-alignment (type-keyword)
    "Return the alignment in bytes of a foreign type."
+ #+32-bit-target <= please specify proper condition!
+ (case type-keyword
+ ((:double :long-long :unsigned-long-long)
+ (return-from %foreign-type-alignment 4)))
    (/ (ccl::foreign-type-alignment
        (ccl::parse-foreign-type
         (convert-foreign-type type-keyword))) 8))