Bug 293368 - Reads from timerfd return nonsense for a while
Summary: Reads from timerfd return nonsense for a while
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Jake Freeland
URL:
Keywords:
: 293709 293804 (view as bug list)
Depends on:
Blocks:
 
Reported: 2026-02-22 15:18 UTC by Gleb Popov
Modified: 2026-04-08 15:10 UTC (History)
12 users (show)

See Also:
jfree: mfc-stable15+
jfree: mfc-stable14+
vvd: needs_errata?


Attachments
Test program (705 bytes, text/plain)
2026-02-22 15:18 UTC, Gleb Popov
no flags Details
timerfd patch (1.05 KB, patch)
2026-03-06 05:17 UTC, Jake Freeland
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gleb Popov freebsd_committer freebsd_triage 2026-02-22 15:18:31 UTC
Created attachment 268274 [details]
Test program

While debugging a bug in KDE Plasma I managed to come up with a minified example that looks strange to me. The test program creates a timer fd and arms it so that it ticks once per minute. However, right after start the program is busy-looping in the poll loop, because reads from timer fd keep returning nonsensical values. After a while the problem goes away and the poll loop starts ticking once per minute.

Running the same program on Linux gives the garbage value only on first read, so no busy-looping there.

The test program is attached to the bug.
Comment 1 commit-hook freebsd_committer freebsd_triage 2026-03-05 12:16:44 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a9f8378e37f45046ee91f0f9ad660d8fb2b77663

