Main menu

Daniel's Stuff

Month: March 2009

I’ve been having some “fun” with my new Mac Pro. In order for me to be able to use it for my daily work I need to be able to connect to a Microsoft SQL Server instance from the Rails app I’m working on at my day job. Normally this is just a simple matter of installing FreeTDS, Ruby-ODBC and the Ruby DBI and DBD packages. When I did this, as soon as I tried to make a connection to the SQL Server instance my application would crash with a bus error! After a bit of digging around with gdb I discovered that the application was crashing when FreeTDS was trying to deallocate a string using the standard C library memory function free. The really weird thing is that the string was pointing to a valid string. I dug a little further and found that if I changed the code that was allocating the string to use malloc and strcpy instead of strdup it worked! If anybody out there knows why this might make a difference I’d really like to hear from them about it.