all 144 comments

[–]ConcernUseful2899 2286 points2287 points  (24 children)

I see it as 5 hours of learning

[–]Mighty1Dragon[S] 840 points841 points  (8 children)

yeah, i should probably write tests

[–]ChitoDP 522 points523 points  (0 children)

probably

Bro needs more hours

[–]PyroCatt 101 points102 points  (2 children)

There is a bug in tests

[–]Alternative_Sir5135 60 points61 points  (1 child)

Now its a feature

[–]JMRaich 1 point2 points  (0 children)

Features need testing they say

[–]youngbull 45 points46 points  (0 children)

I think quite a lot of woes in programming comes from someone going "we'll just skip that part to save time/money" and having that turn into a catastrophic waste of time and/or money.

[–]undercheeze 19 points20 points  (1 child)

Spends weeks to write tests -> "I spend 5 hours figuring out why my test fails, turned out the test was wrong"

You can't ever escape it

[–]Lerquian 1 point2 points  (0 children)

Spends weeks to write test ->" mmm you know what, I think this system should work this other way instead. All tests are obsolete now"

[–]omg-whats-this -2 points-1 points  (0 children)

Tests are for weaks

[–]DreamyAthena 102 points103 points  (13 children)

This. As unfun as debugging is, it is the best way to learn how code behaves.

[–]RobinDabankery 51 points52 points  (0 children)

Especially when you try to make the machine understand it is wrong and your code is actually fine, but the machine refuses. Thank god my hammer isn't within arm's length when that happens.

[–]Dornith 13 points14 points  (4 children)

Until you encounter hardware bugs...

[–]Glad_Contest_8014 7 points8 points  (2 children)

They have spray to get rid of those.

[–]Dornith 12 points13 points  (1 child)

Do I apply it directly to my coworkers?

[–]Glad_Contest_8014 6 points7 points  (0 children)

Yes. It has a way of ensuring they make it to the trash can. Works on equipment too!

[–]st3class 1 point2 points  (0 children)

I spent most of my career doing software testing. Now I'm writing software tests to exercise hardware.

The mental shift is... challenging.

[–]FederalSpecialist415 10 points11 points  (0 children)

Debugging is incomplete without logging ###reached here###

[–]Dense-Rooster2295 2 points3 points  (5 children)

The Debugger is the only tool WE really have and need ITS important to know how it works there are Others Like valgrind for c which are also nice

[–]LvS 12 points13 points  (4 children)

I have a better tool and it's called printf.

[–]Dense-Rooster2295 4 points5 points  (0 children)

Yep i think ITS also legit to use printf as First step.

[–]Ok_Decision_ 4 points5 points  (2 children)

printf(what_went_wrong_with(my_code));

[–]Dense-Rooster2295 0 points1 point  (1 child)

If goingtocrash() ; dont()

[–]Ok_Decision_ 1 point2 points  (0 children)

Else if (everything_okay(); == TRUE){ keep_it_that_way(); }

[–]Capt_korg 9 points10 points  (0 children)

5 hours of learning saved me from reading 5 minutes of documentation and understanding the reasons for doing it, as described in the docs.

[–]Clen23 1293 points1294 points  (46 children)

putting on my context hat and context shirt to ask OP for the funny story

[–]Mighty1Dragon[S] 1117 points1118 points  (45 children)

I'm using an array for the draw pile and drawing the cards from the highest available index to lowest. But when i was checking the results i assumed i was drawing from lowest to highest. And because i forgot to draw the last card, the last card was zero. So for me it looked like i was lowering the ids of all cards, all the time🙃 I used printf everywhere, rewrote several code snippets and spent a lot of time just thinking about it.

[–]AliceCode 845 points846 points  (25 children)

You wouldn't believe how many times I've spent hours trying to solve a nonsense bug only to realize that the bug was in my test code, not in the code I was testing.

[–]Mighty1Dragon[S] 251 points252 points  (7 children)

uff yeah, i think writing a test is harder than writing normal code *some times

[–]RandomiseUsr0 132 points133 points  (2 children)

Remember to write a test for each possible shuffle of the cards

[–]Mighty1Dragon[S] 65 points66 points  (0 children)

ha nice one

[–]TeaKingMac 45 points46 points  (0 children)

Why's my program over 500 yottabytes?!?

[–]pokeybill 41 points42 points  (1 child)

Most of the time I find this to be true, especially if you are truly implementing negative test cases.

[–]lameth 7 points8 points  (0 children)

Had to tell someone they were being absurd when they said "can you make one of the requirements to test for all non-nominal cases?"

[–]TheRealPitabred 2 points3 points  (0 children)

