gnif / LookingGlass

An extremely low latency KVMFR (KVM FrameRelay) implementation for guests with VGA PCI Passthrough.
GNU General Public License v2.0
4.74k stars 261 forks source link

host application crashing (shared memory device already in use), Windows error 1005 #416

Closed Necronom1con closed 3 years ago

Necronom1con commented 3 years ago

Disclaimer, I am not 100% certain this is actually a bug, but it does look somewhat suspicious to me.

I am trying to run the looking glass host application version B2 inside my Windows 10 v10.0.19042 virtual machine. I have created the shared memory device as per the wiki's instructions (no additional shared memory devices exist in the VM config) and installed the IVSHMEM drivers version 0.1.161. I verified the function of the device using the ivshmem-test.exe utility provided with the drivers.

Everytime I start the host application, it crashes after a few seconds without writing anything meaningful to the log files or any error message in the console output. Additionally In the Windows event logs, an error 1005 pops up.

Here is the log file from C:\Windows\Temp:

Startup Terminating the host application Host application terminated Finished Startup Terminating the host application Host application terminated Finished Startup Terminating the host application Host application terminated Finished Startup Terminating the host application Host application terminated Finished Startup Terminating the host application Host application terminated Finished

I also tried running it from the console, but nothing helpful there either:

4055159108 [I] app.c:421 | app_main | Looking for configuration file at: C:\Program Files\Looking Glass (host)\looking-glass-host.ini 4055159768 [I] app.c:425 | app_main | Configuration file not found or invalid

I tried running several older and newer versions, all showing the same behaviour, except for version B1-rc6-6-gb979752989+1, which, on one occasion, did in fact manage to write the following to C:\Users\admin\AppData\Local\Temp\looking-glass-host.txt:

[I] app.c:350 | app_main | Looking Glass Host (B1-rc6-6-gb979752989+1) [I] app.c:351 | app_main | IVSHMEM Size : 32 MiB [I] app.c:357 | app_main | IVSHMEM Address : 0x2CF0000 [I] app.c:366 | app_main | Max Cursor Size : 1 MiB [I] app.c:367 | app_main | Max Frame Size : 15 MiB [I] app.c:368 | app_main | Cursor : 0x2CF0080 (0x00000080) [I] app.c:374 | app_main | Frame 0 : 0x2DF0080 (0x00100080) [I] app.c:374 | app_main | Frame 1 : 0x3D70000 (0x01080000) [I] app.c:381 | app_main | Trying : NVFBC (NVidia Frame Buffer Capture) [E] wrapper.cpp:60 | NvFBCInit | Failed to load NvFBC64.dll: 0x0000007e (Das angegebene Modul wurde nicht gefunden.) [I] app.c:381 | app_main | Trying : DXGI [I] dxgi.c:322 | dxgi_init | Device Descripion: Radeon (TM) RX 480 Graphics [I] dxgi.c:323 | dxgi_init | Device Vendor ID : 0x1002 [I] dxgi.c:324 | dxgi_init | Device Device ID : 0x67df [I] dxgi.c:325 | dxgi_init | Device Video Mem : 8171 MiB [I] dxgi.c:326 | dxgi_init | Device Sys Mem : 0 MiB [I] dxgi.c:327 | dxgi_init | Shared Sys Mem : 8190 MiB [I] dxgi.c:328 | dxgi_init | Feature Level : 0xc000 [I] dxgi.c:329 | dxgi_init | Capture Size : 1920 x 1080 [I] dxgi.c:418 | dxgi_init | Source Format : DXGI_FORMAT_B8G8R8A8_UNORM [I] app.c:282 | captureStart | Using : DXGI [I] app.c:290 | captureStart | Capture Size : 7 MiB (8294400) [I] app.c:292 | captureStart | ==== [ Capture Start ] ==== [I] app.c:65 | pointerThread | Pointer thread started [I] app.c:160 | frameThread | Frame thread started [I] app.c:298 | captureRestart | ==== [ Capture Restart ] ==== [I] app.c:234 | frameThread | Frame thread stopped [I] app.c:154 | pointerThread | Pointer thread stopped [I] dxgi.c:322 | dxgi_init | Device Descripion: Radeon (TM) RX 480 Graphics [I] dxgi.c:323 | dxgi_init | Device Vendor ID : 0x1002 [I] dxgi.c:324 | dxgi_init | Device Device ID : 0x67df [I] dxgi.c:325 | dxgi_init | Device Video Mem : 8171 MiB [I] dxgi.c:326 | dxgi_init | Device Sys Mem : 0 MiB [I] dxgi.c:327 | dxgi_init | Shared Sys Mem : 8190 MiB [I] dxgi.c:328 | dxgi_init | Feature Level : 0xc000 [I] dxgi.c:329 | dxgi_init | Capture Size : 1920 x 1080 [I] dxgi.c:418 | dxgi_init | Source Format : DXGI_FORMAT_B8G8R8A8_UNORM [I] app.c:282 | captureStart | Using : DXGI [I] app.c:290 | captureStart | Capture Size : 7 MiB (8294400) [I] app.c:292 | captureStart | ==== [ Capture Start ] ==== [I] app.c:65 | pointerThread | Pointer thread started [I] app.c:160 | frameThread | Frame thread started [I] app.c:350 | app_main | Looking Glass Host (B1-rc6-6-gb979752989+1) [I] app.c:351 | app_main | IVSHMEM Size : 32 MiB [E] platform.c:379 | os_shmemMmap | DeviceIoControl Failed: 0x00000224 (Es wurde versucht, eine Verbindung mit einem Gerät herzustellen, das bereits eine Verbindung mit einem anderen Gerät unterhält.) [E] app.c:354 | app_main | Failed to map the shared memory [I] app.c:350 | app_main | Looking Glass Host (B1-rc6-6-gb979752989+1) [I] app.c:351 | app_main | IVSHMEM Size : 32 MiB [I] app.c:357 | app_main | IVSHMEM Address : 0x2C40000 [I] app.c:366 | app_main | Max Cursor Size : 1 MiB [I] app.c:367 | app_main | Max Frame Size : 15 MiB [I] app.c:368 | app_main | Cursor : 0x2C40080 (0x00000080) [I] app.c:374 | app_main | Frame 0 : 0x2D40080 (0x00100080) [I] app.c:374 | app_main | Frame 1 : 0x3CC0000 (0x01080000) [I] app.c:381 | app_main | Trying : NVFBC (NVidia Frame Buffer Capture) [E] wrapper.cpp:60 | NvFBCInit | Failed to load NvFBC64.dll: 0x0000007e (Das angegebene Modul wurde nicht gefunden.) [I] app.c:381 | app_main | Trying : DXGI [I] dxgi.c:322 | dxgi_init | Device Descripion: Radeon (TM) RX 480 Graphics [I] dxgi.c:323 | dxgi_init | Device Vendor ID : 0x1002 [I] dxgi.c:324 | dxgi_init | Device Device ID : 0x67df [I] dxgi.c:325 | dxgi_init | Device Video Mem : 8171 MiB [I] dxgi.c:326 | dxgi_init | Device Sys Mem : 0 MiB [I] dxgi.c:327 | dxgi_init | Shared Sys Mem : 8190 MiB [I] dxgi.c:328 | dxgi_init | Feature Level : 0xc000 [I] dxgi.c:329 | dxgi_init | Capture Size : 1920 x 1080 [I] dxgi.c:418 | dxgi_init | Source Format : DXGI_FORMAT_B8G8R8A8_UNORM [I] app.c:282 | captureStart | Using : DXGI [I] app.c:290 | captureStart | Capture Size : 7 MiB (8294400) [I] app.c:292 | captureStart | ==== [ Capture Start ] ==== [I] app.c:65 | pointerThread | Pointer thread started [I] app.c:160 | frameThread | Frame thread started [I] app.c:350 | app_main | Looking Glass Host (B1-rc6-6-gb979752989+1) [I] app.c:351 | app_main | IVSHMEM Size : 32 MiB [I] app.c:357 | app_main | IVSHMEM Address : 0x2CD0000 [I] app.c:366 | app_main | Max Cursor Size : 1 MiB [I] app.c:367 | app_main | Max Frame Size : 15 MiB [I] app.c:368 | app_main | Cursor : 0x2CD0080 (0x00000080) [I] app.c:374 | app_main | Frame 0 : 0x2DD0080 (0x00100080) [I] app.c:374 | app_main | Frame 1 : 0x3D50000 (0x01080000) [I] app.c:381 | app_main | Trying : NVFBC (NVidia Frame Buffer Capture) [E] wrapper.cpp:60 | NvFBCInit | Failed to load NvFBC64.dll: 0x0000007e (Das angegebene Modul wurde nicht gefunden.) [I] app.c:381 | app_main | Trying : DXGI [I] dxgi.c:322 | dxgi_init | Device Descripion: Radeon (TM) RX 480 Graphics [I] dxgi.c:323 | dxgi_init | Device Vendor ID : 0x1002 [I] dxgi.c:324 | dxgi_init | Device Device ID : 0x67df [I] dxgi.c:325 | dxgi_init | Device Video Mem : 8171 MiB [I] dxgi.c:326 | dxgi_init | Device Sys Mem : 0 MiB [I] dxgi.c:327 | dxgi_init | Shared Sys Mem : 8190 MiB [I] dxgi.c:328 | dxgi_init | Feature Level : 0xc000 [I] dxgi.c:329 | dxgi_init | Capture Size : 1920 x 1080 [I] dxgi.c:418 | dxgi_init | Source Format : DXGI_FORMAT_B8G8R8A8_UNORM [I] app.c:282 | captureStart | Using : DXGI [I] app.c:290 | captureStart | Capture Size : 7 MiB (8294400) [I] app.c:292 | captureStart | ==== [ Capture Start ] ==== [I] app.c:65 | pointerThread | Pointer thread started [I] app.c:160 | frameThread | Frame thread started [I] app.c:298 | captureRestart | ==== [ Capture Restart ] ==== [I] app.c:154 | pointerThread | Pointer thread stopped [I] app.c:234 | frameThread | Frame thread stopped [I] dxgi.c:322 | dxgi_init | Device Descripion: Radeon (TM) RX 480 Graphics [I] dxgi.c:323 | dxgi_init | Device Vendor ID : 0x1002 [I] dxgi.c:324 | dxgi_init | Device Device ID : 0x67df [I] dxgi.c:325 | dxgi_init | Device Video Mem : 8171 MiB [I] dxgi.c:326 | dxgi_init | Device Sys Mem : 0 MiB [I] dxgi.c:327 | dxgi_init | Shared Sys Mem : 8190 MiB [I] dxgi.c:328 | dxgi_init | Feature Level : 0xc000 [I] dxgi.c:329 | dxgi_init | Capture Size : 1920 x 1080 [I] dxgi.c:418 | dxgi_init | Source Format : DXGI_FORMAT_B8G8R8A8_UNORM [I] app.c:282 | captureStart | Using : DXGI [I] app.c:290 | captureStart | Capture Size : 7 MiB (8294400) [I] app.c:292 | captureStart | ==== [ Capture Start ] ==== [I] app.c:65 | pointerThread | Pointer thread started [I] app.c:160 | frameThread | Frame thread started [I] app.c:298 | captureRestart | ==== [ Capture Restart ] ==== [I] app.c:234 | frameThread | Frame thread stopped [I] app.c:154 | pointerThread | Pointer thread stopped [I] dxgi.c:322 | dxgi_init | Device Descripion: Radeon (TM) RX 480 Graphics [I] dxgi.c:323 | dxgi_init | Device Vendor ID : 0x1002 [I] dxgi.c:324 | dxgi_init | Device Device ID : 0x67df [I] dxgi.c:325 | dxgi_init | Device Video Mem : 8171 MiB [I] dxgi.c:326 | dxgi_init | Device Sys Mem : 0 MiB [I] dxgi.c:327 | dxgi_init | Shared Sys Mem : 8190 MiB [I] dxgi.c:328 | dxgi_init | Feature Level : 0xc000 [I] dxgi.c:329 | dxgi_init | Capture Size : 1920 x 1080 [I] dxgi.c:418 | dxgi_init | Source Format : DXGI_FORMAT_B8G8R8A8_UNORM [I] app.c:282 | captureStart | Using : DXGI [I] app.c:290 | captureStart | Capture Size : 7 MiB (8294400) [I] app.c:292 | captureStart | ==== [ Capture Start ] ==== [I] app.c:65 | pointerThread | Pointer thread started [I] app.c:160 | frameThread | Frame thread started [I] app.c:350 | app_main | Looking Glass Host (B1-rc6-6-gb979752989+1) [I] app.c:351 | app_main | IVSHMEM Size : 32 MiB [E] platform.c:379 | os_shmemMmap | DeviceIoControl Failed: 0x00000224 (Es wurde versucht, eine Verbindung mit einem Gerät herzustellen, das bereits eine Verbindung mit einem anderen Gerät unterhält.) [E] app.c:354 | app_main | Failed to map the shared memory [I] app.c:298 | captureRestart | ==== [ Capture Restart ] ==== [I] app.c:154 | pointerThread | Pointer thread stopped [I] app.c:234 | frameThread | Frame thread stopped [I] dxgi.c:322 | dxgi_init | Device Descripion: Radeon (TM) RX 480 Graphics [I] dxgi.c:323 | dxgi_init | Device Vendor ID : 0x1002 [I] dxgi.c:324 | dxgi_init | Device Device ID : 0x67df [I] dxgi.c:325 | dxgi_init | Device Video Mem : 8171 MiB [I] dxgi.c:326 | dxgi_init | Device Sys Mem : 0 MiB [I] dxgi.c:327 | dxgi_init | Shared Sys Mem : 8190 MiB [I] dxgi.c:328 | dxgi_init | Feature Level : 0xc000 [I] dxgi.c:329 | dxgi_init | Capture Size : 1920 x 1080 [I] app.c:350 | app_main | Looking Glass Host (B1-rc6-6-gb979752989+1) [I] app.c:351 | app_main | IVSHMEM Size : 32 MiB [E] platform.c:379 | os_shmemMmap | DeviceIoControl Failed: 0x00000224 (Es wurde versucht, eine Verbindung mit einem Gerät herzustellen, das bereits eine Verbindung mit einem anderen Gerät unterhält.) [E] app.c:354 | app_main | Failed to map the shared memory [I] dxgi.c:418 | dxgi_init | Source Format : DXGI_FORMAT_B8G8R8A8_UNORM [I] app.c:282 | captureStart | Using : DXGI [I] app.c:290 | captureStart | Capture Size : 7 MiB (8294400) [I] app.c:292 | captureStart | ==== [ Capture Start ] ==== [I] app.c:65 | pointerThread | Pointer thread started [I] app.c:160 | frameThread | Frame thread started [I] app.c:298 | captureRestart | ==== [ Capture Restart ] ==== [I] app.c:154 | pointerThread | Pointer thread stopped [I] app.c:234 | frameThread | Frame thread stopped [I] dxgi.c:322 | dxgi_init | Device Descripion: Radeon (TM) RX 480 Graphics [I] dxgi.c:323 | dxgi_init | Device Vendor ID : 0x1002 [I] dxgi.c:324 | dxgi_init | Device Device ID : 0x67df [I] dxgi.c:325 | dxgi_init | Device Video Mem : 8171 MiB [I] dxgi.c:326 | dxgi_init | Device Sys Mem : 0 MiB [I] dxgi.c:327 | dxgi_init | Shared Sys Mem : 8190 MiB [I] dxgi.c:328 | dxgi_init | Feature Level : 0xc000 [I] dxgi.c:329 | dxgi_init | Capture Size : 1920 x 1080 [I] app.c:350 | app_main | Looking Glass Host (B1-rc6-6-gb979752989+1) [I] app.c:351 | app_main | IVSHMEM Size : 32 MiB [E] platform.c:379 | os_shmemMmap | DeviceIoControl Failed: 0x00000224 (Es wurde versucht, eine Verbindung mit einem Gerät herzustellen, das bereits eine Verbindung mit einem anderen Gerät unterhält.) [E] app.c:354 | app_main | Failed to map the shared memory [I] dxgi.c:418 | dxgi_init | Source Format : DXGI_FORMAT_B8G8R8A8_UNORM [I] app.c:282 | captureStart | Using : DXGI [I] app.c:290 | captureStart | Capture Size : 7 MiB (8294400) [I] app.c:292 | captureStart | ==== [ Capture Start ] ==== [I] app.c:160 | frameThread | Frame thread started [I] app.c:65 | pointerThread | Pointer thread started