commit a9f8378e37f45046ee91f0f9ad660d8fb2b77663
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2026-03-05 12:15:04 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2026-03-05 12:15:04 +0000

    KDE: Update KDE Plasma to 6.6.0

    Announcement: https://kde.org/announcements/plasma/6/6.6.0/

    The Digital Clock applet now uses timerfd(2) which may cause
    high CPU usage on FreeBSD due to bug [1]. As a workaround
    tweak Clock settings to not show seconds.

    Ports changes:

    graphics/plasma6-spectacle:
     - Require KQuickImageEditor

    security/plasma6-ksshaskpass:
     - Switch from KWallet to QtKeychain

    sysutils/plasma6-kinfocenter:
     - Add dependence on aha
     - pactl comes from pulseaudio, not pipewire
     - Replace ip with ifconfig [2]

    sysutils/plasma6-ksystemstats:
     - Backport upstream patch to enable network info on FreeBSD

    x11-themes/plasma6-aurorae:
     - Fix patch
     - Renew USE_KDE

    x11-toolkits/plasma6-kdeplasma-addons:
     - Drop stale dependencies

    x11-wm/plasma6-kwin:
     - Drop stale dependencies

    x11/plasma6-libkscreen:
     - Clean up Makefile

    x11/plasma6-plasma-workspace:
     - Drop stale dependencies
     - Drop stale cmake args

    PR:             293368 [1]
    PR:             285230 [2]

 Mk/Uses/kde.mk                                     |   2 +-
 audio/plasma6-kpipewire/distinfo                   |   6 +-
 audio/plasma6-ocean-sound-theme/distinfo           |   6 +-
 audio/plasma6-oxygen-sounds/distinfo               |   6 +-
 audio/plasma6-plasma-pa/distinfo                   |   6 +-
 deskutils/plasma6-milou/distinfo                   |   6 +-
 deskutils/plasma6-milou/pkg-plist                  |   7 +-
 deskutils/plasma6-sddm-kcm/Makefile                |   1 -
 deskutils/plasma6-sddm-kcm/distinfo                |   6 +-
 deskutils/plasma6-xdg-desktop-portal-kde/Makefile  |   1 -
 deskutils/plasma6-xdg-desktop-portal-kde/distinfo  |   6 +-
 devel/plasma6-kwrited/distinfo                     |   6 +-
 devel/plasma6-plasma-sdk/Makefile                  |   1 -
 devel/plasma6-plasma-sdk/distinfo                  |   6 +-
 devel/plasma6-plasma-sdk/pkg-plist                 |   1 +
 devel/plasma6-plasma5support/Makefile              |   1 -
 devel/plasma6-plasma5support/distinfo              |   6 +-
 devel/plasma6-plasma5support/pkg-plist             |  63 +++
 graphics/plasma6-spectacle/Makefile                |   4 +-
 graphics/plasma6-spectacle/distinfo                |   6 +-
 print/plasma6-print-manager/Makefile               |   1 -
 print/plasma6-print-manager/distinfo               |   6 +-
 print/plasma6-print-manager/pkg-plist              |   1 +
 security/plasma6-kscreenlocker/Makefile            |   1 -
 security/plasma6-kscreenlocker/distinfo            |   6 +-
 security/plasma6-kscreenlocker/pkg-plist           |   2 +
 security/plasma6-ksshaskpass/Makefile              |   6 +-
 security/plasma6-ksshaskpass/distinfo              |   6 +-
 security/plasma6-kwallet-pam/distinfo              |   6 +-
 sysutils/plasma6-discover/Makefile                 |   1 -
 sysutils/plasma6-discover/distinfo                 |   6 +-
 sysutils/plasma6-discover/pkg-plist                |   4 +
 sysutils/plasma6-kde-cli-tools/Makefile            |   1 -
 sysutils/plasma6-kde-cli-tools/distinfo            |   6 +-
 sysutils/plasma6-kde-cli-tools/pkg-plist           |   3 -
 sysutils/plasma6-kinfocenter/Makefile              |   6 +-
 sysutils/plasma6-kinfocenter/distinfo              |   6 +-
 .../plasma6-kinfocenter/files/patch-kcms_cpu (new) |  11 +
 .../files/patch-kcms_network (new)                 |  21 +
 sysutils/plasma6-kinfocenter/pkg-plist             |   2 +
 sysutils/plasma6-kmenuedit/Makefile                |   1 -
 sysutils/plasma6-kmenuedit/distinfo                |   6 +-
 sysutils/plasma6-knighttime/distinfo               |   6 +-
 sysutils/plasma6-ksystemstats/Makefile             |   1 -
 sysutils/plasma6-ksystemstats/distinfo             |   6 +-
 .../plasma6-ksystemstats/files/patch-network (new) | 245 ++++++++++++
 sysutils/plasma6-libksysguard/Makefile             |   1 -
 sysutils/plasma6-libksysguard/distinfo             |   6 +-
 sysutils/plasma6-libksysguard/pkg-plist            |   2 +
 sysutils/plasma6-plasma-disks/Makefile             |   1 -
 sysutils/plasma6-plasma-disks/distinfo             |   6 +-
 sysutils/plasma6-plasma-systemmonitor/Makefile     |   1 -
 sysutils/plasma6-plasma-systemmonitor/distinfo     |   6 +-
 sysutils/plasma6-plasma-systemmonitor/pkg-plist    |   1 +
 sysutils/plasma6-polkit-kde-agent-1/distinfo       |   6 +-
 sysutils/plasma6-powerdevil/Makefile               |   1 -
 sysutils/plasma6-powerdevil/distinfo               |   6 +-
 sysutils/plasma6-systemsettings/Makefile           |   1 -
 sysutils/plasma6-systemsettings/distinfo           |   6 +-
 www/plasma6-plasma-browser-integration/Makefile    |   1 -
 www/plasma6-plasma-browser-integration/distinfo    |   6 +-
 www/plasma6-plasma-browser-integration/pkg-plist   |   3 +
 x11-themes/plasma6-aurorae/Makefile                |   7 +-
 x11-themes/plasma6-aurorae/distinfo                |   6 +-
 x11-themes/plasma6-aurorae/pkg-plist               |   1 +
 x11-themes/plasma6-breeze-gtk/Makefile             |   1 -
 x11-themes/plasma6-breeze-gtk/distinfo             |   6 +-
 x11-themes/plasma6-breeze/distinfo                 |   6 +-
 x11-themes/plasma6-kde-gtk-config/distinfo         |   6 +-
 x11-themes/plasma6-oxygen/distinfo                 |   6 +-
 x11-themes/plasma6-oxygen/pkg-plist                |   2 -
 .../plasma6-plasma-workspace-wallpapers/distinfo   |   6 +-
 .../plasma6-plasma-workspace-wallpapers/pkg-plist  |   7 +
 x11-themes/plasma6-qqc2-breeze-style/distinfo      |   6 +-
 x11-toolkits/plasma6-kdeplasma-addons/Makefile     |   5 +-
 x11-toolkits/plasma6-kdeplasma-addons/distinfo     |   6 +-
 x11-toolkits/plasma6-kdeplasma-addons/pkg-plist    | 137 ++-----
 x11-wm/plasma6-kdecoration/distinfo                |   6 +-
 x11-wm/plasma6-kwin-x11/Makefile                   |   1 -
 x11-wm/plasma6-kwin-x11/distinfo                   |   6 +-
 x11-wm/plasma6-kwin-x11/pkg-plist                  |  31 +-
 x11-wm/plasma6-kwin/Makefile                       |   5 -
 x11-wm/plasma6-kwin/distinfo                       |   8 +-
 x11-wm/plasma6-kwin/pkg-plist                      |   7 +
 x11/plasma6-kactivitymanagerd/Makefile             |   1 -
 x11/plasma6-kactivitymanagerd/distinfo             |   6 +-
 x11/plasma6-kgamma/distinfo                        |   6 +-
 x11/plasma6-kglobalacceld/Makefile                 |   1 -
 x11/plasma6-kglobalacceld/distinfo                 |   6 +-
 x11/plasma6-kscreen/distinfo                       |   6 +-
 x11/plasma6-kscreen/pkg-plist                      |  24 +-
 x11/plasma6-kwayland/distinfo                      |   6 +-
 x11/plasma6-layer-shell-qt/distinfo                |   6 +-
 x11/plasma6-libkscreen/Makefile                    |   7 +-
 x11/plasma6-libkscreen/distinfo                    |   6 +-
 x11/plasma6-libkscreen/pkg-plist                   |   1 -
 x11/plasma6-libplasma/Makefile                     |   1 -
 x11/plasma6-libplasma/distinfo                     |   6 +-
 x11/plasma6-plasma-activities-stats/distinfo       |   6 +-
 x11/plasma6-plasma-activities/distinfo             |   6 +-
 x11/plasma6-plasma-desktop/Makefile                |   1 -
 x11/plasma6-plasma-desktop/distinfo                |   6 +-
 x11/plasma6-plasma-desktop/pkg-plist               | 116 +-----
 x11/plasma6-plasma-integration/Makefile            |   1 -
 x11/plasma6-plasma-integration/distinfo            |   6 +-
 x11/plasma6-plasma-workspace/Makefile              |   8 +-
 x11/plasma6-plasma-workspace/distinfo              |   6 +-
 x11/plasma6-plasma-workspace/pkg-plist             | 445 +++------------------
 108 files changed, 702 insertions(+), 822 deletions(-)
