PInvokeStackImbalance on load

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
powelerl
Posts: 31
Joined: Thu 22 Dec 2016 10:00

PInvokeStackImbalance on load

Post by powelerl » Tue 28 Nov 2017 18:09

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

powelerl
Posts: 31
Joined: Thu 22 Dec 2016 10:00

Re: PInvokeStackImbalance on load

Post by powelerl » Tue 28 Nov 2017 18:12

Weird, works for netcoreapp2.0 in 32bit mode (as well as 64bit).

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: PInvokeStackImbalance on load

Post by Pinturiccio » Mon 04 Dec 2017 16:12

We are working on the issue, and we will post here when we get any results.

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: PInvokeStackImbalance on load

Post by Pinturiccio » Wed 06 Dec 2017 17:05

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.

powelerl
Posts: 31
Joined: Thu 22 Dec 2016 10:00

Re: PInvokeStackImbalance on load

Post by powelerl » Wed 06 Dec 2017 20:13

OK. But isn't there a erroneous PInvoke call somewhere? Sounds like compiling without type safety and have a go.

powelerl
Posts: 31
Joined: Thu 22 Dec 2016 10:00

Re: PInvokeStackImbalance on load

Post by powelerl » Sun 10 Dec 2017 16:55

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: PInvokeStackImbalance on load

Post by Shalex » Tue 12 Dec 2017 15:57

Thank you for your report. We have reproduced the issue and are investigating it.

simon.sanschagrin
Posts: 1
Joined: Wed 25 Apr 2018 16:05

Re: PInvokeStackImbalance on load

Post by simon.sanschagrin » Wed 25 Apr 2018 16:07

Was this issue solved? Because I am experiencing the same issue.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: PInvokeStackImbalance on load

Post by Shalex » Thu 26 Apr 2018 17:10

This is a resource demanding task. We cannot provide any timeframe at the moment.

hansjoergp
Posts: 39
Joined: Wed 31 May 2017 14:33

Re: PInvokeStackImbalance on load

Post by hansjoergp » Tue 14 Jan 2020 11:58

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: PInvokeStackImbalance on load

Post by Shalex » Thu 16 Jan 2020 16:17

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

hansjoergp
Posts: 39
Joined: Wed 31 May 2017 14:33

Re: PInvokeStackImbalance on load

Post by hansjoergp » Fri 17 Jan 2020 09:46

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

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: PInvokeStackImbalance on load

Post by Shalex » Fri 17 Jan 2020 13:42

Our answer on Tue Dec 12, 2017 5:57 pm was about reproducing the warning. Disabling PInvokeStackImbalance should not cause any issue.

Post Reply