The interesting bit being:

[E] platform.c:379 | os_shmemMmap | DeviceIoControl Failed: 0x00000224 (Es wurde versucht, eine Verbindung mit einem Gerät herzustellen, das bereits eine Verbindung mit einem anderen Gerät unterhält.)

which literally translates to "The application tried to open a connection to a device which already has an active connection to a different device.".

I am actually not the first one running into this issue, here is a link to a thread on the Level1 forum . For that person, changing the VM's CPU config actually did the trick, but had no luck with that. Other things I tried include disabling huge pages and trying different bus and device ids for shared memory device, all to no avail.

In order to rule out issues with DXGI capture, I quickly testet OBS studio which seems to function properly.

My hardware configuration:

Let me know if you need any additional information. My apologies if this is in fact not a bug but a mistake on my side, but looking glass crashing before it even has a chance to write the log files does suggest a potential bug to me.

Thank you in advance.

gnif commented 3 years ago

Are you using Scream via IVSHMEM? If so this is your issue. If not, please tell me exactly which latest version just crashes (no logs) and post your VM configuration?

Necronom1con commented 3 years ago

I am not using Scream. I just tried a few other versions: B2-rc4 (crashing), B1-rc6 (not crashing) and B1 (also not crashing). I couldn't test the client applications though because they wouldn't compile without errors (even when removing the -Werror option).