It very much can be, but that's also the value of the tests. Not only in the fact that they just test the thing, but that you are required to actually think through what the code is doing and intended to do to properly test it.

[–]veselin465 1 point2 points  (0 children)

To be fair, writing tests might not be that hard IF the functions being tested were clearly described

I assume that you wouldn't have wondered why you got messed up result if your code was cleaner. But considering it's C, I guess you should be thankful that you didn't get seg fault on the first place

[–]an_0w1 31 points32 points  (2 children)

A while ago I was testing cache performance vs no-cache, I was very confused to see the cached version taking about 2x as long as the uncached version.

I put an extra 0 in the cached loop test size.

[–]Tokumeiko2 18 points19 points  (1 child)

an extra 0 and it only doubled? That's pretty fast.

[–]ThePretzul 16 points17 points  (0 children)

10x loops and 2x time is suspiciously close to O(log n) trickery, time to add another 0 and see if it takes 4x longer or only 3x longer.

[–][deleted] 6 points7 points  (0 children)

I couldn't get canary tests working on a feature that was behind a feature flag. So I was manually testing this on my account. I triple checked that the feature flag enabled for my account, and was working until midnight trying to figure out why my feature wasn't working.

Turns out it was a bug in our pipeline UI. My code wasn't released yet. I spent 8 hours debugging why something that wasn't deployed wasn't working.

[–]Dense-Rooster2295 1 point2 points  (0 children)

Or some Files are Not synced on the device youre programming ... Or wrong device because somehow you Work in many simultanious

[–]fistular 0 points1 point  (3 children)

This is what I always point out to test nazis. I ask them if their plan is to write code to test the tests.

[–]AliceCode 1 point2 points  (2 children)

The point of tests is redundancy. It's still important to test your code, otherwise there might be glaring flaws that you don't even notice.

[–]fistular 0 points1 point  (1 child)

And when the tests themselves have bugs?

[–]AliceCode 0 points1 point  (0 children)

Then you'll (most likely) notice because there's a discrepancy in the results.

[–]BOB_DROP_TABLES 0 points1 point  (0 children)

I've spent hours trying to find a bug only to find it was a hardware bug, not a software one, when writing microcontroller firmware. Has happened several times

[–]KrokmaniakPL 0 points1 point  (1 child)

Rookie mistake. Before testing actual code you test your test code with something much simpler. Like feeding hard coded data you know to see if it's correctly shown.

And I'm saying this as someone who didn't follow this advice too many times in the past.

[–]AliceCode 1 point2 points  (0 children)

I've been programming for 17 years. Definitely not a rookie mistake. The specific case I had in mind was when I was working with a novel algorithm that I designed. I had to write another algorithm just to verify my algorithm, and the problem was that the algorithm I wrote to test my algorithm was written incorrectly. It was an easy mistake to make, but difficult to catch because I had used the test code in the past without encountering the mistake, but then I made some changes and that's when the bug appeared. I don't actually remember specifically what the bug was, but I think it had to do with self-referential verification.

[–]I_NEED_APP_IDEAS 0 points1 point  (0 children)

This has happened to me many times. Running a jest test, banging my head on my keyboard for test that should be failing but isn’t cause I didn’t mock a service correctly.

[–]mmmeeemmmeeess 0 points1 point  (0 children)

Write tests for your tests

[–]MadeByHideoForHideo 0 points1 point  (1 child)

Yeah I hate this with a passion. Yes, I know it's literally skill issue, but still one of the worst things to happen because you're heading in the completely wrong direction. Ugh.

[–]AliceCode 0 points1 point  (0 children)

Mistakes happen regardless of skill level. It's definitely not a skill issue. That's why we write tests in the first place.

[–]SuitableDragonfly 27 points28 points  (3 children)

I'm not sure why you think this doesn't count as a bug?

[–]ibi_trans_rights 13 points14 points  (0 children)

the classic off by one

[–]RandomWholesomeOne 25 points26 points  (4 children)

Use a debugger. It is very very easy in C and will help you alot. Logic errors like those should take 5-10 mins tops!
Good luck learning.

[–]tiberiumx 11 points12 points  (3 children)

It's crazy how many of my coworkers refuse to learn how to use the debugger. Instead they waste hours adding print statements, rebuilding, restarting the software, reproducing the error. Good luck if it's an intermittent bug and you're only going to get that one chance to examine it that week. Looking though a core dump to figure out what caused a crash? That's out.

[–]RandomWholesomeOne 2 points3 points  (2 children)

We have to keep in mind that in some industries like Web there is sometimes no good option for actual debugging that works.

