[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/prog/ - Programming

Programming board

Catalog

See 8chan's new software in development (discuss) (help out)
Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 1 per post.


File: 1445968875001.jpg (28.57 KB, 600x338, 300:169, xtoanhero.jpg)

09b70f No.3484

Tell me, /prog/, what were the nastiest bugs you ran into?

Mine was when I coded a multithreaded Java project for university. In our group was a girl which we considered incompetent and so we only gave her lowest-tier tasks where no sentinent being should be able to cause any harm. Stuff like putting the debug output calls in comments for the final version.

The result looked like this:


void runThreads() {
while(!done) {
iteration++;

if (iteration%10000 == 0)
//Debug.out("Iteration: " + iteration + ", State: " + state.toString());

/* I'm a huge comment explaining
what the critical section does*/

syncThreads();
doCriticalStuff();
}
};

Needless to say, our debug version sometimes had incorrect output due a data race resulting from the missing synchronization. The really annoying part was that this was part of the proven, extensively tested and seemingly unchanged core program and merged alongside with a large update to peripheral functions, so we spent several days testing the graphing, output, and other stuff before finding where the problem was. And then there was a huge comment in the middle which made it easy to overlook the if-statement when looking at the seemingly important parts.

455572 No.3492

Nastiest bug I've ever seen? Probably the "Openoffice doesn't print on Tuesdays" bug:

https://bugs.launchpad.net/ubuntu/+source/file/+bug/248619

Nastiest bug I've ever created myself? A memory leak in a HQ9+ interpreter I wrote in Haskell:

inc :: StateT Integer (ReaderT FilePath IO) ()
inc = modify (+1)

Since the accumulator in HQ9+ is never accessed, only incremented, every call to inc creates a thunk that never gets resolved, instead of simply incrementing the accumulator. Multiple calls to inc create a huge thunk stack.

If I print out the accumulator in order to debug the program, the memory leak vanishes.

Adding a bang pattern fixes it:

inc = get >>= (\ !s -> put (s+1))


e48e42 No.3493

>>3492

How did you even find that bug? Haskell doesnt have the best debugging tools for shit like this.


455572 No.3494

>>3493

Since an HQ9+ interpreter is so small in scale, I just fed in a bunch of different input files until I found out that the + instructions (which resulted in calls to inc) caused the memory leaks. The rest of it came down to figuring out why the inc function was a memory leak and how to fix it.




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]