Welcome to the CHICKEN Scheme pasting service

read-symbolic-link crash added by gahr on Mon Oct 28 15:31:34 2024

> cat read-symbolic-link.scm
(import (chicken foreign)
        (chicken fixnum)
        (chicken file posix)
        )

(define-foreign-variable _filename_max long "FILENAME_MAX")

#>
#define C_do_readlink(f, b) C_fix(readlink(C_c_string(f), C_c_string(b), FILENAME_MAX))
<#

(define buf (make-string (fx+ _filename_max 1) #\a))
(let ((res (##core#inline "C_do_readlink" (##sys#make-c-string "/home" 'here) buf)))
  (print "buf: <" buf ">")
  (print "res: <" res ">")
  (substring buf 0 res))

> csc read-symbolic-link.scm

> ./read-symbolic-link

Error: bus error

        Call history:

        read-symbolic-link.scm:12: scheme#make-string     
        read-symbolic-link.scm:13: ##sys#make-c-string    
        read-symbolic-link.scm:14: chicken.base#print           <--
buf: <

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which relatively recent Scheme report version does CHICKEN _not_ implement?
Visually impaired? Let me spell it for you (wav file) download WAV