#1109970 upower crashes due to -NaN battery percentage from ACPI

Package:
upower
Source:
upower
Description:
abstraction for power management
Submitter:
Renkas Mykhailo
Date:
2026-07-02 11:07:05 UTC
Severity:
normal
Tags:
#1109970#5
Date:
2025-07-27 10:13:20 UTC
From:
To:
Dear Maintainer,

On systems with broken battery controllers, ACPI may report an invalid battery
capacity value, specifically `-NaN`. This causes `upowerd` to crash repeatedly
due to an invalid gdouble being passed to `g_object_set`.

This leads to system instability or continuous reboots due to repeated crashes
of systemd-managed services.

The following patch adds a basic sanity check to clamp invalid values to 0.0.
--- PATCH START ---
--- upower-1.90.3.orig/src/linux/up-device-supply.c
+++ upower-1.90.3/src/linux/up-device-supply.c
@@ -313,6 +313,11 @@ up_device_supply_refresh_device (UpDevic
 	if (percentage == 100.0)
 		state = UP_DEVICE_STATE_FULLY_CHARGED;

+	if (!isfinite(percentage) || percentage < 0.0 || percentage > 100.0) {
+		g_warning("Invalid percentage value: %f, setting to 0.0", percentage);
+		percentage = 0.0;
+	}
+
 	g_object_set (device,
 		      "percentage", percentage,
 		      "battery-level", level,
--- PATCH END ---

Tested on affected system; no crash occurs after patch is applied.

Regards,
Renkas Mykhailo

#1109970#10
Date:
2025-07-27 13:17:55 UTC
From:
To:
Hi

Am 27.07.25 um 12:13 schrieb Renkas Mykhailo:

It would be great if you can submit a merge request upstream at
https://gitlab.freedesktop.org/upower/upower

We avoid applying patches downstream as much as possible, especially if
the issue is not Debian specific.

Regards,
Michael

#1109970#15
Date:
2025-07-27 17:45:37 UTC
From:
To:
Hi

I agree with Michael, and would actually suggest opening an issue
instead of a pull request, so the problem can be investigated properly.

Incidentally, this code should only run for powered peripherals, not the
system power supply. So it should most likely not be triggered by ACPI,
buggy or not. As a result, I do not expect upower folk to merge the
patch as is. While it would seem to be working, it is likely masking a
bigger issue that warrants a proper fix, perhaps even outside upower
itself, e.g. kernel.

Sincerely,
Sicelo

#1109970#20
Date:
2025-07-28 21:26:40 UTC
From:
To:
Hi

Am 27.07.25 um 19:45 schrieb Sicelo:

Thanks a lot for your input, Sicelo!
Your suggestion to open an issue first is indeed a reasonable one.

As I expect follow-up questions, it is best if you do that directly
Renkas, as I can't reproduce the issue myself given it's hardware specific.

I'm tentatively removing the patch tag

Regards,
Michael

#1109970#27
Date:
2026-05-10 22:04:57 UTC
From:
To:
Hi Renkas, Michael,

There appears to be a fix that landed in v1.91.1 of upower (the bugfix has git
commit ID 988624350b5c29818c0ee0114f16ace011767165) to resolve upower crashes
due to this NaN issue:

https://gitlab.freedesktop.org/upower/upower/-/merge_requests/306

However: see also Debian bug #1114796; it describes excessive log output and
seems similar/related.  Those log messages continue to appear on my affected
system running v1.91.2 of upowerd.

Regards,
James

#1109970#32
Date:
2026-07-02 11:05:16 UTC
From:
To:
Version: 1.19.1-1

Thanks, closing this particular bug report for this version.

Michael