[plt-scheme] Strange error in C bindings

From: Noel Welsh (noelwelsh at yahoo.com)
Date: Tue Jan 21 12:28:30 EST 2003

Hi all,

I'm hacking intermittently on a MySQL driver.  I have
a strange (aka interesting) error in the bindings. 
This application:

  (connect #f "foo" "foo" "foo")

(a connection to a database that doesn't exist)
reliably causes a segmentation fault if I define
connect thusly:

  ;; connect : (union string #f) (union string #f)
(union string #f)
  ;; (union string #f) [integer] [string] [integer] ->
mysql
  (define connect
    (opt-lambda (host user password db [port 0]
[unix-socket #f] [client-flag 0])
      (let ((mysql (make-MYSQL)))
        (maybe-fail-mysql (mysql-init mysql))
        (maybe-fail-mysql (mysql-real-connect mysql
host user password db port unix-socket
client-flag)))))

This seemingly equivalent definition raises an
exception as it should:

  (define connect
    (opt-lambda (host user password db [port 0]
[unix-socket #f] [client-flag 0])
      (let ((mysql (make-MYSQL)))
        (maybe-fail-mysql (mysql-init mysql))
        (mysql-real-connect mysql host user password
db port unix-socket client-flag)
        (maybe-fail-mysql mysql))))

Can anyone hypothesise why this might be the case? 
I'm more curious than anything. 

Ta,
Noel

PS: The complete code is @ Schematics src/libs/database/mysql

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


Posted on the users mailing list.