Here is my VM config:

  <name>win10</name>
  <uuid>72d9cb03-6b73-41e1-8a85-071f99d61252</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/10"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit="KiB">16777216</memory>
  <currentMemory unit="KiB">16777216</currentMemory>
  <memoryBacking>
    <hugepages/>
  </memoryBacking>
  <vcpu placement="static">12</vcpu>
  <os>
    <type arch="x86_64" machine="pc-q35-4.2">hvm</type>
    <loader readonly="yes" type="pflash">/usr/share/OVMF/OVMF_CODE.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/win10_VARS.fd</nvram>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state="on"/>
      <vapic state="on"/>
      <spinlocks state="on" retries="8191"/>
    </hyperv>
    <vmport state="off"/>
  </features>
  <cpu mode="host-model" check="partial">
    <topology sockets="1" cores="6" threads="2"/>
  </cpu>
  <clock offset="localtime">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
    <timer name="hypervclock" present="yes"/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled="no"/>
    <suspend-to-disk enabled="no"/>
  </pm>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="qcow2"/>
      <source file="/var/lib/libvirt/images/win10-1.qcow2"/>
      <target dev="sda" bus="sata"/>
      <address type="drive" controller="0" bus="0" target="0" unit="0"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <target dev="sdb" bus="sata"/>
      <readonly/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    </disk>
    <controller type="usb" index="0" model="qemu-xhci" ports="15">
      <address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
    </controller>
    <controller type="sata" index="0">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
    </controller>
    <controller type="pci" index="0" model="pcie-root"/>
    <controller type="pci" index="1" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="1" port="0x10"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0" multifunction="on"/>
    </controller>
    <controller type="pci" index="2" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="2" port="0x11"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x1"/>
    </controller>
    <controller type="pci" index="3" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="3" port="0x12"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x2"/>
    </controller>
    <controller type="pci" index="4" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="4" port="0x13"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x3"/>
    </controller>
    <controller type="pci" index="5" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="5" port="0x14"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x4"/>
    </controller>
    <controller type="pci" index="6" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="6" port="0x8"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0" multifunction="on"/>
    </controller>
    <controller type="pci" index="7" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="7" port="0x9"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
    </controller>
    <controller type="pci" index="8" model="pcie-to-pci-bridge">
      <model name="pcie-pci-bridge"/>
      <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
    </controller>
    <controller type="pci" index="9" model="pcie-root-port">
      <model name="pcie-root-port"/>
      <target chassis="9" port="0xa"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x2"/>
    </controller>
    <controller type="pci" index="10" model="pci-bridge">
      <model name="pci-bridge"/>
      <target chassisNr="10"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x01" function="0x0"/>
    </controller>
    <controller type="pci" index="11" model="pci-bridge">
      <model name="pci-bridge"/>
      <target chassisNr="11"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x02" function="0x0"/>
    </controller>
    <controller type="pci" index="12" model="pci-bridge">
      <model name="pci-bridge"/>
      <target chassisNr="12"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x03" function="0x0"/>
    </controller>
    <controller type="pci" index="13" model="pci-bridge">
      <model name="pci-bridge"/>
      <target chassisNr="13"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x04" function="0x0"/>
    </controller>
    <controller type="pci" index="14" model="pci-bridge">
      <model name="pci-bridge"/>
      <target chassisNr="14"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x05" function="0x0"/>
    </controller>
    <controller type="pci" index="15" model="pci-bridge">
      <model name="pci-bridge"/>
      <target chassisNr="15"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x06" function="0x0"/>
    </controller>
    <controller type="pci" index="16" model="pci-bridge">
      <model name="pci-bridge"/>
      <target chassisNr="16"/>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x07" function="0x0"/>
    </controller>
    <controller type="virtio-serial" index="0">
      <address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
    </controller>
    <interface type="bridge">
      <mac address="52:54:00:e6:42:6b"/>
      <source bridge="br0"/>
      <model type="e1000e"/>
      <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0"/>
    </interface>
    <serial type="pty">
      <target type="isa-serial" port="0">
        <model name="isa-serial"/>
      </target>
    </serial>
    <console type="pty">
      <target type="serial" port="0"/>
    </console>
    <input type="mouse" bus="ps2"/>
    <input type="keyboard" bus="ps2"/>
    <input type="keyboard" bus="virtio">
      <address type="pci" domain="0x0000" bus="0x09" slot="0x00" function="0x0"/>
    </input>
    <graphics type="spice" autoport="yes">
      <listen type="address"/>
      <image compression="off"/>
      <gl enable="no" rendernode="/dev/dri/by-path/pci-0000:07:00.0-render"/>
    </graphics>
    <sound model="ich9">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x1b" function="0x0"/>
    </sound>
    <video>
      <model type="none"/>
    </video>
    <hostdev mode="subsystem" type="pci" managed="yes">
      <source>
        <address domain="0x0000" bus="0x10" slot="0x00" function="0x0"/>
      </source>
      <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
    </hostdev>
    <hostdev mode="subsystem" type="pci" managed="yes">
      <source>
        <address domain="0x0000" bus="0x14" slot="0x00" function="0x0"/>
      </source>
      <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
    </hostdev>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="2"/>
    </redirdev>
    <redirdev bus="usb" type="spicevmc">
      <address type="usb" bus="0" port="3"/>
    </redirdev>
    <memballoon model="virtio">
      <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/>
    </memballoon>
    <shmem name="looking-glass">
      <model type="ivshmem-plain"/>
      <size unit="M">32</size>
      <address type="pci" domain="0x0000" bus="0x08" slot="0x10" function="0x0"/>
    </shmem>
  </devices>
