RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

PInvokeStackImbalance on using zlib32.dll or zlib64.dll

Scriptiz

Sorceror
When I'm debugging the server side of RunUO, each time a Gump is opened I get this exception wich stop the code and need to manually clic on continue executing button.

Code:
PInvokeStackImbalance was detected Message: A call to PInvoke function 'Server!Server.Network.Compressor32::compress2'
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.

This exception is throwed because the method signature of compress2 as a variable number of parameters. To avoid this exception and continue to debug the server side-code, you just have to made a few fixes :

Change all line theses lines in Network/Comression.cs :
Code:
[DllImport( "zlib32" )]
By this :
Code:
[DllImport("zlib32", CallingConvention = CallingConvention.Cdecl)]

And theses :
Code:
[DllImport( "zlib64" )]
By this :
Code:
[DllImport("zlib64", CallingConvention = CallingConvention.Cdecl)]

That's 8 small lines to change from line 218 to 262.

That's is just saying that the method have a variable number of parameters and that it is normal.

Maybe there is a way to change debugging option to avoid this warning while executing the server, but I found that a proper way to fix this and avoiding others to have this problem while debugging server side code.

Thanks :)

PS : tested and approved ;)
 

Jeff

Lord
When I'm debugging the server side of RunUO, each time a Gump is opened I get this exception wich stop the code and need to manually clic on continue executing button.

Code:
PInvokeStackImbalance was detected Message: A call to PInvoke function 'Server!Server.Network.Compressor32::compress2'
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.

This exception is throwed because the method signature of compress2 as a variable number of parameters. To avoid this exception and continue to debug the server side-code, you just have to made a few fixes :

Change all line theses lines in Network/Comression.cs :
Code:
[DllImport( "zlib32" )]
By this :
Code:
[DllImport("zlib32", CallingConvention = CallingConvention.Cdecl)]

And theses :
Code:
[DllImport( "zlib64" )]
By this :
Code:
[DllImport("zlib64", CallingConvention = CallingConvention.Cdecl)]

That's 8 small lines to change from line 218 to 262.

That's is just saying that the method have a variable number of parameters and that it is normal.

Maybe there is a way to change debugging option to avoid this warning while executing the server, but I found that a proper way to fix this and avoiding others to have this problem while debugging server side code.

Thanks :)

PS : tested and approved ;)
Ya, .Net 4.0 changed how DllImport works...So this only applies to when you compile against the .Net 4.0 framework. 3.5 and below would try to resolve the calling convention itself, 4.0 removed this for performance purposes.
 

Scriptiz

Sorceror
Ok great, is there any performance gain to compile with .NET 4 framework?

Or just new C# 4.0 new features (dynamic typed objects, optional and named parameters, ...)?
 

Jeff

Lord
Ok great, is there any performance gain to compile with .NET 4 framework?

Or just new C# 4.0 new features (dynamic typed objects, optional and named parameters, ...)?
Nothing really. Mostly features.... infact, there is a memory leak in .Net 4 with the DateTime.Now call, which i believe is used a lot in RunUO... so might want to be careful.
 

Scriptiz

Sorceror
I didn't noticed any memory leak since I've compiled RunUO with the framework .NET 4.

Maybe it was fixed in a patch because my RunUO server is going well, always running around 180 Mb RAM, even after a few days.

Or the memory leak is of 1 bit per DateTime.Now? ^^
 

Jeff

Lord
I didn't noticed any memory leak since I've compiled RunUO with the framework .NET 4.

Maybe it was fixed in a patch because my RunUO server is going well, always running around 180 Mb RAM, even after a few days.

Or the memory leak is of 1 bit per DateTime.Now? ^^

Ya it is eventually cleaned up. But seems GC takes forever in doing so.
 
Top