16 votes

A very subtle bug

4 comments

  1. [2]
    Jakobeha
    Link
    Bugs like these (with the steps it takes to debug them) are another reason why AI probably won’t replace programmers for even seemingly “easy” tasks anytime soon.

    Bugs like these (with the steps it takes to debug them) are another reason why AI probably won’t replace programmers for even seemingly “easy” tasks anytime soon.

    9 votes
    1. xk3
      Link Parent
      maybe... although if we copy paste some text from the article into a GenAI tool like Claude: It provides an answer that uses tarfile and avoids calling subprocess. Although it makes a couple minor...

      maybe... although if we copy paste some text from the article into a GenAI tool like Claude:

      The following code snippet in Python is intended to extract and return a single file from a tarball:

      It provides an answer that uses tarfile and avoids calling subprocess. Although it makes a couple minor mistakes it would have avoided above bug.

      And it would have exited after returning the first file: something that the author's subprocess version does not do but which seems to be the original intention of the author--although maybe they were initially unaware that Tar files can contain multiple files with the same names [most archiving tools expose only the latest version of the file in a UI]. Although, I'm not sure about the actual implementation details of tar.getmembers() and tar.extract()--just what the python code looks like it is doing.

      2 votes
  2. [2]
    xk3
    Link
    I found this article to be interesting. The author also made a follow-up article: https://blog.nelhage.com/2010/03/followup-to-a-very-subtle-bug/ So it is a bug that has been fixed over a decade...

    I found this article to be interesting. The author also made a follow-up article: https://blog.nelhage.com/2010/03/followup-to-a-very-subtle-bug/

    So it is a bug that has been fixed over a decade ago but it is pretty easy to follow and still interesting to read about.

    3 votes
    1. brandt
      Link Parent
      I love stories like this. It's like a whodunit where you can speculate as it unfolds. By the end, you've either refreshed your knowledge or learned something along the way. Also, learning how...

      I love stories like this. It's like a whodunit where you can speculate as it unfolds. By the end, you've either refreshed your knowledge or learned something along the way.

      Also, learning how stuff breaks is a great way of getting a better understanding of how it works.

      3 votes