</domain>

EDIT: I just tried B2-rc1 - also crashing

gnif commented 3 years ago

Please edit your update and surround your config with backticks like so

``` Code ```

gnif commented 3 years ago

<gl enable="no" rendernode="/dev/dri/by-path/pci-0000:07:00.0-render"/>

This is not a VFIO passthrough VM, you're using Intel GVT-g, as such afaik you don't need LG, you can just use the libvirt spice viewer.

Necronom1con commented 3 years ago

It is in fact a VFIO passthrough VM, I am using my RX 480 inside of the VM.

This should be the passthrough config (one is for the GPU, the other for a USB card):

<hostdev mode="subsystem" type="pci" managed="yes">
  <source>
    <address domain="0x0000" bus="0x10" slot="0x00" function="0x0"/>
  </source>
  <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/>
</hostdev>
<hostdev mode="subsystem" type="pci" managed="yes">
  <source>
    <address domain="0x0000" bus="0x14" slot="0x00" function="0x0"/>
  </source>
  <address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
</hostdev>

GVT-g only works with Intel GPUs, but all GPUs in this system are AMD (including the onboard one). I think that line you mentioned is just a remnant of the virtual GPU that QEMU automatically added. I will try removing it to see if it causes the issue.

gnif commented 3 years ago

Can you please stop the LG service in Windows, and run it directly on the command like so and provide the output:

