Skip to main content

The Null Pointer Nightmare: How a Simple Mistake Can Halt The World

A global IT outage, described as “the largest IT outage in history” by Microsoft Regional Director Troy Hunt, occurred on July 19, 2024, affecting millions of Windows-based systems worldwide.

Imagine you’re driving on a highway, and suddenly, your GPS starts pointing to a nonexistent road. You keep driving, and before you know it, you're in a ditch because there was no road where your GPS pointed. Something similar happened with a recent CrowdStrike outage, but instead of a car, it involved lines of code, and instead of a ditch, it resulted in a system crash also called Blue screen of Death (BSOD).

Let’s dive into what happened, why it happened, and how we can avoid such nightmares in the future.

The Culprit: A Null Pointer

In the world of programming, a "pointer" is like a GPS for data. It points to a specific location in the computer’s memory where information is stored. In this case, a CrowdStrike developer wrote a piece of code that created a pointer. This pointer was supposed to point to an object—a kind of data structure with specific information. However, due to an oversight, the pointer remained "null."


Think of a null pointer as a GPS that has no destination set—it points to "nothing." But the program didn’t check if the GPS had a valid destination before trying to get there. When it tried to use this pointer to access the data, it essentially tried to read from "nowhere" in the computer's memory.








The Result: A System Crash

Because the pointer was null, trying to access data through it was like trying to find a non-existent road. The program attempted to read from an invalid memory address (0x9C in the technical jargon), which is like trying to drive on an imaginary road.

When the system recognised this invalid memory access, it panicked—rightfully so! To protect itself from potential harm, the system decided to crash the program entirely, resulting in what’s known as the Blue Screen of Death (BSOD). This is a safety measure, akin to your car shutting down to prevent further damage when it detects a critical issue.

How to Avoid Null Pointer Nightmares

So, how can we ensure our digital "GPS" always points to a real destination? Here are some straightforward strategies:

Always Set a Valid Destination:

Make sure pointers are always pointing to a valid memory address or set them to null initially and then check before use.

 

Check Before Using:

Before using a pointer, always check if it’s not null. This is like checking if your GPS has a valid route before you start driving.

Defensive Programming:

Always anticipate and check for potential errors. Use assertions and exceptions to handle unexpected null pointers gracefully. 

    

Conclusion
The CrowdStrike outage was a stark reminder of how a small mistake can cascade into a major issue. By following these best practices, both seasoned developers and newcomers can avoid null pointer nightmares.

Remember, in programming, as in life, always make sure your GPS has a valid destination before you hit the road!

Happy coding, and safe travels through the world of software development! 🚀


Comments

Popular posts from this blog

Feeding a Hungry World: Why We’re Falling Behind and What It Means for Our Future

Imagine waking up each morning with a gnawing pain in your stomach. Not just the mild hunger we all know, but a deep, empty ache. Imagine that feeling isn’t relieved by breakfast or lunch. Imagine it’s there all day. Now, imagine it’s there for your child, your brother, your mother—every single day. This is reality for millions around the world. It’s a silent crisis unfolding in plain sight. And despite the technological and agricultural advancements of the 21st century, the situation is getting worse. Global hunger is on the rise again. We had once been on the path to eliminating it, but something changed. So how did we get here? Why, with all our resources and knowledge, are more people hungry now than just a few years ago? And, more importantly, what are we going to do about it? A Setback in the Fight Against Hunger In 2015, the world seemed to be making steady progress. Hunger levels had been declining for years. It felt like we were on the brink of achieving what seemed impossible...

One More Black Day

Today I have learned about an incident that took place in Hathras in Uttar Pradesh, India. An innocent girl who was just to explore this world and started seeing dreams, like we all do in our 20's is no more with us. When she was to dream her life and make a wish list about what she would like to buy, like all the girls, have in her 20's she met some Inhumans which tarnished her life to death. They tortured her, made her soul cry, and broke her backbone. Her father who was wishing like all fathers would do that one day she will make him proud. But who knew that man wouldn't even get a chance to give last rites to her daughter.  I can't take the pain from her but just can give her pain a few words. A game of lust they played, ruining her night's and day's today she is no more with us was she a sinner? for which she paid? humanity's tower was shaken from inside! hearing to this heinous crime. Her soul was in agony and pain, when they were looting her insane. T...

"Itna Aasan Nahi Hota"

An Acknoledgement to all Boys Out There Who Work Hard Everyday to Capture joy for their Family.... HUM LADKON KI ZINDAGI ITNI BHI AASAN NAHI HOTI.... "Yuh toh dil samandar bhara hai humare, aur ankhon mein nami nahi hoti, itna sunlo hum ladkon ki zindagi bhi itni aasan nahi hoti... Ghar mein bade hai ya chote, kande hamesha zimmedariyon se bhare rehte hai, apne hi pariwaar ki khaatir hum apno se dur rehte hai, Gharwaale pareshaan nah ho humari fikar mein isiliye, hass kar sab theek hai keh dete hai. Ladkiyon ki vidai par toh zamana rota hai, humari vidai ke charche kuch khaas nah hote hai, aur aap jitna sochte ho nah, Hum ladkon ki zindagi bhi itni aasan nah hoti hai... Maa ke Ladle bete hai beshak, par apni bhi pechaan banani padti hai, ek naukri ke khaatir, dere thokre bhi khaani padti hai, Hum ladkon ki zindagi bhi itni aasan nah hoti hai... kabhin in aankoh pe dere nakro hote the jinke, pariwaar ke khaatir sab bhulani padti hai, kuch ko zaroorate jagaye rakhte hai toh, kuch ko...