Seems that the duplicated are expected, and the crash seems related to how i access the name slot
If i change the code to remove the mem-ref form it works fine, but i don't know what is the different.
(cffi:with-foreign-object (p :pointer)
(ice-cffi:getifaddrs p)
(do ()
((cffi:null-pointer-p p))
(format t "Interface: ~a~%" (cffi:foreign-slot-value p 'ifaddrs 'name))
(setf p (cffi:foreign-slot-value p 'ifaddrs 'next))))
On Mon, Dec 13, 2010 at 10:39 PM, pepone.onrez pepone.onrez@gmail.comwrote:
Hi,
I don't understand why my loop crashes,
Here is my grovel definition for ifaddrs struct:
(cstruct ifaddrs "struct ifaddrs" (next "ifa_next" :type :pointer) (name "ifa_name" :type :string) (flags "ifa_flags" :type :unsigned-int) (address "ifa_addr" :type :pointer) (netmask "ifa_netmask" :type :pointer) (broadcast "ifa_broadaddr" :type :pointer) (point-to-point-destination "ifa_dstaddr" :type :pointer) (data "ifa_data" :type :pointer))
Here is my loop, i was expecting next to be a null pointer after the first vmnet8
CL-USER> (cffi:with-foreign-object (p :pointer)
(getifaddrs
p)
(do
()
((cffi:null-pointer-p
p))
(format t "Interface: ~a~%" (cffi:foreign-slot-value
(cffi:mem-ref p :pointer) 'ifaddrs 'name)) (setf p (cffi:foreign-slot-value p 'ifaddrs 'next)))) Interface: lo
Interface: sit0
Interface: eth0
Interface: wlan0
Interface: vmnet1
Interface: vmnet8
Interface: lo
Interface: wlan0
Interface: vmnet1
Interface: vmnet8
Interface: lo
Interface: wlan0
Interface: vmnet1
Interface: vmnet8
; Evaluation aborted on #<SB-SYS:MEMORY-FAULT-ERROR {BF604E1}>.
Regards, Jose