this post was submitted on 02 Oct 2023
1099 points (98.8% liked)

Programmer Humor

32479 readers
666 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] xilliah@beehaw.org 1 points 1 year ago

If you have optimizations enabled this can easily occur due to code being moved around behind the scenes. For example the body of a small function can be inserted where it is called. For example in c# if you get a null ref exception in such inlined code it will actually direct you to the place where the function is called from, rather than its body.

So if you know, you probably can find the issue. In the worst case just go to debug mode with opti off, or use an attribute on the function to force it not to inline.