Content from 2017-06

Horrible Bug
posted on 2017-06-10 16:01:00

I just figured out the most horrible bug! For nearly two months, I've been watching my deploys of a lisp webapp say

Woo server is going to start.
Listening on localhost:5000.
Unhandled WOO.EV.CONDITION:OS-ERROR in thread #<SB-THREAD:THREAD "main thread" RUNNING
                                                 {1005C85A43}>:
  getaddrinfo() failed (Code: -8)
Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1005C85A43}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<WOO.EV.CONDITION:OS-ERROR {1007BD7533}> #<unused argument>)

over and over and over.

Since I only find a little time to work on this stuff, around my day job, it was really pissing me off.

When I finally figured out what the problem was, I was even more pissed off.

It took me forever to try to figure out what that -8 error code was. At least I'd seen C code, before, to know that that was what it was. I must have miscounted, looking at strange webpages that listed the possible errors for getaddrinfo(), and that threw me off for a month alone. Today, I finally decided there wasn't some quick way to solve this, and I had to dig into the problem with due dilligence. I wrote a quick C program to get the description of the error from the horse's mouth:

#include <netdb.h>
#include <stdio.h>

int main(int argc, char** argv[]) {
  const char *explanation = gai_strerror(-8);
  printf("Error -8 is %s", explanation);
  return 0;
}

And it informed me: Error -8 is Servname not supported for ai_socktype. A quick search led me to this stackoverflow, which had a comment I include here for your convenience:

I had this problem with a Tornado/Python app. Apparently, this can be caused by the port being interpreted as a string instead of an integer. So in my case, I needed to change my startup script to force it to be interpreted as an integer.

This turned out to be precisely my problem.

I had written my development configuration as a p-list, which, being readable could contain numbers. In production, I was reading configuration out of environment variables, which are all strings. So, pop in an if statement with a (parse-integer port) and blam.

Two months of hobby time, down the toilet.

I'm gonna have to see if I can make a patch for woo or something to make sure this doesn't happen, again.

This blog covers vegan, ice cream, Work, Vegan, Uncategorized, Rust, Resistance, Research, Repair, Recipes, Physics, Nest, Music, Lisp, Linux, Links, Link, Life, Language, Information, Image, Gnome, Games, Gallery, Food, Fascism, Esperanto, Emacs, Electronics, Education, Dog, Did You Know That?, DRM, Community, Comics, Colgate, Code, Buddhism, Books, Aside, Anarchism, 3D Printing

View content from 2009-04, 2009-06, 2009-07, 2009-08, 2009-10, 2009-11, 2009-12, 2010-05, 2010-06, 2010-07, 2010-08, 2010-09, 2011-01, 2011-02, 2011-03, 2011-04, 2011-06, 2011-07, 2011-08, 2011-09, 2011-10, 2011-11, 2011-12, 2012-01, 2012-02, 2012-03, 2012-04, 2012-07, 2012-08, 2012-09, 2012-11, 2013-02, 2013-03, 2013-04, 2013-06, 2013-07, 2013-09, 2013-11, 2014-01, 2014-02, 2014-03, 2014-07, 2014-11, 2014-12, 2015-01, 2015-02, 2015-07, 2015-10, 2015-11, 2015-12, 2016-01, 2016-05, 2016-08, 2016-10, 2016-11, 2016-12, 2017-02, 2017-06, 2018-04, 2019-03, 2009-03


Unless otherwise credited all material Creative Commons License by Matt Novenstern