looking-glass-host.exe os:logFile=stderr

Necronom1con commented 3 years ago

I tried running LG B2 with .\looking-glass-host.exe os:logFile=stderr, but this is all I got:

PS C:\Program Files\Looking Glass (host)> .\looking-glass-host.exe os:logFile=stderr
PS C:\Program Files\Looking Glass (host)>    999815420 [I]                app.c:421  | app_main                       | Looking for configuration file at: C:\Program Files\Looking Glass (host)\looking-glass-host.ini
   999816017 [I]                app.c:425  | app_main                       | Configuration file not found or invalid

Nothing was written to the log files.

I also tried .\looking-glass-host.exe 2>&1 to send stderr to stdout, same output as above.

gnif commented 3 years ago

Please do this in command prompt, not powershell

Necronom1con commented 3 years ago

Still the same output. I just removed the Spice Display from the VM config, did not change anything.

Necronom1con commented 3 years ago

I think it's actually not LG crashing, it looks more like Windows is closing it for some reason. Here is the error message from the Event Viewer:

Windows cannot access the file  for one of the following reasons: there is a problem with the network connection, the disk that the file is stored on, or the storage drivers installed on this computer; or the disk is missing. Windows closed the program looking-glass-host.exe because of this error.

Program: looking-glass-host.exe
Necronom1con commented 3 years ago

