s23697 / practicesharp

Automatically exported from code.google.com/p/practicesharp
0 stars 0 forks source link

NAudio FLAC reading stack imbalances #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I noticed I kept getting PInvokeStack imbalances with your test program for the 
NAudio FLAC player. Then when I checked LibFLACSharp.cs I noticed all of the 
DLLImport calls are as follows

[DLLImport(DLLName)]

The stack imbalance exceptions were fixed by changing these to:

[DllImport(DLLName, CallingConvention = CallingConvention.Cdecl)]

Original issue reported on code.google.com by mathew1800 on 22 May 2013 at 3:40

GoogleCodeExporter commented 9 years ago
Hi Mathew,
Just noticed this defect now.
Can you explain what 'Imbalances' mean, and how I can test it as well?
The Cdecl means:
"The caller cleans the stack. This enables calling functions with varargs, 
which makes it appropriate to use for methods that accept a variable number of 
parameters, such as Printf."

I have no problem changing all the DllImport declarations, but I'm trying to 
first understand how you noticed the issue. The original code I used was here, 
http://stoyanov.in/2010/01/08/encoding-uncompressed-audio-with-flac-in-c/
It might be a bug by the original author

Original comment by yuva...@gmail.com on 10 Jun 2013 at 3:25

GoogleCodeExporter commented 9 years ago
I noticed it when I used the plugin for a personal player I'm working on. I 
opened the Flac DLL in Dependency Walker and it says the calling convention 
used within that DLL is cdecl.

By default, P/Invoke functions use StdCall if an explicit calling convention 
isn't specified in the DllImport attribute. So it's using the wrong calling 
convention to call those functions.

Original comment by mathew1800 on 12 Jun 2013 at 5:33

GoogleCodeExporter commented 9 years ago
Oh, forgot to mention that what I meant by a stack imbalance is the error that 
gets thrown: http://msdn.microsoft.com/en-us/library/0htdy0k3.aspx 
PInvokeStackImbalance

Original comment by mathew1800 on 12 Jun 2013 at 5:35

GoogleCodeExporter commented 9 years ago

Original comment by yuva...@gmail.com on 14 Jun 2013 at 7:46

GoogleCodeExporter commented 9 years ago
Will be released in the next release

Original comment by yuva...@gmail.com on 14 Jun 2013 at 7:47