https://bugs.kde.org/show_bug.cgi?id=489219

            Bug ID: 489219
           Summary: KWin sometimes seems to return zero-byte FDs for
                    keymaps
    Classification: Plasma
           Product: kwin
           Version: 6.0.5
          Platform: NixOS
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: wayland-generic
          Assignee: kwin-bugs-n...@kde.org
          Reporter: ad...@cryto.net
  Target Milestone: ---

***
If you're not sure this is actually a bug, instead post about it at
https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see
https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY

I'm currently developing a Wayland protocol implementation (not using
libwayland) with Node.js, and am running into an issue where for the
`wl_keyboard#keymap` event I frequently receive an FD that seems to contain no
content (trying to read it returns zero bytes), despite the event claiming that
it's 64798 bytes long.

On one occasion I *did* receive actual keymap data of the correct length,
suggesting that the code on my end is not *fundamentally* broken, and is able
to read out FDs correctly. Since this successful read happened on the first run
of my testing code after a KWin crash-and-restart, and failed on every
subsequent run, my suspicion is that there's some state somewhere that's
getting corrupted in some way. Since my testing code is currently stateless,
that state could not be on my side.

There *was* what seems like a bug in my code (the documentation on Wayland does
not seem to specify this either way), in that it failed to close FDs that it
received previously, and it is possible that this is what triggered the bug on
the KWin side. Fixing the bug on my side has not resolved the issue of
zero-length files on subsequent runs in the same existing KWin session (I am
testing directly against my development system's Wayland session).

STEPS TO REPRODUCE
1. Connect Wayland client to KWin
2. Bind to `wl_seat` global and `get_keyboard`
3. Wait for the `wl_keyboard#keymap` event to be emitted
4. Try to read the included FD to completion

OBSERVED RESULT

An empty Buffer (ie. string of bytes) resulting from the FD read, despite the
`size` attribute claiming 64798 bytes, and the `format` claiming to be
`xkb_v1`.

EXPECTED RESULT

Either the keymap data (if one is available, which seems to be the case), or a
`size` attribute of 0 bytes (if not).

SOFTWARE/OS VERSIONS
Linux/KDE Plasma:
(available in About System)
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.1

ADDITIONAL INFORMATION

It's difficult to provide a minimal testcase, as there's an entire
as-of-yet-unpublished in-progress protocol implementation involved - if a
testcase is wanted, please let me know what the desired shape is. For
completeness, my implementation uses jhs67's USocket library due to missing
FD-sending support in Node.js core, but a reduced testcase of just USocket
talking to another instance of itself could not replicate the empty-reads issue
- it only seems to happen when talking to Kwin.

I have not tested against other compositors. I have also not gotten around to
testing other parts of the protocol that involve FDs, so I don't know if this
is specific to keymaps. I also cannot fully rule out an issue on my side, but
I've run out of potential causes that I can think of, especially because of the
successful read that happened once.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to