I wanted to do some debugging, so I compiled the host application version B2 from the source code. For some reason, the pre-compiled binary crashes but when I compile it myself (directly in the VM following the instructions from the readme), it works, albeit with quite a siginificant performance impact (~15 fps less in FurMark, not sure if this is normal).

gnif commented 3 years ago

Perhaps your VM CPU doesn't support SSE 4.1, this is the minimum required. Also, windows defender might be preventing access, the host binary is often false flagged as a virus.

LG does have a performance impact, unfortunately, this can not be avoided.

Necronom1con commented 3 years ago

I just checked, my CPUs support SSE 4.2. The performance hit is only noticeable in GPU bound workloads (like FurMark), but over all it's running exceptionally well.

I have already tried disabling Windows Offender, but the pre-compiled binary still wouldn't run.

Anyway, it's working now. Whether this issue is worth investigating is for you to decide. If not, I will simply add this solution to the Thread on the Level1 forum.

Thank you for the support!

gnif commented 3 years ago

CPUs support SSE 4.2

Yes, but what does the guest CPU support? Run CPU-Z in the guest to see what extensions are available.

The performance hit is only noticeable in GPU bound workloads (like FurMark)

Correct, this is to be expected as we are using the GPU also after all :)

Necronom1con commented 3 years ago

According to CPU-Z, my guest CPU supports SSE 4.1 and SSE 4.2.

gnif commented 3 years ago

Strange, I would like to get to the root cause of this as it may affect others. Do you have any other AV software running, or enterprise protection suites?

Necronom1con commented 3 years ago

No. Only Windows Defender, which is also disabled.

Did you make any changes to the tool chain starting with B2-rc1? Because the pre-compiled binaries before this version do not crash.

gnif commented 3 years ago

The build server may have been upgraded, B2-rc1 was a long time ago now. The next step is to set up a build environment in Windows and run a debug build of the host under gdb to get a backtrace. (Or build a debug release under linux and run under gdb in windows).

Necronom1con commented 3 years ago

I have built the host application I'm running right now in Windows with backtrace enabled, but since it's working perfectly fine, I don't think the backtrace of that will be helpful.

I strongly suspect the problem is somewhere in your tool chain. Maybe you could provide me a debug build of the host binary, built on your build server, so I can provide a backtrace of the crash?

gnif commented 3 years ago

I have built the host application I'm running right now in Windows with backtrace enabled,

Windows backtrace is simply a stub, it's not implemented.

provide me a debug build of the host binary

Currently, it does not build one however this should change soon.

Necronom1con commented 3 years ago

I will try cross compiling it on Linux and see if that binary works.

EDIT: I used the exact commands from the build log, including x86_64-w64-mingw32-strip, it still works perfectly fine.

At this point, I have no idea what is actually going on.

Necronom1con commented 3 years ago

Another thing I just noticed, with the stripped version, I actually get better performance (~8 fps higher in FurMark), which is always nice :)

Necronom1con commented 3 years ago

I just tried installing B3-rc1 to see if it makes a difference, but the pre-compiled binary still crashes. At least it now manages to write something to C:\Windows\Temp\looking-glass-host-service.txt:

[2021-01-24 22:35:05] Startup
[2021-01-24 22:35:09] Host application exited with code 0xc000001d
[2021-01-24 22:35:09] Host application failed due to unknown error; restarting
[2021-01-24 22:35:12] Host application exited with code 0xc000001d
[2021-01-24 22:35:12] Host application failed due to unknown error; restarting
[2021-01-24 22:35:14] Host application exited with code 0xc000001d
[2021-01-24 22:35:14] Host application failed due to unknown error; restarting
...