Comment 2 Jake Freeland freebsd_committer freebsd_triage 2026-03-06 05:17:45 UTC
Created attachment 268564 [details]
timerfd patch
Comment 3 Jake Freeland freebsd_committer freebsd_triage 2026-03-06 05:17:56 UTC
Hey Gleb,

Thanks for reporting this. I've attached a patch that I think should solve this issue. I'll do some testing and post a review tomorrow morning.

Thanks,
Jake
Comment 4 Max Brazhnikov freebsd_committer freebsd_triage 2026-03-06 10:01:17 UTC
(In reply to Jake Freeland from comment #2)
Thank you! This patch fixes the problem with Plasma clock. Tested on 15-stable.
Comment 5 Evgenii Khramtsov (Inactive) 2026-03-06 12:04:48 UTC
(In reply to Jake Freeland from comment #2)

Test program works fine on -CURRENT/amd64 here as well.
Comment 6 Gleb Popov freebsd_committer freebsd_triage 2026-03-07 15:41:39 UTC
I also confirm that the patch fixes the problem.

Jake, do you need someone with src commit bit to review and merge this into main?
Comment 7 Oleksandr Kryvulia 2026-03-07 18:34:59 UTC
My problem is also solved.

https://mail.kde.org/pipermail/kde-freebsd/2026-March/045916.html
Comment 8 Vladimir Druzenko freebsd_committer freebsd_triage 2026-03-09 17:12:08 UTC
stable/14 and stable/15 are affected too.
Comment 9 Jake Freeland freebsd_committer freebsd_triage 2026-03-10 00:58:03 UTC
Hi Gleb,

I have a commit bit (I was accidentally logged into my personal Bugzilla account), so I can commit when ready. 

I apologize for getting this out late. I started working on this simple patch and got pulled into the many other todos I had related to timerfd. I posted a series of reviews and tagged you as a reviewer.

The review targeting this specific bug is here: https://reviews.freebsd.org/D55791

Thanks
Comment 10 Jake Freeland freebsd_committer freebsd_triage 2026-03-10 01:00:15 UTC
Oops, accidentally linked the wrong review in the last comment. The review for this fix is here: https://reviews.freebsd.org/D55790
Comment 11 Mikael Urankar freebsd_committer freebsd_triage 2026-03-10 08:02:57 UTC
*** Bug 293709 has been marked as a duplicate of this bug. ***
Comment 12 Graham Perrin freebsd_committer freebsd_triage 2026-03-15 07:12:45 UTC
*** Bug 293804 has been marked as a duplicate of this bug. ***
Comment 13 Jake Freeland freebsd_committer freebsd_triage 2026-03-20 07:21:20 UTC
This has been fixed in https://reviews.freebsd.org/rG85c0f1a87da1fd1eb3e646e86f70e630c48da91a
Comment 14 Mark Johnston freebsd_committer freebsd_triage 2026-03-20 07:29:20 UTC
(In reply to Jake Freeland from comment #13)
Thank you, but I think these commits need to be MFCed to stable/15 too?
Comment 15 Gleb Popov freebsd_committer freebsd_triage 2026-03-20 08:17:03 UTC
(In reply to Mark Johnston from comment #14)
Ideally, we need an EN for that, because it severely affects the desktop usage.
Comment 16 Mark Johnston freebsd_committer freebsd_triage 2026-03-20 08:34:09 UTC
(In reply to Gleb Popov from comment #15)
This could be done, but in any case the first step will be an MFC.
Comment 17 Vladimir Druzenko freebsd_committer freebsd_triage 2026-03-20 10:07:58 UTC
To stable/14 too.
Comment 18 Jake Freeland freebsd_committer freebsd_triage 2026-03-23 21:52:23 UTC
Will re-comment here once they've been MFC'd. Thanks.
Comment 19 Graham Perrin 2026-03-25 06:56:28 UTC
Re: bug 293804 comment 2 from Denis Shaposhnikov

The workaround suggested at <https://forums.freebsd.org/posts/749200> is not, or no longer, effective for me on bugged systesms. 

Excessive use of CPU by plasmashell is not reproducible, by me, with FreeBSD 16.0-CURRENT as a VirtualBox guest following a pkgbase update to main-n284672-e6a77f81d1eb GENERIC-NODEBUG amd64, which includes base 85c0f1a87da1.

----

jfree@ would you like to close bug 293820 as a duplicate? 

The coincidental power management issue is spun of, away from Bugzilla for FreeBSD, at <https://mail.kde.org/pipermail/kde-freebsd/2026-March/046035.html>.
Comment 20 Jake Freeland freebsd_committer freebsd_triage 2026-03-26 00:35:57 UTC
Graham Perrin,

Have you confirmed this patch fixes that issue? If so, I think it can be marked as a duplicate of this report.

Thanks,
Jake
Comment 21 Graham Perrin 2026-03-26 02:31:52 UTC
I use pkgbase for updates (didn't need to build from source, with the patch). Bug 293820 comment 12 has a little more detail.
Comment 22 Thierry Thomas freebsd_committer freebsd_triage 2026-03-26 19:01:38 UTC
Upgrading my laptop to 16-CURRENT main-n284700-9b98c4b05391 fixed the plasmashell problem reported in PR 293709.
Comment 23 Jake Freeland freebsd_committer freebsd_triage 2026-04-03 15:35:24 UTC
Hi there,

MFC to stable/15 and stable/14 has been done.

stable/15:
https://cgit.freebsd.org/src/commit/?h=stable/15&id=9b785380f307e772eae0df017c982acd81d5879e

stable/14:
https://cgit.freebsd.org/src/commit/?h=stable/14&id=3c00f603a2801fd780666f9e94a26f264a887c90

Closing this. Feel free to re-open if anything else is needed. Thanks.
Comment 24 Vladimir Druzenko freebsd_committer freebsd_triage 2026-04-04 19:02:36 UTC
We need Errata Notices too for 15.0, 14.4 and 14.3: https://www.freebsd.org/security/notices/
Comment 25 Mark Johnston freebsd_committer freebsd_triage 2026-04-06 02:58:40 UTC
(In reply to Vladimir Druzenko from comment #24)
Can you or anyone else please provide some background on the impact of the bug, so we can fill out an errata template?  How does the bug manifest?
Comment 26 Max Brazhnikov freebsd_committer freebsd_triage 2026-04-06 09:56:21 UTC
(In reply to Mark Johnston from comment #25)
The only impact I'm aware of is 100% CPU usage by plasmashell process when running Plasma Desktop 6.6.0 and greater, which makes KDE user experience unpleasant to say at least:

https://cgit.freebsd.org/ports/commit/?id=a9f8378e37f45046ee91f0f9ad660d8fb2b77663
Comment 27 Maxnix 2026-04-06 10:54:31 UTC
(In reply to Mark Johnston from comment #25)
I wrote this post on FreeBSD Forums, don't know if could be useful:
https://forums.freebsd.org/threads/trying-to-run-kde-6-plasma-with-wayland.93951/post-748570
Comment 28 Mark Johnston freebsd_committer freebsd_triage 2026-04-08 08:01:23 UTC
Thanks, I am drafting an EN.

Is anyone able to confirm that commit 85c0f1a87da1 on its own is enough to fix the problems reported here?
Comment 29 Max Brazhnikov freebsd_committer freebsd_triage 2026-04-08 15:10:26 UTC
(In reply to Mark Johnston from comment #28)
I can confirm: I'm running 15-stable of git commit 6a1ebd14aa96 (a week before the fix has been MFCed to stable) with the only 85c0f1a87da1 merged and it solves the problem for me.