[Openmcl-devel] Intermittent FFI problem

Ron Garret ron at flownet.com
Thu Mar 31 21:48:40 UTC 2016


I’m facing a very complicated and annoying problem.

I’m trying to use Drakma to connect to an HTTPS server.  The problem is that Drakma uses CL+SSL, which uses libssl, which is out of date on OS 10.9.5. (It’s version 0.9.8) and it won’t let me connect to one particular server (api.name.com in case you want to try to reproduce this problem).

Normally the solution would be to simply update libssl, but unfortunately that doesn’t work.  When I tried it, it made MacOS very (very!) unhappy and actually rendered my Mac unbootable.  (So don’t try it!)

So I have to install the updated libssl somewhere else, like /usr/local/lib.

Unfortunately, CL+SSL hard-codes the path to libssl as follows:

(cffi:define-foreign-library libssl
...
  (:darwin (:or "libssl.dylib" "/usr/lib/libssl.dylib”))
…

and it does not seem to respect cffi:*foreign-library-directories*.  No matter when I set that to, it picks up the outdated libssl in /usr/lib.

So I tried the following:

1.  Load CL+SSL
2.  (cffi:close-foreign-library (gethash 'cl+ssl::libssl cffi::*foreign-libraries*))
3.  (cffi:load-foreign-library "libssl" :search-path "/usr/local/ssl/lib/libssl.dylib”)

That works 99% of the time.  But every now and then it fails.  I can’t reliably reproduce it, but my startup sequence is always exactly the same each time.  The only pattern seems to be that it’s more likely to fail after CCL has not been running for a while, so it might be a cache issue, but the failures are infrequent enough that I don’t really have enough data to tell.  All I know is that I’ve never had two failures in a row.  Quitting and restarting after a failure has always worked.

Any ideas on what might be causing this?

rg



More information about the Openmcl-devel mailing list