News for hackers. Stuff that matters.
Re:Worst Bug Ever by jasonkester on Monday January 21, 2013 @10:49AM (#5091945)
I had a similarly fun time back in the 90s debugging a VBA script a co-worker had written for an Excel spreadsheet. She was looping through a bunch of time values...

... so she named her variable "time"

... which, when modified, would (naturally) set the system time of the computer.

I'm not sure whether they've fixed that one yet.

Re:Worst Bug Ever by ja27 on Monday January 21, 2013 @11:39AM (#5092188)
At least once a quarter I'd have a student working on some programming assignment on one of our unix-ish systems where they named the executable "test" and couldn't figure out why it wasn't doing anything they expected.

I also got to the point with FORTRAN (yes, I'm old) students where I'd cut them off and tell them to count the columns and make sure each line started with 6 blanks, not 5.

My favorite bug is still some piece of C code buried in a library that was like this:

   if (flag == TRUE) ...
Or there's the old for loop typo (much easier to detect on today's high-DPI screens):

   for(float x=0.0; x < 3,4; x = x + 0.1) ...
Re:Worst Bug Ever by viraptor on Monday January 21, 2013 @12:30PM (#5092493)
I don't get what's wrong with the flag check apart from being a bit too verbose.
Re:Worst Bug Ever by mpyne on Monday January 21, 2013 @01:21PM (#5092803)
TRUE is going to be 1. The flag value might have the value 0x2, 0x4, 0xsomething_else, etc., which will not equal exactly 1 (TRUE).

What you want varies but is probably something like:

    if (flag & FLAG_VALUE) ...
    if (flag) ....
    if ((flag & FLAG_VALUE) == TRUE) ...
that kind of thing.
Re:Worst Bug Ever by geon on Monday January 21, 2013 @03:51PM (#5093691)

    if ((flag & FLAG_VALUE) == TRUE) ...
That would still check if flag is 1, right?
Re:Worst Bug Ever by azth on Monday January 21, 2013 @04:04PM (#5093754)
That is correct.
Re:Worst Bug Ever by mpyne on Monday January 21, 2013 @09:23PM (#5095147)
Indeed, great catch (this is why I use things like QFlags now, as it has a simple "testFlag" method)
Re:Worst Bug Ever by to3m on Monday January 21, 2013 @04:43PM (#5093905)
flag&FLAG_VALUE will be FLAG_VALUE or 0, so unless FLAG_VALUE==TRUE the answer could be wrong.

Suggest (flag&FLAG_VALUE), or, if you need the expression to be of type bool, ((flag&FLAG_VALUE)!=0) or (!!(flag&FLAG_VALUE)).

Re:Worst Bug Ever by mpyne on Monday January 21, 2013 @09:24PM (#5095151)
Very true, I just checked to see if I can edit but I can't, so mea culpa.
Re:Worst Bug Ever by ja27 on Monday January 21, 2013 @09:58PM (#5095262)
Boolean true / TRUE wasn't defined in any standard way before C99. Back in the "olden days", most programmers #defined it as 1, but not always. I ran into one of those "not always" cases in some inherited code.
Re:Worst Bug Ever by anonymouz on Monday January 21, 2013 @04:59PM (#5093982)
I'm curious about the test one. Do you have "." in your PATH? Or do students simply not realize that they should call their program as ./test anyway?
Re:Worst Bug Ever by ja27 on Monday January 21, 2013 @10:01PM (#5095274)
Student accounts had "." in their PATH by default. I'm sure someone did it to keep students from asking why their program wouldn't run at all. Fun times.
Re:Worst Bug Ever by bch on Monday January 21, 2013 @12:21PM (#5092426)
I had this with Perl, using $a or $b for a throw-away script, but Perl uses these internally for sorting. Didn't take -too- long to sort it out, but certainly broke my flow.
Re:Worst Bug Ever by jey on Monday January 21, 2013 @04:13PM (#5093788)

    using $a or $b for a throw-away script, but Perl uses these internally for sorting
Everything I learn about Perl just makes me hate it more. But a lot of people seem to love it -- it must have some redeeming qualities, right?
Re:Worst Bug Ever by draegtun on Tuesday January 22, 2013 @06:27AM (#5096580)
There is nothing to be afraid of here, sort just makes use of localised $a & $b package variable names as references to the sort block:

    our $a = 100;   # using $a package variable

    # then later do a sort on @list
    my @sorted = sort { $a cmp $b } @list;

    # @sorted worked correctly, $a = 100 had no effect on it
    # and $a is still 100
And if we change our to my (so lexical variable) then script will fail to compile giving the fatal error: Can't use "my $a" in sort comparison at...

For more information on sort see: http://perldoc.perl.org/functions/sort.html

PS. The OP problem may have been due to issue/bug in older version of Perl. Also using use strict; use warnings do help highlight issues with code.

Re:Worst Bug Ever by bch on Saturday January 26, 2013 @03:06PM (#5121569)
Indeed.

First 3 lines of all perl code for me are:

  #!/usr/bin/env perl
  use strict;
  use warnings;
Re:Worst Bug Ever by kamaal on Tuesday January 22, 2013 @12:08AM (#5095641)
Everything I learn about the world makes me hate it more. But a lot of people seem to love it --it must have some redeeming qualities, right?

Answer: Yes, depends on where in the world you live.

Re:Worst Bug Ever by Achshar on Monday January 21, 2013 @12:26PM (#5092460)
Are you saying changing the value of a variable in excel changes system time? Isn't that a little... nevermind. What about the privileges required to change time? Did it bypass them or it only worked for admins?
Re:Worst Bug Ever by StavrosK on Monday January 21, 2013 @12:55PM (#5092671)
What privileges? It was Windows in the 90s.
Re:Worst Bug Ever by Achshar on Tuesday January 22, 2013 @05:37AM (#5096467)
Oops, missed that part.
Re:Worst Bug Ever by StavrosK on Tuesday January 22, 2013 @05:40AM (#5096478)
Yes, it was the excellent security model of "let's not bother with security models".
Re:Worst Bug Ever by niggler on Monday January 21, 2013 @12:27PM (#5092471)
Time is a reserved keyword according to MS-VBAL. My guess is that excel itself didn't follow their standard ...