[gambit-list] print vs. display segfault

Lang Martin lang-gb at coptix.com
Wed Apr 25 17:23:27 EDT 2007

ok, I got a segfault in a program and I don't quite understand the  

This code:

(define (string-escape string chars
	               #!optional (escape (lambda (c) (print #\\ c))) port)
    (let ((pred? (%string-charset->pred chars))
          (output (or port (open-output-string ""))))
        (lambda (c)
          (if (pred? c)
              (escape c)
              (print c)))  ; this is where the anti-magic happens
      (or port (get-output-string output))))

is called many times (inside a function called sql-quote-object). On  
line 1420 of my input file, it segfaults. I've had a hard time  
reproducing this in a more confined context, but I will if this  
doesn't turn out to be known or easily deducible.

If I change that (print c) to (display c), all is well. At first I  
was under the impression that the output was leaking because line  
1421 turned out to contain a literal ^H. The progam exhibits the same  
behavior with all the lines containing control characters removed  
from the input. Also exhibits the same behavior in a file containing  
multiple copies of the first 1419 lines of the input, so I'm pretty  
confident it doesn't have anything to do with the input.

I'm sorry this message is so rough -- I really will create a  
responsible bug report if this vague one doesn't give someone with a  
good understanding of the internals something to go on.

Does print buffer it's output, by any chance?

More information about the Gambit-list mailing list