C
C#17mo 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
Anton17mo ago
I'd guess this is null
pengowray
pengowray17mo 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
Accord17mo 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
canton717mo 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
qqdev17mo ago
Use the debugger to check if this is null
nukleer bomb
nukleer bomb17mo 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
Accord17mo 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
More Posts
❔ Azure Speech Service wont shut upI am using azure in a WPF app, where I have two buttons, Read, and Stop The problem is, that when I❔ The remote certificate is invalid because of error in the certificate chain: partial chainWhen I debug it from VS, the request responds successfully, but when the service is deployed to anot❔ ✅ How does .NET MAUI Blazor relate to Blazor Server or WebAssembly?Or am I conflating those ideas? I see the .NET MAUI Blazor project template `index.html` has the li✅ Output not correctIm doing a Client/server program the program will give out in output if the user is a minor or not t❔ How to create an event handler for a variableI am currently developing a HTML editor that has tabs and a page that shows the output. The variable❔ Looking to turn this GUI integer calculator into a Fraction calculator using the provided classFinal project for school, need to create a GUI fraction calculator. I have a GUI integer calculator ❔ How do I publish a WebAssembly app to a singlefile executableHow do I publish a web assembly app to a selfhosted single executable file? Using these settings juJSON C#Can someone help with this code: using System; using System.Collections.Generic; using System.Compon❔ Help to close a forms from another forms C#I created 2 scripts with a timer with intervals of 1000 ms, both one is to open a new form when a ce❔ Item stacking in unity c#I am trying to get my items to stack in my inventory, so i have added a counter to my script which d