I then compiled it from source on Ubuntu 20.04.1 LTS, following the procedure from the build log. The binary I compiled is not crashing. Unfortunately I couldn't test if it actually works because the corresponding client application crashes with the following error:

./looking-glass-client: symbol lookup error: ./looking-glass-client: undefined symbol: glEGLImageTargetTexture2DOES
gnif commented 3 years ago

Unfortunately I couldn't test if it actually works because the corresponding client application crashes with the following error

This is fixed for bleeding edge. Also, the bleeding edge host now has windows backtrace support, if you could please give the pre-compiled binary another go and then check the log it would be greatly appreciated.

Necronom1con commented 3 years ago

I gave the bleeding edge binary a try. It doesn't write anything meaningful to the log files, only this

[2021-01-27 20:59:49] Startup

in C:\Windows\Temp\looking-glass-host-service.txt. I tried running it from the command line, but no output there.

Here's the debug log straight from Visual Studio:

'looking-glass-host.exe' (Win32): Loaded 'C:\Program Files\Looking Glass (host)\looking-glass-host.exe'. Symbols loaded.
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\setupapi.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\cfgmgr32.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\dbghelp.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\dxgi.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\userenv.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\d3d11.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. 
The thread 0xfb4 has exited with code 0 (0x0).
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\SHCore.dll'. 
'looking-glass-host.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. 
Exception thrown at 0x00007FFCFFBCD759 (KernelBase.dll) in looking-glass-host.exe: 0x00000005: Access is denied.
Exception thrown at 0x0000000000415C02 in looking-glass-host.exe: 0xC000001D: Illegal Instruction.
Unhandled exception at 0x0000000000415C02 in looking-glass-host.exe: 0xC000001D: Illegal Instruction.

The program '[2560] looking-glass-host.exe' has exited with code 0 (0x0).

Here's the call stack:

looking-glass-host.exe!option_register() Line 115   C++
looking-glass-host.exe!WinMain() Line 223   C++
looking-glass-host.exe!__tmainCRTStartup() Line 341 C++
looking-glass-host.exe!WinMainCRTStartup() Line 197 C++
[External Code] 

As a sanity check, I compiled the host application myself once again and it works. At this point I'm almost certain, your build server is doing some funny business.

gnif commented 3 years ago

C:\Windows\Temp\looking-glass-host-service.txt

Wrong file, what about looking-glass-host.txt?

Necronom1con commented 3 years ago

This is the only file that is created.

gnif commented 3 years ago

0xC000001D: Illegal Instruction.

As suspected it is trying to use a CPU instruction that is not valid on your system.

looking-glass-host.exe!option_register() Line 115

This is simply a memcpy, which is likely being accelerated using intrinsics. Can you please post a screenshot of CPU-Z?

Necronom1con commented 3 years ago

Here's the screenshot: cpu_z

Did you enable any additional optimizations that are not specified in the cmake file?

gnif commented 3 years ago
  9 option(OPTIMIZE_FOR_NATIVE "Build with -march=native" ON)
 10 if(OPTIMIZE_FOR_NATIVE)
 11   CHECK_C_COMPILER_FLAG("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
 12   if(COMPILER_SUPPORTS_MARCH_NATIVE)
 13     add_compile_options("-march=native")
 14   endif()
 15 endif()

This means, use the extensions available on the local system's CPU at compile time, this is the default. For the binary distributed clearly this needs to be fixed, and based on the feature set we are using westmere seems to be the appropriate value, however for maximum compatibility I will set it to use nehalem.

gnif commented 3 years ago

That commit should have fixed it, if not please let me know and I will re-open this issue.

Necronom1con commented 3 years ago

So, from now on, the pre-compiled binary will be compiled for Nehalem or newer? This will probably cost a bit of performance on newer CPUs, but at least there won't be compatibility issues in the future (maybe add something to wiki about compiling it yourself for really old CPUs).

I will test it as soon as the updated binary is online.

gnif commented 3 years ago

This will probably cost a bit of performance on newer CPUs, but at least there won't be compatibility issues in the future (maybe add something to wiki about compiling it yourself for really old CPUs).

It will be so minor it wouldn't even show up in benchmarks as we were already using intrinsics for SSE 4.1 for the performant memory copies. Anything older than nehalem won't work at all.

Necronom1con commented 3 years ago

Ok. I just installed the new commit and it works!

Thank you for the support.