Page 1 of 1

PInvokeStackImbalance on load

Posted: Tue 28 Nov 2017 18:09
by powelerl
Works for 64bit, fails for 32bit. I am 100% sure the correct Oracle client is in PATH env according to bitness.

NuGet v9.5.399 / .NET Standard 2.0
.NET Framework 4.6.2
Oracle 12c Release 1 32bit

Code: Select all

Managed Debugging Assistant 'PInvokeStackImbalance'  occurred
  Message=Managed Debugging Assistant 'PInvokeStackImbalance' : 'A call to PInvoke function 'Devart.Data.Oracle!Devart.Data.Oracle.Oci::nativeOCIEnvCreate' 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.'

Re: PInvokeStackImbalance on load

Posted: Tue 28 Nov 2017 18:12
by powelerl
Weird, works for netcoreapp2.0 in 32bit mode (as well as 64bit).

Re: PInvokeStackImbalance on load

Posted: Mon 04 Dec 2017 16:12
by Pinturiccio
We are working on the issue, and we will post here when we get any results.

Re: PInvokeStackImbalance on load

Posted: Wed 06 Dec 2017 17:05
by Pinturiccio
powelerl wrote:Managed Debugging Assistant 'PInvokeStackImbalance' occurred
The pInvokeStackImbalance MDA is implemented only for the 32-bit x86 platforms. For more information, please refer to https://docs.microsoft.com/en-us/dotnet ... alance-mda
Thus this error can occur only in a 32-bit application. A 64-bit application will ignore it.
Moreover, this behavior occurs only in the debug mode and won't occur in the release mode. So if you disable MDA or run code in the release mode, everything should work.

Re: PInvokeStackImbalance on load

Posted: Wed 06 Dec 2017 20:13
by powelerl
OK. But isn't there a erroneous PInvoke call somewhere? Sounds like compiling without type safety and have a go.

Re: PInvokeStackImbalance on load

Posted: Sun 10 Dec 2017 16:55
by powelerl
I disabled the MDA and error gone, of course. Now I have a program that hangs indefinitely loading data from the database. I guess the error is real.

Re: PInvokeStackImbalance on load

Posted: Tue 12 Dec 2017 15:57
by Shalex
Thank you for your report. We have reproduced the issue and are investigating it.

Re: PInvokeStackImbalance on load

Posted: Wed 25 Apr 2018 16:07
by simon.sanschagrin
Was this issue solved? Because I am experiencing the same issue.

Re: PInvokeStackImbalance on load

Posted: Thu 26 Apr 2018 17:10
by Shalex
This is a resource demanding task. We cannot provide any timeframe at the moment.

Re: PInvokeStackImbalance on load

Posted: Tue 14 Jan 2020 11:58
by hansjoergp
When will the error be corrected?We have the same problem and it would be very important for us to have a solution for this

Re: PInvokeStackImbalance on load

Posted: Thu 16 Jan 2020 16:17
by Shalex
This is a warning about a possible issue, but in fact, there is no problem.

There are possible workarounds:
a) set Platform target=x64 in the properties of your project
b) use Direct Mode instead of connecting via Oracle Client x86
c) turn off the PInvokeStackImbalance option via Exception Settings > Managed Debugging Assistants > PInvokeStackImbalance

Re: PInvokeStackImbalance on load

Posted: Fri 17 Jan 2020 09:46
by hansjoergp
a) is not possible, because we have an program which is for win32
b) We have to support for historical reasons both
c) I hope that it is only a warning. Regarding to the post of "powelerl on Sun 10 Dec 2017 16:55" he had problems after disabling the warning

Regards

Re: PInvokeStackImbalance on load

Posted: Fri 17 Jan 2020 13:42
by Shalex
Our answer on Tue Dec 12, 2017 5:57 pm was about reproducing the warning. Disabling PInvokeStackImbalance should not cause any issue.