Xpra-org / xpra

Persistent remote applications for X11; screen sharing for X11, MacOS and MSWindows.
https://xpra.org/
GNU General Public License v2.0
1.99k stars 169 forks source link

Xpra 6.2 crashes on client connect #4389

Closed janLo closed 1 month ago

janLo commented 1 month ago

Describe the bug Since xpra 6.2 the server constantly disconnects a newly connected client due to an internal exception.

It seems that the xdg-menu-handling is somehow broken:

2024-10-14 11:06:29,986 Error in worker thread processing item <bound method MenuProvider.got_menu_data of <xpra.server.menu_provider.MenuProvider object at 0x7f2773524630>>
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/server/background_worker.py", line 74, in run
    item()
  File "/usr/lib/python3/dist-packages/xpra/server/menu_provider.py", line 173, in got_menu_data
    cb(self.menu_data)
  File "/usr/lib/python3/dist-packages/xpra/server/mixins/child_command.py", line 183, in send_updated_menu
    self.do_send_xdg_menu_data(source, xdg_menu)
  File "/usr/lib/python3/dist-packages/xpra/server/mixins/child_command.py", line 178, in do_send_xdg_menu_data
    log(f"{len(xdg_menu)} menu data entries sent to {ss}")
           ^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()
2024-10-14 11:06:29,987 Error: error in network packet write/format
2024-10-14 11:06:29,988  invalid None value in 'setting-change' packet at index 2
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/xpra/net/protocol/socket_handler.py", line 497, in write_format_thread_loop
    self._add_packet_to_queue(*gpc())
  File "/usr/lib/python3/dist-packages/xpra/net/protocol/socket_handler.py", line 513, in _add_packet_to_queue
    chunks: tuple[NetPacketType, ...] = tuple(self.encode(packet))
                                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/xpra/net/protocol/socket_handler.py", line 671, in encode
    raise TypeError(f"invalid None value in {packet_type!r} packet at index {i}")
TypeError: invalid None value in 'setting-change' packet at index 2

To Reproduce Steps to reproduce the behavior:

  1. server command: xpra start :100 --start-child=/bin/true --exit-with-children=no --daemon=no
  2. client command: xpra attach 'ssh://<host>/?display=100&ssh=ssh&opengl=no&session-name=workspace'
  3. specific action to trigger the bug: that's all.

System Information (please complete the following information):

Additional context Setting the (undocumented?) environment variable XPRA_EXPORT_MENU_DATA to false makes the issue go away.

janLo commented 1 month ago

~The issue also goes away if the package menu-xdg is installed in the system.~

:point_up: This workaround worked once but cannot be reproduced.

totaam commented 1 month ago

A default installation should have installed python-xdg: https://github.com/Xpra-org/xpra/blob/892f117437431fdd64607d93bd321df3c1b51b6f/packaging/debian/xpra/control#L137 https://github.com/Xpra-org/xpra/blob/892f117437431fdd64607d93bd321df3c1b51b6f/packaging/debian/xpra/control#L155-L156 Unfortunately, containers skip the recommended package dependencies.

6de9596660864436c59ff5700dc16b0199a0ba5e should fix this, it is trivial to apply by hand. You can also workaround this issue with --start-new-commands=no.

EgosOwn commented 1 month ago

I just want to note that i also get this exception with 6.2 but neither my server nor my client are running in a container. Both are installed from xpra's repos. Fedora 40 for client and Bookworm for server.

edit: Verified that the 66e69de commit fixes the problem.

janLo commented 1 month ago

Thank you for the fix. I do think, though, that the root cause must be different.

The python3-xdg package was already installed in the containers. Also, we did not see any of this kind of exception before the 6.2 update.

I would also expect to see this in the log file if the package was missing: https://github.com/Xpra-org/xpra/blob/master/xpra/platform/posix/menu_helper.py#L398

nakkaya commented 1 month ago

I am also having the same issue, running in a container with python3-xdg already installed. My latest build fails to connect with the same issue. Is the fix out for ubuntu (jammy) apt repo as well?

totaam commented 1 month ago

@janLo the (unfortunately) very common other way the load_xdg_menu_data method can fail is here: https://github.com/Xpra-org/xpra/blob/6de9596660864436c59ff5700dc16b0199a0ba5e/xpra/platform/posix/menu_helper.py#L457-L465 And should have printed a big warning about broken menus on Debian.

@nakkaya the bug fix has not hit the repos yet, making all the build variants takes many many days. Be patient.

totaam commented 1 month ago

Since many of you seem to be using xpra in containers, what's preventing you from using a distribution less buggy than Debian? So much hassle would be avoided - not just in this ticket.

EgosOwn commented 1 month ago

it is simply what the team i'm on used it for before i came around and it is simplest to stay on approximately the same environment. Ideally we'd move over to Nix or whatever, yes.

totaam commented 1 month ago

Ideally we'd move over to Nix or whatever, yes.

Better choose anything from Tier 1: https://github.com/Xpra-org/xpra/wiki/Platforms (as per this page, Debian and Ubuntu servers are Tier 3)

totaam commented 1 month ago

FYI: I have uploaded 6.2-r2 with this fix for most RPM distros just now, the Debian builds will take a few hours more. (bookworm is already done)

janLo commented 1 month ago

@janLo the (unfortunately) very common other way the load_xdg_menu_data method can fail is here:

https://github.com/Xpra-org/xpra/blob/6de9596660864436c59ff5700dc16b0199a0ba5e/xpra/platform/posix/menu_helper.py#L457-L465

And should have printed a big warning about broken menus on Debian. @nakkaya the bug fix has not hit the repos yet, making all the build variants takes many many days. Be patient.

I did not see this warning either in the logs. Actually no menu related warning was there, only the exception.

totaam commented 1 month ago

@janLo do the 6.2-r2 builds fix the issue for you?

janLo commented 1 month ago

Ideally we'd move over to Nix or whatever, yes.

Better choose anything from Tier 1: https://github.com/Xpra-org/xpra/wiki/Platforms (as per this page, Debian and Ubuntu servers are Tier 3)

What prevents me is years of pain with the RPM ecosystem.

Debian is just the right balance between stable enough and usable.

Nix would be an interesting option but sadly the system is completely broken when it comes to environments where you don't have a internet connection (we have an air-gapped environment with a package mirror for Debian).

janLo commented 1 month ago

@janLo do the 6.2-r2 builds fix the issue for you?

I'll test it as soon as I have a chance (probably tonight or tomorrow)

But the change looked reasonable.

totaam commented 1 month ago

What prevents me is years of pain with the RPM ecosystem.

I hear you. The dnf ongoing pain is not pretty. That said, the deb packaging tools are so kludgy, it's not funny.

Debian is just the right balance between stable enough and usable.

I used to believe that to be true, my deeper DEB packaging experience made me realize that "stable" has a different meaning in Debian-land, one that I fundamentally disagree with.

nakkaya commented 1 month ago

For me its similar, some of the software I rely on only supports Ubuntu.

janLo commented 1 month ago

@totaam 6.2-r2 fixes the problem here.

Regarding the debian-packaging I do agree if it comes to packaging python software. To be honest, I package python tooling lately only via dh_virtualenv ;)

But from a user's perspective, it's just the most works-for-me distribution. I'm using it on fleets of servers and all my managed end-user systems since 2006 and never felt the urge to look back to RPM-based distros ;)