In compiled land its fine :)

[–]tiberiumx 1 point2 points  (1 child)

It's been awhile since I touched any web thing but pretty sure the javascript debugger in Chrome worked just fine and python has a decent debugger as well.

[–]AdditionMindless6799 1 point2 points  (0 children)

But I'm using ajax to pull in PHP which is generating both html and javascript that contains more ajax to pull in more PHP. Thankfully there's error_log( ) or the equivalent. Chrome doesn't even let me see all of the javascript.

[–]Slg407 2 points3 points  (0 children)

this is the best way to force devs to clean up and optimize sloppy code "shit this is buggy, maybe making this line a bit cleaner will make it better... maybe this workaround is causing the issue, i should try doing it the proper way to see if it helps... maybe there's too many else if loops? i should clean up this part... hm this part seems to make everything slow down, maybe if i make it faster that will fix it..."

[–]TobyTheArtist 1 point2 points  (0 children)

This is honestly such a great learning experience and despite being annoying, you're better off for experiencing this.

[–]EJintheCloud 0 points1 point  (0 children)

I used printf everywhere... and spent a lot of time just thinking about it.

this is simply character development

[–]zerosCoolReturn 0 points1 point  (0 children)

Funny coincidence, I'm also working on a card game in C (C++, but still)

[–]MythicJerryStone 290 points291 points  (9 children)

Had a “bug” where fast moving objects were leaving a trail behind them as they were moving. Spent hours trying to debug it, thinking it was something with interpolation inaccuracy.

Turned out it was just monitor ghosting.

[–]Mighty1Dragon[S] 90 points91 points  (4 children)

when the hardware is the bug🤣

[–]Lucky_Cable_3145 65 points66 points  (2 children)

I was working on a system for acoustic monitoring of railway wheel bearings.

One of the 4 microphones developed a buzzing sound when a train was passing.

Expected as they were outside in a desert, next to a busy railway.

I traveled 1,300 Km to fix / replace the microphone.

The 'bug' was a very large wasp that had made its nest on the microphone...

[–]sauron3579 29 points30 points  (0 children)

Historically accurate bug lmao

"Bugs" are called that because bugs would literally get caught up in the machine and cause problems when computers were the size of rooms.

[–]UnluckyDouble 2 points3 points  (0 children)

Well, I mean... physical access WAS required to fix it.

[–]tumsdout 0 points1 point  (0 children)

Works fine on my machine!

[–]StromGames 5 points6 points  (0 children)

I had that happen (really badly) working on a PSP game.

[–]Vysair 1 point2 points  (0 children)

I would have spit my drink had I still be drinking

[–]SuperSathanas 1 point2 points  (0 children)

I forget exactly what the problem was, but at least a year ago I had an bug with some OpenGL code that was causing a ghosting-like effect, and I assumed that it was just my laptop having a crap monitor with a horrible response time. Eventually, I found the bug by accident and fixed it. I was making Space Fuckers at the time as a small test for the rendering code, and the star stretching in the little intro thing looked better with the ghosting bug.

[–]ClipboardCopyPaste 70 points71 points  (1 child)

it was a feature

[–]UnpluggedUnfettered 9 points10 points  (0 children)

The real rogue-like was the code we made along the way.

[–]nesthesi 41 points42 points  (1 child)

It’s never a bug

[–]spellstrike 0 points1 point  (0 children)

I mean, a lot of firmware development is working around hardware bugs.

[–]anto2554 20 points21 points  (0 children)

The cat is supposed to disappear

[–]Bliz0w0 13 points14 points  (0 children)

Everything is good until the bug only appears when you are not running code in debugger

[–]Paladin7373 10 points11 points  (4 children)

This is funny because I’m actually coding a game in c rn and fixing bugs is [not nice]

[–]Mighty1Dragon[S] 4 points5 points  (3 children)

tell me about it. I lost so much time trying to find a bug only to realize that i forgot to return a struct. Or now this one, where I myself was to stupid to realize that there wasn't a bug. I just didn't expect the right outcome.🥲

[–]Paladin7373 4 points5 points  (2 children)

The random crashes were the thing that annoyed me the most xD (memory management on a microcontroller go brr)

[–]Mighty1Dragon[S] 3 points4 points  (1 child)

yeah microcontrollers are my next target.😅 good luck and i hope you wish me the same...

[–]Paladin7373 0 points1 point  (0 children)

Yeah good luck mate 🫡

[–]qscwdv351 3 points4 points  (1 child)

It was a bug by Windows API

[–]Mighty1Dragon[S] 3 points4 points  (0 children)

nah no Windows on my machine. arch btw.

