Thin with SSL on El Capitan

1 minute read

Hit a bug, couldn’t find the answer, documenting it here for the next person.

I’m working on a Rails project where I need SSL in development. The simple way to do this is with the thin gem for example http://www.railway.at/2013/02/12/using-ssl-in-your-local-rails-environment/

It had been working (on OS X El Capitan), but suddenly thin started blowing up on me, either the server wouldn’t start with:

-bash(3373,0x7fff71f87000) malloc: *** error for object 0x100007f9132d01e4: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

Or the server would start but would blow up on HTTPS requests:

Unexpected error while processing request: negative string size (or size too big)
	/blah/blah/blah/eventmachine-1.0.8/lib/em/connection.rb:488:in `get_peer_cert'

Googling returned nothing of use. (Hopefully it now returns this post.) Given the stack trace, I suspected the problem was with eventmachine. Eventmachine was a pain to build on El Capitan because Apple stopped shipping open SSL headers. I’d previously gotten it to build with:

gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include

however, the current best advice on building it on El Capitan has changed to:

PKG_CONFIG_PATH=/usr/local/Cellar/openssl/1.0.2e/lib/pkgconfig gem install eventmachine

(This presumes you have installed OpenSSL with Brew. If you have a different version of OpenSSL, you’ll need to change that path.)

Rebuilding thusly fixed thin. I’m back in business and perhaps you are as well.

I haven’t dug into why it works. My best guess is the issue is a conflict between the OpenSSL library Apple ships and the headers that come with Brew. But works is good enough at the moment.

Comments