Close

Toward Serious Debugging

At some point you may want to know about why something is stuck, whether it’s your own code or someone else’s. Print statements, command lines and logging are fine when you need them but only if you are writing your own code. More is possible. The higher level strace and lower level gdb are good tools to use when something is stuck. While dtrace or SystemTap are certainly amazing and powerful, reaching inside a live kernel, few people want or need that much power.

What are your experiences using these tools?

We meet at Bobby G’s Pizzeria on the second and fourth Sundays of each month from Noon to 3PM in Berkeley near the Downtown Berkeley BART station. Bobby G’s is on University Ave near Shattuck Ave. We hope you join us, join the discussion on our email list and/or join us in #berkeleylug on freenode.net by following the tabs at the top.

grep

There are certain things sysadmins rely on a lot. If they break it’s really not good. For me, the grep tool is one of them, so I was surprised to find inconsistent results. Based on otherwise good advice I was trying to use grep -i '[p]rocess' to look for running processes. When it didn’t work correctly I discovered related bugs 28981 (includes a good test case) and 36567 so that for us in our environment grep fails when:

  • trying to match upper case data (lower case matched ok)
  • using dash i for case insensitive
  • using square brackets as above
  • LANG was set with UTF8

Evidently this has been a problem for a while. Though fixed upstream the fix hasn’t made it’s way to all production Linux environments, making the use of this common trick a bit risky in production.

What other problems have you encountered that you choose to code around?

We meet at Bobby G’s Pizzeria on the second and fourth Sundays of each month from Noon to 3PM in Berkeley near the Downtown Berkeley BART station. Bobby G’s is on University Ave near Shattuck Ave. We hope you join us, join the discussion on our email list and/or join us in #berkeleylug on freenode.net by following the tabs at the top.