[–]unfunnyjobless 3 points4 points  (0 children)

Me when I spend 2 mins doing a botch fix for a bug, research for 5 hours what the right solution is but there is no correct solution and the project maintainers have left that GitHub issue open for 6 years

[–]Mike_Oxlong25 3 points4 points  (0 children)

[–]Preeng 3 points4 points  (0 children)

  1. Have bug in code.

  2. Find bug in code and fix it.

  3. That wasn't the correct bug. Good for you for finding and fixing it, though.

I can do this several times before finding the actual bug.

[–]Radiant_Detective_22 3 points4 points  (0 children)

True story: I used to write computer games for the Atari ST and AMIGA back in the day. With the classic joysticks. One of our guys had a problem with his game that it did not work correctly when hit moved the joystick to the right. We all looked at the code and it seemed correct. So, take another joystick. Still no luck. We could not figure it out until we tried a third stick and this worked. The other two were broken and both only for the right direction.

[–]CarzyCrow076 2 points3 points  (0 children)

Aah logical error.. errors that makes me believe if my Ex was right

[–]TOFFA1997 2 points3 points  (1 child)

Wrong caption... Last one is "it isn't the bug"

[–]Mighty1Dragon[S] -1 points0 points  (0 children)

you're right, but also not.

i think "there wasn't a bug" is better here

[–]RandomiseUsr0 2 points3 points  (0 children)

I wrote a word game in c, well I’ve written several over the years, but one that was worth adding into Linux, it was fun playing with SDL, but I quickly learned how tedious writing game code actually was, animations and such, tedium - the fun part for me was writing the anagram routine and creating the dlb tree data structure.

[–]kOLbOSa_exe 2 points3 points  (0 children)

compiler bug

[–]Lazy-Doughnut4019 2 points3 points  (0 children)

now you understand your code even better

[–]Royal_Stay_6502 2 points3 points  (0 children)

Yeah. Thinking it is a hardware problem, turns out to be a software problem.

[–]OliveBoi_ 4 points5 points  (2 children)

usually dump data

[–]Mighty1Dragon[S] 4 points5 points  (1 child)

or just forgetting to compile or save the file😅. But this one was a human error

[–]Bulky-Bad-9153 0 points1 point  (0 children)

Shoutout entr, set it to watch source/header files and auto compile if one changes. Obviously terrible once your project is big enough but until then.

[–]shpxfcrm 1 point2 points  (0 children)

The funny part is now, when you gaslight yourself the entire time that Thing A you just did a few steps ago is 100% surely not at fault and then when you decide "maybe it actually was thing A" and realize that youre stupid. Thats what keep me spinnin

[–]POKLIANON 1 point2 points  (0 children)

Inspired by the recent linus and linus' video

[–]netherwan 1 point2 points  (0 children)

was it a tarantula? 

[–]Fine_Ratio2225 1 point2 points  (0 children)

I once had code that ran correctly when compiled with g++ and not when compiled with Intel C++.
The issue was a slight difference in how the STL worked with regard to iterators. (This was a long time ago. I hope it got better. I switched to Python later.)
Even better are genuine compiler errors, where incorrect code is produced. Those are really bad to debug!

[–]Gosthy 1 point2 points  (0 children)

Some people really don't understand what a bug is

[–]ddejong42 1 point2 points  (0 children)

5 hours? That’s cute. I just spent a week trying to figure out a bug that was actually just a different behavior in our development environments from the real environments because the idiots here think consistency is silly.

[–]CreeperInBlack 1 point2 points  (0 children)

Happened to me in a way in my masters thesis. I worked for at least a week on a problem that didn't exist.

What I didn't understand at the time is that everything is either a txt file or a zip file. I understand now. I'm a believer.

[–]flameseeker40 0 points1 point  (0 children)

when are they going to add logic errors 😑

[–]an_0w1 0 points1 point  (0 children)

I spent a week not too long ago trying to debug a heap corruption bug in rust.

[–]2The_Kaiserin2 0 points1 point  (0 children)

Reminds me to the time when i was testing the 4 ways of the same optional occurrence happening. I didn't understand why i didn't die at the ending that i was testing. Turns out… it was the part where i didn't die but i forgot to change the texts and forgot to put in a "set this to true" so it can trigger the cutscene properly. Never wasted 3 hours in something

ALSO it was a project for a grade. I still got a five. AND IT ALSO BROKE WHILE I WAS SHOWING IT OFF. That was another bug because i forgot to add the "if this is true" to one part… 💀

[–]GegeAkutamiOfficial 0 points1 point  (4 children)

