jon <[EMAIL PROTECTED]> writes:
> hello all,
>
> why is it that when i do something like
> (alien:with-alien ((var1 char) (var2 integer))
> ; blahblah
> (unix:unix-read fd (alien:addr var2) 4)
> )
>
> it segfaults? i'm using the latest from debian (18e-7).
> it only happens when there are two or more variables declared,
> when there is only 1, it's ok.
> also, on other times (sorry, i'm forgot to take note of
> what i changed) when i did
> (mutliple-value-bind (result err) (unix:unix-read fd (alien:addr var2) 4)
> (unless err (print err)))
> i got 14, which is EFAULT here.
I can't reproduce this, but I'm running 18d+ (24 September 2002 build
4293). However, I get:
* (alien:with-alien ((var1 char) (var2 integer))
(let ((fd (unix:unix-open "/tmp/test.lisp" unix:o_rdonly unix:o_creat)))
(unix:unix-read fd (alien:addr var2) 4)
(unix:unix-close fd))
var2)
Type-error in KERNEL::OBJECT-NOT-SAP-ERROR-HANDLER:
#<Alien (*
(ALIEN:SIGNED
32)) at #x080838B0> is not of type SYSTEM:SYSTEM-AREA-POINTER
Restarts:
0: [ABORT] Return to Top-Level.
Debug (type H for help)
(UNIX:UNIX-READ 3 5 #<Alien (* #) at #x080838B0> 4)[:EXTERNAL]
Source:
; File: target:code/unix-syscall.lisp
(DEFUN UNIX-READ (FD BUF LEN)
"Unix-read attempts to read from the file described by fd into
the buffer buf until it is full. Len is the length of the buffer.
The number of bytes actually read is returned or NIL and an error
number if an error occured."
(DECLARE (TYPE UNIX-FD FD)
(TYPE SYSTEM:SYSTEM-AREA-POINTER BUF)
(TYPE # LEN))
...)
but if I do:
* (alien:with-alien ((var1 char) (var2 integer))
(let ((fd (unix:unix-open "/tmp/test.lisp" unix:o_rdonly unix:o_creat)))
(unix:unix-read fd (alien:alien-sap (alien:addr var2)) 4)
(unix:unix-close fd))
var2)
1768710440
You might try adding the `alien:alien-sap' call and see if it helps.
Best wishes,
cbb
--
23:13:20 up 176 days, 8:08, 1 user, load average: 0.02, 0.03, 0.03