Thank you, Thomas and Felix, for answering my question :)

Heath


On 07/05/06, felix winkelmann <[EMAIL PROTECTED]> wrote:
On 5/4/06, Heath Johns <[EMAIL PROTECTED]> wrote:

> I've got a noob question: Why does this segfault?  Should I be doing
> this differently?  I'm using 2.3 stable on linux...

Hi!

No noob question at all. You've found a genuine bug: the result
type conversion didn't  do the right thing for null pointers (#f).
Here is a patch to compiler.scm:

891,893c891,900
<                                              ,@(if (memq rtype 
'(nonnull-c-string c-string))
<                                                    `((##sys#make-c-string 
(let () ,@(cddr lam))))
<                                                    (cddr lam)) )
---
>                                              ,@(case rtype
>                                                  ((nonnull-c-string) 
`((##sys#make-c-string (let () ,@(cddr lam)))))
>                                                  ((c-string*)
>                                                   (##sys#syntax-error-hook
>                                                    "`c-string*' is not a valid 
resulte type for callback procedures"
>                                                    name) )
>                                                  ((c-string)
>                                                   `((let ((r (let () ,@(cddr 
lam))))
>                                                       (and r 
(##sys#make-c-string r)) ) ) )
>                                                  (else (cddr lam)) ) )

BTW, I recommend using `define-external' (as suggested by Thomas).
In fact I undocumented `foreign-safe-wrapper' and it wil be
deprecated in future releases, since it is kludgy and not really
useful.

(that c-string* works is a mere coincedence - the special treatment of
strings as callback-results didn't take `c-string*' into account).

Thanks for reporting this!


(felix)



_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to