C
C#2y ago
pengowray

❔ I'm confused how "x = false" can cause a NullReferenceException

declaration of _isUpdatingPeakValue is inside a public sealed class:
private volatile bool _isUpdatingPeakValue;
//...
_isUpdatingPeakValue = false;
private volatile bool _isUpdatingPeakValue;
//...
_isUpdatingPeakValue = false;
The code is in a large, decompiled (open source) library, and is called by a timer (setup automatically by the library). I can give more details if needed, but thought I'd ask with the basics in case I was missing something obvious first. It consistently crashes at this spot when run with debugger (but not when it's not). .Net 4.8
7 Replies
Anton
Anton2y ago
I'd guess this is null
pengowray
pengowrayOP2y ago
yah, i think so, but it's odd that it's there and never the previous _isUpdatingPeakValue = true i guess i don't know what's happening in the function calls in between
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
canton7
canton72y ago
Is this a release build? If it is, I wouldn't necessarily expect the line number to be correct there -- it might be actually be raised on one of the lines above It should be impossible for this to be null there, unless that method is being called by reverse p/invoke or IL manually emitted at runtime or something. The compiler always emits IL which ensures that this is not null (unless it's certain that it cannot be null)
qqdev
qqdev2y ago
Use the debugger to check if this is null
nukleer bomb
nukleer bomb2y ago
If the library is decompiled, then the debugger may point to the wrong line. Stacktrace will give much more information in this case
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server