Skip to content

fix: use lossy UTF-8 conversion for device sysname to avoid panic#98

Open
neuralbroker wants to merge 1 commit into
Smithay:masterfrom
neuralbroker:master
Open

fix: use lossy UTF-8 conversion for device sysname to avoid panic#98
neuralbroker wants to merge 1 commit into
Smithay:masterfrom
neuralbroker:master

Conversation

@neuralbroker

Copy link
Copy Markdown

The sysname() method used to_str().expect() which panics when a USB device's kernel sysname contains non-UTF-8 bytes. Use to_string_lossy() instead, matching the behavior of the name() method.

Fixes pop-os/cosmic-epoch#2105 where cosmic-comp crashes with:
Device sysname is no valid utf8: Utf8Error { valid_up_to: 126, error_len: Some(1) }

The sysname() method used to_str().expect() which panics when a USB
device's kernel sysname contains non-UTF-8 bytes (e.g. certain USB
microphones with corrupted manufacturer strings). Use to_string_lossy()
instead, matching the behavior of the name() method.

Fixes pop-os/cosmic-epoch#2105 where cosmic-comp crashes with:
'Device sysname is no valid utf8: Utf8Error { valid_up_to: 126, error_len: Some(1) }'
@PolyMeilex

PolyMeilex commented Jun 8, 2026

Copy link
Copy Markdown
Member

Can you prove that this is indeed true? That string is most likely controlled by the kernel or udev rather than by the device.

The linked issue describes a different problem, the panic log you provide does not align with the one in that issue, what's the source of it?

Something similar to running libinput debug-events and getting a dump of its outputs should be enough to prove that the described device can indeed control its sysname string. Alternatively, one can also dump /sys/class/input/, /sys/class/sound/, etc. contents to prove that one of the files there contains a non-ascii filename.

@neuralbroker

Copy link
Copy Markdown
Author

Ill check on that once again3daf7a4c4056a6464ff46f13fcbefd32.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] System crashes when an USB microphone is plugged-in

2 participants