[HN Gopher] Bug #915: Solved
       ___________________________________________________________________
        
       Bug #915: Solved
        
       Author : ingve
       Score  : 72 points
       Date   : 2020-01-14 21:45 UTC (1 hours ago)
        
 (HTM) web link (nedbatchelder.com)
 (TXT) w3m dump (nedbatchelder.com)
        
       | hinkley wrote:
       | The first really bizarre bug I fixed was a file descriptor bug.
       | The code was streaming data and in some cases the app would just
       | stop processing network packets. He or I figured out that
       | keyboard input would temporarily unblock things.
       | 
       | He had a compound conditional without enough parentheses in it,
       | and one of the possible outcomes resulted in fd=1, which is stdin
       | on many operating systems. My general advice now is to assume a
       | 5th grade reading level for math (which consists of +-x/), and
       | use parentheses for _everything_ else. Especially if you think
       | yourself to be clever (narrator: he did).
        
       | lilSebastian wrote:
       | Previously: https://news.ycombinator.com/item?id=22028581
        
       | egdod wrote:
       | That was quick.
        
       | yhoiseth wrote:
       | This made me laugh out loud:
       | 
       | > Hacker News can be helpful, in spite of the tangents about
       | shell redirection, authorship attribution, and GitHub
       | monoculture.
        
       | alpb wrote:
       | Pretty funny how the entire HN rallied together to solve some
       | github issue on someone's personal repo. I'll try posting some of
       | my bugs here to see if it'll work for me as well.
        
         | jnwatson wrote:
         | It is hardly just "someone's personal repo". coveragepy has 1k
         | github stars and is used by nearly every Python project under
         | the sun.
        
         | AdmiralAsshat wrote:
         | Soon: "Hacker News Code Review As A Service"
        
         | dang wrote:
         | There's a power-law dropoff when it comes to follow-up
         | submissions, since the hivemind craves novelty. But it would be
         | fun to try. Maybe it could become a thing: Bug HN!
         | 
         | The trick would be to make the bugs intrinsically interesting:
         | weird or hard, and preferably both.
        
         | ehsankia wrote:
         | To be fair, it was a great nerd snipe, as it was a mysterious
         | bug that happened when things aligned perfectly, yet still had
         | a very good repro making it easy to test.
        
       | kjksf wrote:
       | This bug, the HN thread and how hard it is to fix
       | (https://bugs.python.org/issue39318) is a pretty good argument
       | against exceptions.
       | 
       | A code that looks simple and correct has been hiding a very
       | subtle bug because no one understood the implications of an
       | arbitrary exception being thrown at any point under the caller.
       | 
       | And of all the people who looked at the bug not a single one
       | looked at this seemingly simple code and said "oh yeah, that's
       | because this code is obviously wrong". It took someone skilled
       | enough to script gdb to figure out the buggy interactions.
       | 
       | So the next time someone makes fun of `if err != nil`, send them
       | the buggy implementation of tempfile.NamedTemporaryFile and ask
       | them to spot the bug.
       | 
       | Also, KeyboardInterrupt should not be an exception. It's a
       | signal, not an error or exceptional situation that code wants to
       | report to the caller. But once you have a hammer, everything
       | looks like like a nail. In addition to making the code impossible
       | to reason about, no-one can agree what exactly is an exception so
       | they randomly commingle expected errors with exceptional
       | circumstances and, in case of Python, out-of-band signals.
       | 
       | ("randomly" as in: why is "open file" throwing an exception when
       | file doesn't exist but "find substring" returns -1 when substring
       | doesn't exist?)
        
         | excpointer wrote:
         | Popcorn time...
        
       | 0xff00ffee wrote:
       | I saw this pop up a few days ago. Can someone ELI5 how this
       | person's bug made it to the top of HN?
        
       | ehsankia wrote:
       | So the final answer is basically, there's nothing the author can
       | do. The problem was half with the user's code mocking with
       | internals, and half with downstream library not cleaning up
       | properly.
        
       ___________________________________________________________________
       (page generated 2020-01-14 23:00 UTC)