Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange exception: msvcrt.dll #31

Open
osbeorn opened this issue Mar 7, 2017 · 8 comments
Open

Strange exception: msvcrt.dll #31

osbeorn opened this issue Mar 7, 2017 · 8 comments
Assignees
Labels
Milestone

Comments

@osbeorn
Copy link

osbeorn commented Mar 7, 2017

Hello,

I randomly encounter the following error in my program when using this library:

Exception thrown at 0x00007FF81DD03F80 (msvcrt.dll) in FireDeptStopwatch.exe: 0xC0000005: Access violation reading location 0x0000000014585ED8.

The following line of code is enough to trigger the exception:
var sessions = audioController.DefaultPlaybackDevice.GetCapability<IAudioSessionController>();

Any clue what might be wrong?

@xenolightning
Copy link
Owner

What operating system are you running on?

Does it happen immediately, or after the application has been running for some time?

@osbeorn
Copy link
Author

osbeorn commented Mar 7, 2017

Win10 x64.
It happens after sometime. And it seems quite random.

@xenolightning
Copy link
Owner

The underlying COM object may get destroyed.

Taking a quick look at the session code, there may be some enhancements in that space regarding object lifecycle.

@xenolightning xenolightning self-assigned this Mar 8, 2017
@xenolightning xenolightning added this to the 4.0.0 milestone Mar 8, 2017
@osbeorn
Copy link
Author

osbeorn commented Mar 9, 2017

One more thing ... My application is basically a stopwatch, which plays a command on start and plays another random audio track on end. It seems that just one specific audio track triggers this error.

The audio track is a 10s long .wav file of some song.
The code used to play the track:
using (var player = new SoundPlayer((UnmanagedMemoryStream) sound)) { player.Play(); }

@xenolightning
Copy link
Owner

Are you able to create a gist or attach a piece of self contained code that can be used to reproduce it? If you can, it should be fairly easy to track down and fix.

@osbeorn
Copy link
Author

osbeorn commented Mar 10, 2017

Here you go:
fireDeptStopwatchGist.zip

Run the project, press Start, wait for the counter to start counting and then press Stop. You should get the mentioned exception.

@osbeorn
Copy link
Author

osbeorn commented Mar 10, 2017

It seems that the main problem is this block of code:
using (var player = new SoundPlayer((UnmanagedMemoryStream) sound)) { player.Play(); }

If I remove the using block and normally create a new SoundPlayer instance, the application stops crashing. It seems the SoundPlayer instance created inside the using block is getting disposed before it finishes playing the sound.

But if I remove your library, the SoundPlayer works fine even when using it with the using block.

@xenolightning
Copy link
Owner

I had a look at this in the weekend, and it's definitely in the Session Initialization code.

I should be able to track it down, and make a fix for it. I'll tag the commit in here, once it's done.

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants