When an FTP Transfer Breaks Your Software: A Troubleshooting Tale
Upgrading software can sometimes be more of an adventure than you’d expect. Recently, I decided to upgrade kdb+ to version 4.1 on my Ubuntu server. Seemed simple enough, right? I downloaded the archive to my Mac, unzipped it, and then connected to the server via FTP using Filezilla. From there, I dragged and dropped the q.k and l64 folders over to the server.
With everything in place, I logged in via SSH, ready to fire up q. The paths were all set, so I confidently typed the command and hit enter — only to be greeted with a “Permission denied” error. Alright, no big deal. I thought, I’ll just chmod +x on the q binary and get this show on the road.
So, I did that and tried running q again. This time, instead of the “Permission denied” error, I got a segmentation fault and a crash. Not exactly what I was hoping for. It was clear something was off. Weird.
I figured maybe the new version of kdb+ needed a newer Ubuntu, so I went ahead and upgraded the OS. But after that, the result was the same. At this point, I started wondering if the new kdb+ version just wasn’t compatible with my setup. So, I downloaded the old version that had been working just fine an hour ago and repeated the process. To my surprise, I got the exact same error. Now, even the previously stable version was crashing with a segfault.
A quick Google search didn’t turn up anything useful, so I dug into /var/log/syslog. The segfault seemed to be tied to ld-linux-x86-64.so.2. Another Google search suggested it could be a permissions issue. I double-checked the permissions on the q file — everything seemed fine, but just to be sure, I did a chmod 777. Still no luck.
I was stuck and starting to get frustrated. Then it hit me — the only thing that had changed from when everything was working was that I transferred the files via FTP. It seemed silly, but I decided to check if that could be the issue. I downloaded the binary archive directly to the server using wget, unzipped it, and ran q. This time, it worked perfectly — no permission errors, no segfaults, just the welcome text.
So, what the heck went wrong with the FTP transfer? After some digging, I discovered that FTP transfers can happen in two modes: ASCII and binary. By default, my FTP client was set to “Auto” mode, where it tries to guess the best transfer mode based on the file content. Turns out, it guessed wrong.
I switched the transfer mode to binary, repeated the process, and voilà — it worked like a charm. Lesson learned: when transferring executable files over FTP, always use binary mode. What seemed like a straightforward upgrade turned into a real learning experience.
21 Aug 2024 Alex Ternovoy 158