https://bugs.winehq.org/show_bug.cgi?id=47782
Bug ID: 47782 Summary: Segmentation fault and exceptions using ManagementClass Product: Wine Version: 4.15 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: dridi.boukelmoune@gmail.com Distribution: ---
Originally reported on Fedora's bugzilla for Wine 4.12 (Fedora includes wine-staging) and still happening with Wine 4.15, I'm now throwing the towel as I failed to debug this by myself. I'm interested in commit hashes if a fix is merged, and general pointers on how to deal with this in the future. For example I couldn't get a full back trace when building the master branch and never managed to print arguments up the stack with WineDbg.
https://bugzilla.redhat.com/show_bug.cgi?id=1734794
I can reliably reproduce the C# exceptions and the segfault on my system (either using Fedora packages or building the master branch with or without wine-staging):
$ cat test.cs using System; using System.Management;
class Test { static void Main(string[] args) { ManagementClass mc = new ManagementClass(args[0]); ManagementObjectCollection moc = mc.GetInstances(); foreach (ManagementObject mo in moc) { Console.Write("{0}\n", mo); foreach (PropertyData pd in mo.Properties) Console.Write("\t{0} => {1}\n", pd.Name, pd.Value); } moc.Dispose(); mc.Dispose(); } } $ mcs /reference:System.Management.dll test.cs $ ./test.exe Win32_OperatingSystem # OK $ ./test.exe Win32_PhysicalMemory # OK $ ./test.exe Win32_SoundDevice # OK $ ./test.exe Win32_Processor # System.InvalidCastException $ ./test.exe Win32_VideoController # System.InvalidCastException $ ./test.exe Win32_DesktopMonitor # System.InvalidCastException $ ./test.exe Win32_DisplayControllerConfiguration # SIGSEGV
The problem on the current master branch is the same as when I first reported the segfault to Fedora, except that things moved around a bit:
0x0000000067753b3e build_relpath+0x37 [dlls\wbemprox\query.c:866] in wbemprox: movq (%rax),%rax 866 struct table *table = view->table[table_index];
Again, view->table is null when test.exe is run with Win32_DisplayControllerConfiguration, and for other paths the results are the same (no regression nor improvement).
Obviously my testing is not comprehensive, there may be other problematic management paths but those are the ones I came across. I will happily test patches if requested.
https://bugs.winehq.org/show_bug.cgi?id=47782
--- Comment #1 from Hans Leidekker hans@meelstraat.net --- (In reply to dridi.boukelmoune from comment #0)
$ mcs /reference:System.Management.dll test.cs $ ./test.exe Win32_OperatingSystem # OK $ ./test.exe Win32_PhysicalMemory # OK $ ./test.exe Win32_SoundDevice # OK $ ./test.exe Win32_Processor # System.InvalidCastException $ ./test.exe Win32_VideoController # System.InvalidCastException $ ./test.exe Win32_DesktopMonitor # System.InvalidCastException $ ./test.exe Win32_DisplayControllerConfiguration # SIGSEGV
The System.InvalidCastException failures are due to wrong CIM to VARIANT type conversions for some of the properties. I've submitted a patch to fix them.
The SIGSEGV failure happens because that class is not implemented. I've submitted another patch that turns it into a more graceful System.Management.ManagementException, which includes an error code.
https://bugs.winehq.org/show_bug.cgi?id=47782
--- Comment #2 from dridi.boukelmoune@gmail.com --- I gave a try to the current master branch with the two patches you submitted, merged as 58572fc916ecbd6ae77f2b181f51daf4169dcef1 and 34bd6a9cf3b3b40ebb81dab423d2d740e2ad9ac4 and it looks fine on my end.
For Win32_DisplayControllerConfiguration, do you have pointers on how to implement that class? For example another class I could look at to see how things are put together?
Thanks for such a quick fix!
https://bugs.winehq.org/show_bug.cgi?id=47782
--- Comment #3 from dridi.boukelmoune@gmail.com --- And also, I wasn't able to pick a component for this bug report, it is still "-unknown". What would be the correct one?
https://bugs.winehq.org/show_bug.cgi?id=47782
Zebediah Figura z.figura12@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Component|-unknown |wmi&wbemprox
https://bugs.winehq.org/show_bug.cgi?id=47782
Hans Leidekker hans@meelstraat.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|UNCONFIRMED |RESOLVED Fixed by SHA1| |31c0cb48622ae869cfc358be853 | |1821ec1eda7b4
--- Comment #4 from Hans Leidekker hans@meelstraat.net --- Win32_DisplayControllerConfiguration is implemented with 31c0cb48622ae869cfc358be8531821ec1eda7b4.
https://bugs.winehq.org/show_bug.cgi?id=47782
--- Comment #5 from Dridi dridi.boukelmoune@gmail.com --- Thanks a lot, it works as expected on my system! Should I run into another missing class, I will revisit your patches and try to give it a stab myself. You were impressively fast to address this ticket.
https://bugs.winehq.org/show_bug.cgi?id=47782
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #6 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 4.18.