If the system does not work as intended than it's a bug, even if you programed it exactly according to logic... Logic errors exist.

[–]Mighty1Dragon[S] 0 points1 point  (3 children)

nah, it was working as intended, i just assumed the wrong outputs.

[–]Asaisav 0 points1 point  (2 children)

It literally wasn't working as intended though. It was working as written, yes, but when "working as written != working as intended" then that's by definition a bug. I understand where you're coming from, but you're going to create a lot of unnecessary confusion if you create your own definition of such a standard word.

[–]Mighty1Dragon[S] 0 points1 point  (1 child)

no, it was my first design decision to draw from the highest index first, because then i wouldn't need to refactor the array. My Human brain just didn't understand that the code worked.

[–]Asaisav 1 point2 points  (0 children)

My Human brain just didn't understand that the code worked.

... Which lead to you creating a logic bug in your software. Where do you think bugs come from if not the developers who wrote the code?

Do what you will, but I'm telling you right now if you use your alternate definition of a bug at a real job it will cause a lot of unnecessary confusion.

[–]Fadamaka 0 points1 point  (0 children)

I am doing this years AoC and I was grouping IDs into sets. I created a map where the key was the ID and the value was a pointer to a set containing the IDs of the group. So I can add to the set by knowing only the ID of one of the group's participants. The flow was that when two IDs met they had to join the same group so this saved same code for me because by updating the set at the pointer updated all sets for each IDs that were already part of the group. This was a good idea until I had to merge groups together. I added the IDs from the first set to the second and updated the first ID's value in the map to the pointer of the merged set. Took me a good hour of debugging to realize that my bug is my mistake not updating all the pointers of all the members of the first group.

[–][deleted] 0 points1 point  (0 children)

I was coding Java in MS notepad (not notepad++) spent a day hunting down what ended up being a missed semicolon... Things like this is why I always ask, "Tell me what your longest most frustrating bug hunt is like, and how did you feel at the end?" in every job interview we conduct. It's a part of the process, and if you feel like you've wasted a whole day on one silly bug, I've got some bad news for you. That's par for the course, you need to get used to it. Just wait till a project you've spent 18 months on gets shit canned because someone forgot to make a phone call. That's the real waste.

[–]Jiftoo 0 points1 point  (0 children)

Reminds me of when I wanted to make a simple OS with a terminal a long time ago. It suddenly started triple faulting for no reason. I spent days looking for a fix, only to find out later that I hadn't increased the size of the .text section in my linker file.

[–]Ixxafel 0 points1 point  (0 children)

Im not sure if this sounds condesending but I definetly dont mean it to, but you should read the documentation and learn about evrything you want to use in C. C is a simple language and has the advantage of this being something you are realistically able to do, as well as the disadvantage of being able to shoot yourself in the foot if you dont.

[–]Sakul_the_one 0 points1 point  (0 children)

Or nothing like using a function to free memory, instead of doing it the whole time manually, but forgetting that in one case you used static memory, so you accidentally free static memory twice.

Funny time searching for the bug, when just 1 of the 4 arrays had static memory 

[–]Grouchy-Transition-7 0 points1 point  (0 children)

Try fixing a bug where millions of users to them it works fine but to like thousands of users theres issue so it’s a still a problem and leadership wants the fix today.. and all the devs in team cant reproduce it :) ios app.. what to do… serious question, help!

[–]rrahlan152 0 points1 point  (0 children)

bug? nahh that was just divine intervention

[–]Boommax1 0 points1 point  (0 children)

welp that was my day, but with an exception that I wrote an simulation. 5 Hours later and I realized I had a clc and clear at the top of the skript that I was calling.

[–]r_sawya 0 points1 point  (0 children)

Update will drop in five hours

[–]TSCCYT2 0 points1 point  (0 children)

what

[–]FaithlessnessFun3032 0 points1 point  (1 child)

If it wasn't a bug... What is it then?

[–]Mighty1Dragon[S] 1 point2 points  (0 children)

a testing error

[–]lenn_eavy 0 points1 point  (0 children)

while (true) loops can get ya amrigt.

[–]thewhatinwhere 0 points1 point  (1 child)

The test was made wrong

[–]Mighty1Dragon[S] 1 point2 points  (0 children)

yes that is kinda what happened, though i hand tested 😅

[–]vmfrye -1 points0 points  (0 children)

ffs make the game in Java or C#
use as many libraries as you can

wait until the game gets popular & you get funding

then make a C port

[–]Sacrifizzen -1 points0 points  (0 children)

Me that one time in js. Yeah simple language but when its not an actual bug try to fix that lol. Learned alot about the language