http://bugs.winehq.org/show_bug.cgi?id=34711
Bug #: 34711 Summary: Terraria Server 1.2.0.x fails on startup (needs CLSID_UPnPNAT {ae1e00aa-3fd5-403c-8a27-2bbdc30cd0e1}) Product: Wine Version: 1.7.4 Platform: x86 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: focht@gmx.net Classification: Unclassified
Hello folks,
split off from bug 30097 as this is a different issue.
Prerequisite: 'winetricks -q dotnet40 xna40' in clean 32-bit WINEPREFIX
--- snip --- $ wine TerrariaServer.exe -config serverconfig.txt ... fixme:shell:URL_ParseUrl failed to parse L"System" fixme:shell:URL_ParseUrl failed to parse L"Microsoft.Xna.Framework.Game" fixme:shell:URL_ParseUrl failed to parse L"Microsoft.Xna.Framework" fixme:shell:URL_ParseUrl failed to parse L"System.Configuration" fixme:shell:URL_ParseUrl failed to parse L"System.Xml" err:ole:CoGetClassObject class {ae1e00aa-3fd5-403c-8a27-2bbdc30cd0e1} not registered err:ole:create_server class {ae1e00aa-3fd5-403c-8a27-2bbdc30cd0e1} not registered fixme:ole:CoGetClassObject CLSCTX_REMOTE_SERVER not supported err:ole:CoGetClassObject no class object {ae1e00aa-3fd5-403c-8a27-2bbdc30cd0e1} could be created for context 0x15 fixme:advapi:RegisterTraceGuidsW (0xc3c4da, (nil), {8e9f5090-2d75-4d03-8a81-e5afbf85daf1}, 1, 0x33b6cc, (null), (null), 0xfa2868,): stub fixme:shell:URL_ParseUrl failed to parse L"Microsoft.Xna.Framework.Graphics" fixme:shell:URL_ParseUrl failed to parse L"Microsoft.Xna.Framework.Xact" fixme:process:FlushProcessWriteBuffers : stub
Unhandled Exception: System.TypeInitializationException: The type initializer for 'Terraria.Main' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Terraria.Netplay' threw an exception. ---> System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1} failed due to the following error: 80040154 Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG). at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Activator.CreateInstance(Type type) at Terraria.Netplay..cctor() --- End of inner exception stack trace --- at Terraria.Main..cctor() --- End of inner exception stack trace --- at Terraria.Main..ctor() at Terraria.ProgramServer.Main(String[] args) --- snip ---
Server: Main.versionNumber = "v1.2.0.3.1";
Decompiling with ILSpy gives:
--- snip --- // Terraria.Netplay static Netplay() { // Note: this type is marked as 'beforefieldinit'. Netplay.stopListen = false; Netplay.serverSock = new ServerSock[256]; Netplay.clientSock = new ClientSock(); Netplay.serverPort = 7777; Netplay.disconnect = false; Netplay.password = ""; Netplay.banFile = "banlist.txt"; Netplay.spamCheck = false; Netplay.anyClients = false; Netplay.upnpnat = (UPnPNAT)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("AE1E00AA-3FD5-403C-8A27-2BBDC30CD0E1"))); Netplay.mappings = Netplay.upnpnat.StaticPortMappingCollection; Netplay.uPNP = true; Netplay.ServerUp = false; } --- snip ---
Expected as Wine doesn't implement CLSID_UPnPNAT in HNetCfg.dll (NATUPnP.idl).
$ du -sh terraria-server-12031.zip 788K terraria-server-12031.zip
$ sha1sum terraria-server-12031.zip 2333bf1e6ad1d77fc5d59a389cad6581e48c12bf terraria-server-12031.zip
$ wine --version wine-1.7.4-91-g7ac2b3b
Regards
http://bugs.winehq.org/show_bug.cgi?id=34711
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |dotnet, download URL| |http://www.terraria.org/ter | |raria-server-12031.zip
http://bugs.winehq.org/show_bug.cgi?id=34711
ineyaa@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |ineyaa@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=34711
Sergey lis82@mail.by changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |lis82@mail.by
https://bugs.winehq.org/show_bug.cgi?id=34711
Richard Graham richard479@yahoo.co.uk changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |richard479@yahoo.co.uk
https://bugs.winehq.org/show_bug.cgi?id=34711
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |hnetcfg
--- Comment #1 from Anastasius Focht focht@gmx.net --- Hello folks,
revisiting, still present.
$ wine --version wine-1.7.54-179-ga0d0d0d
Regards
https://bugs.winehq.org/show_bug.cgi?id=34711
Alistair Leslie-Hughes leslie_alistair@hotmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |leslie_alistair@hotmail.com Status|NEW |STAGED Staged patchset| |https://github.com/wine-sta | |ging/wine-staging/tree/mast | |er/patches/hnetcfg-NATUPnP
https://bugs.winehq.org/show_bug.cgi?id=34711
Alistair Leslie-Hughes leslie_alistair@hotmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |449833b48aabe25ef500fe12b2b | |00e83bd9b2efd Status|STAGED |RESOLVED Resolution|--- |FIXED
--- Comment #2 from Alistair Leslie-Hughes leslie_alistair@hotmail.com --- Fixed by https://source.winehq.org/git/wine.git/?a=commit;h=449833b48aabe25ef500fe12b...
https://bugs.winehq.org/show_bug.cgi?id=34711
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED |---
--- Comment #3 from Anastasius Focht focht@gmx.net --- Hello folks,
too soon. No, unfortunately not fixed.
* https://source.winehq.org/git/wine.git/commitdiff/c71abc386b5f84c19fed7dd69f... ("include: Add natupnp.idl.")
* https://source.winehq.org/git/wine.git/commitdiff/bd9610535369500dff1dfde0fc... ("hnetcfg: Register NATUPnP interface.")
* https://source.winehq.org/git/wine.git/commitdiff/449833b48aabe25ef500fe12b2... ("hnetcfg: Support IUPnPNAT interface. ")
* https://source.winehq.org/git/wine.git/commitdiff/d65bd95ecd4fee57cbfe17b375... ("hnetcfg: Link to uuid library.")
The old archive to reproduce with is no longer present on the main site. I found a copy here:
http://wc3dota.persiangig.com/.Srl0nxC6Ke/Terraria/terraria-server-12031.zip
New version:
http://terraria.org/system/dedicated_servers/archives/000/000/032/original/t...
It crashes. Running under managed CLR debugger shows:
--- snip --- ... 0035:trace:loaddll:load_builtin_dll Loaded L"C:\windows\system32\hnetcfg.dll" at 0x7d060000: builtin 0035:fixme:hnetcfg:hnetcfg_cf_QueryInterface interface {00000003-0000-0000-c000-000000000046} not implemented 0035:fixme:hnetcfg:hnetcfg_cf_QueryInterface interface {00000019-0000-0000-c000-000000000046} not implemented 0035:fixme:hnetcfg:hnetcfg_cf_QueryInterface interface {b196b28f-bab4-101a-b69c-00aa00341d07} not implemented 0035:err:ole:marshal_object Failed to create an IRpcStubBuffer from IPSFactory for {b196b28f-bab4-101a-b69c-00aa00341d07} with error 0x80004002 0032:err:ole:ClientIdentity_QueryMultipleInterfaces IRemUnknown_RemQueryInterface failed with error 0x80004002 0035:fixme:hnetcfg:upnpnat_QueryInterface interface {00000003-0000-0000-c000-000000000046} not implemented 0035:fixme:hnetcfg:upnpnat_QueryInterface interface {00000003-0000-0000-c000-000000000046} not implemented 0035:fixme:hnetcfg:upnpnat_QueryInterface interface {00000019-0000-0000-c000-000000000046} not implemented 0035:fixme:hnetcfg:upnpnat_QueryInterface interface {c3fcc19e-a970-11d2-8b5a-00a0c9b7c9c4} not implemented 0035:fixme:hnetcfg:upnpnat_QueryInterface interface {c3fcc19e-a970-11d2-8b5a-00a0c9b7c9c4} not implemented 0032:err:ole:ClientIdentity_QueryMultipleInterfaces IRemUnknown_RemQueryInterface failed with error 0x80004002 0035:fixme:hnetcfg:upnpnat_QueryInterface interface {b196b283-bab4-101a-b69c-00aa00341d07} not implemented 0035:err:ole:marshal_object Failed to create an IRpcStubBuffer from IPSFactory for {b196b283-bab4-101a-b69c-00aa00341d07} with error 0x80004002 0032:err:ole:ClientIdentity_QueryMultipleInterfaces IRemUnknown_RemQueryInterface failed with error 0x80004002 0035:err:ole:marshal_object couldn't get IPSFactory buffer for interface {00000144-0000-0000-c000-000000000046} 0032:err:ole:ClientIdentity_QueryMultipleInterfaces IRemUnknown_RemQueryInterface failed with error 0x80004002 0035:err:ole:marshal_object couldn't get IPSFactory buffer for interface {b171c812-cc76-485a-94d8-b6b3a2794e99} 0032:err:ole:ClientIdentity_QueryMultipleInterfaces IRemUnknown_RemQueryInterface failed with error 0x80004002 0035:err:ole:marshal_object couldn't get IPSFactory buffer for interface {b171c812-cc76-485a-94d8-b6b3a2794e99} 0032:err:ole:ClientIdentity_QueryMultipleInterfaces IRemUnknown_RemQueryInterface failed with error 0x80004002 (31.32): C++ EH exception - code e06d7363 (first chance) 0030:fixme:ntdll:RtlGetUnloadEventTrace stub! 0030:trace:loaddll:load_builtin_dll Loaded L"C:\windows\system32\wtsapi32.dll" at 0xf7df0000: builtin 0030:trace:loaddll:load_native_dll Loaded L"C:\windows\Microsoft.NET\Framework\v4.0.30319\mscordacwks.dll" at 0x7a820000: native There is no current managed exception on this thread OS Thread Id: 0x32 (0) Child SP IP Call Site 0033d664 7b43c87b [HelperMethodFrame_1OBJ: 0033d664] 0033d6c0 0389014c Terraria.Netplay..cctor() 0033d928 791421db [GCFrame: 0033d928] 0033f30c 791421db [PrestubMethodFrame: 0033f30c] Terraria.ProgramServer.Main(System.String[]) 0033f548 791421db [GCFrame: 0033f548] 0032:fixme:ntdll:EtwRegisterTraceGuidsW (0xc405ba, (nil), {8e9f5090-2d75-4d03-8a81-e5afbf85daf1}, 1, 0x33b930, (null), (null), 0xfb2d64): stub 0032:fixme:ntdll:EtwRegisterTraceGuidsW register trace class {8e9f5090-2d75-4d03-8a81-e5afbf85daf1} (31.32): CLR exception - code e0434352 (first chance) Exception object: 00f9d5e4 Exception type: System.InvalidCastException Message: Unable to cast COM object of type 'System.__ComObject' to interface type 'NATUPNPLib.UPnPNAT'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B171C812-CC76-485A-94D8-B6B3A2794E99}' failed due to the following error: Exception from HRESULT: 0x80004002 (E_NOINTERFACE). InnerException: <none> StackTrace (generated): <none> StackTraceString: <none> HResult: 80004002 OS Thread Id: 0x32 (0) Child SP IP Call Site 0033d664 7b43c87b [HelperMethodFrame_1OBJ: 0033d664] 0033d6c0 0389014c Terraria.Netplay..cctor() 0033d928 791421db [GCFrame: 0033d928] 0033f30c 791421db [PrestubMethodFrame: 0033f30c] Terraria.ProgramServer.Main(System.String[]) 0033f548 791421db [GCFrame: 0033f548] First chance exceptions are reported before any exception handling. This exception may be expected and handled. --- snip ---
"Unable to cast COM object of type 'System.__ComObject' to interface type 'NATUPNPLib.UPnPNAT'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B171C812-CC76-485A-94D8-B6B3A2794E99}' failed due to the following error: Exception from HRESULT: 0x80004002 (E_NOINTERFACE)."
Cross-thread marshalling doesn't work here. Each thread must have access to the type information (registry) that describes the COM object to be able to unmarshal the object from the source thread.
Wine source:
https://source.winehq.org/git/wine.git/blob/HEAD:/include/natupnp.idl#l205
--- snip --- 187 [ 188 object, 189 uuid(b171c812-cc76-485a-94d8-b6b3a2794e99), 190 dual, 191 pointer_default(unique) 192 ] 193 interface IUPnPNAT : IDispatch 194 { 195 [propget, id(1)] 196 HRESULT StaticPortMappingCollection ([out, retval] IStaticPortMappingCollection **collection); 197 198 [propget, id(2)] 199 HRESULT DynamicPortMappingCollection ([out, retval] IDynamicPortMappingCollection **collection); 200 201 [propget, id(3)] 202 HRESULT NATEventManager ([out, retval] INATEventManager **manager); 203 }; 204 205 [ 206 id(2), 207 uuid(1c565858-f302-471e-b409-f180aa4abec6), 208 version(1.0) 209 ] 210 library NATUPNPLib 211 { 212 importlib("stdole2.tlb"); 213 214 [ 215 vi_progid("HNetCfg.NATUPnP"), 216 progid("HNetCfg.NATUPnP.1"), 217 threading(apartment), 218 uuid(ae1e00aa-3fd5-403c-8a27-2bbdc30cd0e1) 219 ] 220 coclass UPnPNAT 221 { 222 [default] interface IUPnPNAT; 223 }; 224 }; --- snip ---
It seems for Wine's MIDL the interface in question needs to be defined *inside* the 'library' block and have 'oleautomation' attribute. Otherwise it's not getting registered under 'HKEY_CLASSES_ROOT\Interface\{IID}\...' (proxy/stub).
I was surprised about that behaviour since the interface was referenced by the coclass within the library block and had 'dual' attribute.
http://diranieh.com/IDL/Structure.htm
--- quote --- Interface location [oleautomation]/ [dual] defined
Inside library block Interface uses Universal Marshaler Interface appears in type library
Outside library block Interface uses Universal Marshaler Interface does not appear in type library (unless referenced, perhaps in the coclass section)
---
Interface location [oleautomation]/ [dual] not defined
Inside library block AVOID. NO INTERCEPTION CODE GENERATED!
Outside library block Interface does not use Universal Marshaler. Need to build proxy/stub DLL. Interface does not appear in type library (unless referenced, perhaps in the coclass section) --- quote ---
With that fixed, cross-thread marshalling (using std marshaler) works and it runs into next problem (unimpl. method/stub).
$ wine --version wine-3.18-75-ge55aca8f49
Regards
https://bugs.winehq.org/show_bug.cgi?id=34711
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution|--- |FIXED
--- Comment #4 from Anastasius Focht focht@gmx.net --- Hello folks,
--- quote --- I don't think this is the right solution to this problem. On Windows only the coclass declaration is inside the library declaration, so I think we should fix widl to also register dependent interfaces. --- quote ---
Zebediah's comment https://www.winehq.org/pipermail/wine-devel/2018-October/133648.html convinced me to create a new ticket to target this problem in general.
Bug 46005 ("Multiple games and applications fail due to missing interface proxy information in registry (oleautomation/dual interfaces referenced in coclass section)").
Resolving here since the general parts were done.
Thanks Alistair
Regards
https://bugs.winehq.org/show_bug.cgi?id=34711
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.winehq.org/sho | |w_bug.cgi?id=46005
https://bugs.winehq.org/show_bug.cgi?id=34711
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #5 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 3.19.
https://bugs.winehq.org/show_bug.cgi?id=34711
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- URL|http://www.terraria.org/ter |https://web.archive.org/web |raria-server-12031.zip |/20141007075154/http://terr | |aria.org/system/dedicated_s | |ervers/archives/000/000/002 | |/original/terraria-server-1 | |241.zip?1410586550