DEV Community

Cover image for What was the weirdest bug you ever encountered?
Andreas
Andreas

Posted on

What was the weirdest bug you ever encountered?

As developers we find and troubleshoot bugs everyday. What was the strangest bug you've ever stumbled upon?

Bug saying Hello

Top comments (39)

Collapse
 
dwd profile image
Dave Cridland

Personally, the weirdest and hardest to solve bugs for me are when the C++ optimizer takes a shortcut that ends up ignoring my code. These are usually cases where, for example, a pointer cannot be NULL according to the standard and therefore my NULL check is ignored.

I know of two other bugs which are gloriously Byzantine. I don't know Trey Harris, but his bug is legendary: The 500 Mile Email

I do know (and used to work for) Dave Baggett, and have heard this story first-hand. My Hardest Bug Ever

Collapse
 
metalmikester profile image
Michel Renaud

Those optimizers can be sneaky. I don't know how long you've been doing this, but I remember when the first C and C++ optimizing compilers for PC came out (late '80s, roughly) that they did a lot of nasty things and you had to be very careful with what optimizations you picked. Let's just say it was a rocky start.

I was on a project with some C++ just three years ago and it's a good thing my supervisor was borderline genius because he caught VC++ doing some really strange things. The ways he figured it out was beyond the skills of pretty much everyone else I know.

Collapse
 
dwd profile image
Dave Cridland

I've been using C/C++ since around 1990 or so. The old problems were usually weird compiler bugs when optimizations went wrong dramatically, from what I can recall. But I was thinking more of cases like this, which tripped me up recently - I'll simplify, of course:

int * p = nullptr; // Start with a NULL pointer.
int & r = *p; // Later on, convert to a reference, probably in a function call.
int * i = &r; // Convert the reference back to a pointer.
if (i != nullptr) { // If it's not NULL
  std::cout << "i is now " << *i << std::endl; // Print it.
}

That code crashes with a segfault trying to deference a NULL pointer. This is because the standard says that if the address of a reference is the NULL pointer, it's Undefined Behaviour. So most modern compilers now choose to optimize away the test, even without optimization turned on...

Thread Thread
 
metalmikester profile image
Michel Renaud

"Undefined behaviour" is hell.

Collapse
 
devmount profile image
Andreas

Thank you so much for sharing! The 500 mile email is indeed legendary! 😂

Collapse
 
_darrenburns profile image
Darren Burns • Edited

That time I snoozed my iPhone alarm and instead of ringing again when it hit 0, it continued to count down past zero into the negatives. It's happened about 4 times now.

snooze counting past zero

Collapse
 
metalmikester profile image
Michel Renaud

Snoozing for 44 minutes? Get up! lol

Collapse
 
devmount profile image
Andreas

Awesome 😂 I'm wondering how long it would go on this way 😅

Collapse
 
markfreedman profile image
Mark Freedman

That's the new time travel feature. Apple is ahead of their time... um... literally :)

Collapse
 
devmount profile image
Andreas

Hearing a crackling noise in my headphones when touching the fingerprint sensor on my Android phone.

Collapse
 
jvr0x profile image
Javier ⚛️

Lol that was weird

Collapse
 
devmount profile image
Andreas

Indeed it is! And it is reproducible. The sensor must somehow produce an electrical charge that's affecting the jack connection 😅

Collapse
 
sergix profile image
Peyton McGinnis

I get this in my PC a lot. I'm pretty sure the reason is that unless you have a dedicated sound card a lot of motherboard noise is likely to pass through the audio jack.

Collapse
 
paceaux profile image
Paceaux • Edited

The Stacking Context in CSS. More specifically, that there are a few CSS properties that can trigger a stacking context. And even more specific, that particular properties, in particular browsers, will give you very different results within that stacking context.

It'd started with a simple request to remove a double-scroll bar that was displaying in certain browsers. Over the course of a month I reviewed every CSS property on every element until I discovered that we'd unintentionally created a new stacking context, and that CSS we'd written accidentally handled that very well... until it didn't.

I ended up editing the mozilla developer network page on stacking contexts, and producing the most boring codepen ever that illustrates exactly how certain CSS properties totally bork stacking contexts.

took a month to discover that no one on the internet had, until then, documented that perspective would change the behavior of position:absolute. That double scroll bar was the hardest bug I ever tackled, but is also one of my proudest moments.

Collapse
 
gjeloshajantoine profile image
GjeloshajAntoine

I've never heard of stacking context in css!
What is it?

Collapse
 
paceaux profile image
Paceaux • Edited

The stacking context is the ... well "context" in which the browser determines how to layer things. We hardly ever think about stacking context and it hardly ever matters.

But stacking context is about paint order ; when the browser has elements that overlap, the browser has to know which element to draw first, and which to draw next.

contrary to popular belief, z-index hasn't anything to do with positioning but with painting. When we have overlapping elements, and the browser is painting them in an order that we don't want, we use z-index to change the order in which the browser draws them.

So, that means that "the order in which the browser draws them" has to be determined some how. So what the browser does is find "root contexts" to determine which elements need to have their drawing order sorted out. Think of these "root contexts" as buckets with sheets of paper.

The bucket is any element with position:fixed, absolute, perspective, transform, etc. When the browser encounters those, it says, "aha! I need to make a bucket with this, and then figure out the order in which to paint things". That's your stacking context.

You can live a happy and fruitful career never having to think about this.

But occasionally you will discover that the browser sometimes has some strange rules about how it creates stacking contexts. Sometimes the browser has to change the rules of the bucket just to figure out how to paint those sheets of paper.

A great example of this might be an element that's position:fixed, with a parent container that has opacity: .2.

That position:fixed child element is _supposed to be` wherever you intend it to be, relative to the browser window.

But you see, it's inside of an opaque parent.

The browser is supposed to show just a little bit of the element underneath that parent, because the parent is opaque. That means the grandparent is supposed to influence the look of the grandchild.
But how can it do that if the grandchild is position:fixed and nowhere underneath this opaque parent? So the browser makes a decision:

I will create a "Positioning context" that matches the stacking context.

So what happens is position:fixed breaks . It's no longer relative to the window, it's relative to that parent that has opacity: .2.

Again, you can live a fruitful live never knowing about the Stacking Context because it mostly never matters. But there will be rare times where the browser can't reconcile these CSS properties where layering matters with other CSS properties where positioning matters, and it creates a new "positioning context" that matches the stacking context.

Collapse
 
devmount profile image
Andreas

In short: positioning and z-index. Paceaux provided a link with a detailed explanation. Here is an example:

stacking context example

Collapse
 
gsto profile image
Glenn Stovall

I used to work on an application that colleges used to process certain types of applications. College could create their own forms. When the user was done, it would compile the answers into a PDF and mailed out to relevant people.

For one client, the PDF would come in empty, but only 10-20% of the time. We couldn't figure out why.

I spent three days tracking down a bug in legacy code that ended up being a bug in PHP itself. . Our system did a lot of parsing of the data to move in between different formats. When you did a Regex find/replace, the method should return the updated string. If there were no matches, it should have returned the original string.

BUT

If you passed in a string over a certain length, and there were no matches, it would return null instead. This one client ask a lot of essay questions. The script would only fail for the most verbose students.

We couldn't patch PHP, so we wrote some checks to strip useless markup and keep strings under the limit.

Collapse
 
sergix profile image
Peyton McGinnis

Good gracious. I've had to deal with similar bugs in APIs that have string limits as well, always very annoying to deal with. But never anything that strange.

Collapse
 
hammzj profile image
Zach Hamm

My favorite bug has to do with not software, not coding, but my last desktop build. Four hours later after two trips back to MicroCenter that day already, I had it "done" and booted it up, and got to install Windows. Another few minutes after getting things installed on my Windows profile, it blue screens. So, I do start it up again, and lo and behold, another blue screen. And I think even some memory dump, too.

The reason?

It overheated.

Because I forgot to buy a heatsink. And put it on a supercharged 4.2Ghz i7.

I literally nearly burned $2000 from heat in the first day I had created that monster.

Collapse
 
lbeul profile image
Louis • Edited

Everytime I inserted headphones into my Huawei's headphone jack, Google Assistant was activated. I guess that there are some accessibility devices for disabled people that work through the headphone jack's connectors. Because there was some dust in my headphone jack, the connectors got either short-circuited or triggered in a wrong way, idk. After I cleaned the port and removed the dust, everything worked well again.

Collapse
 
osde8info profile image
Clive Da

only posted it last week ! the windows 10 add new user popup in 20x10 pixels

Collapse
 
devmount profile image
Andreas

Well that's... small 😂 Screenshot?

Collapse
 
osde8info profile image
Clive Da
Collapse
 
osde8info profile image
Clive Da

yes it wasnt funny until i found the workaround

Collapse
 
osde8info profile image
Clive Da

on the bus now you can search for my post with screenshots or wait until im on the wifi in the pub

Collapse
 
nlxdodge profile image
NLxDoDge

I had a lot of bugs in my 6 years of programming, but the one I will always remember is a Database Connector file being called PG for Postgress, bu actualy being a MySQL driver renamed to PG.

Why? No clue but I reinstalled everything but the driver was in my project folder, hens it not working correctly. Took me a week to find it.

Madness.

Collapse
 
jrop profile image
Jonathan Apodaca

Encounter strange bug: git reset --hard, retype the exact same code, and it works. :shrug:

Collapse
 
alex_chisholm profile image
Alex Chisholm

Hearing the frequency of static in my headphones increase and decrease as I moved my cursor from top left to bottom right of my screen

Collapse
 
hammzj profile image
Zach Hamm

This got a good laugh out of me for just the idea of doing sweeps with your mouse

Collapse
 
devmount profile image
Andreas

😂 And that's how to shorten battery life effectively.

Collapse
 
fultonbrowne profile image
Fulton Browne • Edited

Today I had a github bot go wrong and my all my Ci's ran 800 (not Kidding) times they all failed and ended up in my inbox.

Collapse
 
devmount profile image
Andreas

🤖😜 Someday the bots will take over 😅

Collapse
 
sebbdk profile image
Sebastian Vargr

IE6, just take your pick.

I also had problems with my sausage face generator not having enough contrast.
Or there was the time i just could not program pee to hit a cup.

My early career was odd.

Collapse
 
madza profile image
Madza

Too many to count.
Reason: github.com/denysdovhan/wtfjs

Much love, JS dev :)