开发者

"PInvokeStackImbalance was detected" from HDFDotNet 1.8.7

I have been attempting to update to the latest HDF5DotNet wrappers (1.8.7) and am getting the following warnings (when running in DEBUG mode from VS2010):

PInvokeStackImbalance was detected Message: A call to PInvoke function 'HDF5DotNet!::H5Fopen' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

I am using the pre-compiled binaries (HDF5DotNet as开发者_StackOverflow社区sembly for .NET Framework 4.0 32-bit), but got the same result when I compiled from source.

Strangely, when executing my application that calls the HDF5DotNet wrappers in non-DEBUG mode, I see no problems. I did notice that between 1.8.6 and 1.8.7 all the calling conventions were switched from Cdecl to StdCall. Could this be causing this? I've seen other forums saying the CallingConvention should BE Cdecl...

Thanks!


Yes, calling a stdcall function as cdecl or the other way round causes a stack imbalance. The main difference between these conventions is that with cdecl the caller is responsible for removing the arguments from the stack, with stdcall the callee is responsible.

I guess in release mode you have the same bug. But you don't get the error because some runtime checks are disabled. A native program would crash in most cases where you use the wrong calling convention, but it seems like the .net interop code has a more robust stack handling that masks this problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