3 ms·
You directly see where the null dereference happens. But that's not necessarily where the problem actually is, because a null pointer can flow through a lot of
by int_19h 7y ago
You directly see where the null dereference happens. But that's not necessarily where the problem actually is, because a null pointer can flow through a lot of code before it actually gets dereferenced. So "program continues to work for a while" is also a thing with them.
In a language like C, a null pointer can also become an invalid non-null pointer pretty easy with pointer arithmetics.
- cylon13 7y agoEasy, just add "if (thing == null) return;" to the top of the function that crapped out on a null reference and close the ticket! /s
- int_19h 7y agoSarcasm aside, this is often how it gets fixed in poor quality codebases! And if it returns a reference itself, it ends up being: if (thing == null) return null; more often than not. Which leads to an even more entertaining debuggin trip next time...
- cylon13 7y agoOh for sure. I wish I would have thought of that sarcastic quip by being creative, but in reality it's because I've seen it so many times.
- MertsA 7y ago>a null pointer can also become an invalid non-null pointer pretty easy with pointer arithmetics. Yeah but even then it's still easy enough to see what happened when you have a pointer to address 0x0000002F or some similar small pointer.