with-alien leads to GC invariant lost

Bug #1387861 reported by Ken Olum
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Invalid
Undecided
Unassigned

Bug Description

After these definitions:

(define-alien-type statfs
  (struct statfs
   (type long)
   (bsize long) ;Block size
   (blocks long) ;Total blocks
   (bfree long) ;Total free blocks
   (bavail long) ;Free blocks to non-superuser
   (files long) ;Total inodes
   (ffree long) ;Free inodes
   (fsid long)
   (namelen long) ;Max filename length
   ))

(define-alien-routine statfs int
  (path c-string)
  (data (* statfs)))

This code, which worked in 1.0.56, now crashes lisp in 1 .2.5 with the error
GC invariant lost, file "gencgc.c", line 303:

(with-alien ((data statfs))
  (statfs "/" (addr data)))

Doing it without stack-allocating the structure still works:

(let ((data (make-alien statfs)))
  (statfs "/" data))

 uname -a
Linux tunic6.uit.tufts.edu 2.6.32-358.14.1.el6.x86_64 #1 SMP Mon Jun 17 15:54:20 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

 *features*

(:ALIEN-CALLBACKS :ANSI-CL :ASH-RIGHT-VOPS :C-STACK-IS-CONTROL-STACK
 :COMMON-LISP :COMPARE-AND-SWAP-VOPS :COMPLEX-FLOAT-VOPS :CYCLE-COUNTER :ELF
 :FLOAT-EQL-VOPS :GENCGC :IEEE-FLOATING-POINT :INLINE-CONSTANTS :LARGEFILE
 :LINKAGE-TABLE :LINUX :LITTLE-ENDIAN :MEMORY-BARRIER-VOPS :MULTIPLY-HIGH-VOPS
 :OS-PROVIDES-BLKSIZE-T :OS-PROVIDES-DLADDR :OS-PROVIDES-DLOPEN
 :OS-PROVIDES-GETPROTOBY-R :OS-PROVIDES-POLL :OS-PROVIDES-PUTWC
 :OS-PROVIDES-SUSECONDS-T :PACKAGE-LOCAL-NICKNAMES :RAW-INSTANCE-INIT-VOPS
 :SB-DOC :SB-EVAL :SB-FUTEX :SB-LDB :SB-PACKAGE-LOCKS :SB-SIMD-PACK
 :SB-SOURCE-LOCATIONS :SB-TEST :SB-THREAD :SB-UNICODE :SBCL
 :STACK-ALLOCATABLE-CLOSURES :STACK-ALLOCATABLE-FIXED-OBJECTS
 :STACK-ALLOCATABLE-LISTS :STACK-ALLOCATABLE-VECTORS
 :STACK-GROWS-DOWNWARD-NOT-UPWARD :SYMBOL-INFO-VOPS :UNIX
 :UNWIND-TO-FRAME-AND-CALL-VOP :X86-64)

Revision history for this message
Stas Boukarev (stassats) wrote :

You need to include the code to reproduce the issue.

Changed in sbcl:
status: New → Incomplete
Revision history for this message
Stas Boukarev (stassats) wrote :

Ok, sorry, I used a slightly older revision of 1.2.4.xx, so, it's a recent regression.

Changed in sbcl:
status: Incomplete → Triaged
Revision history for this message
Stas Boukarev (stassats) wrote :

Actually, that wasn't the case, it just doesn't get triggered with safepoints enabled. But the problem is that your definition of statfs is wrong. Compare it with the definition in man statfs.
(define-alien-type statfs
  (struct statfs
          (type long)
          (bsize long)
          (blocks long)
          (bfree long)
          (bavail long)
          (files long)
          (ffree long)
          (fsid long)
          (namelen long)
          (fr-size long)
          (spare (array long 5))))

does work. But it is better to grovel the structure.

Changed in sbcl:
status: Triaged → Invalid
Revision history for this message
Ken Olum (kdo) wrote : Re: [Bug 1387861] Re: with-alien leads to GC invariant lost

Huh. It failed for me also in 1.1.14. Perhaps it is very sensitive to
something.

                                        Ken

Revision history for this message
Ken Olum (kdo) wrote :

Ack! You're right. But it's worse than you know. My man statfs gives
the definition that I used, but it is wrong. The truth, in
/usr/include/bits/statfs.h, is just as you said.

Sorry to bother you.

                                        Ken

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.