Skip to content

logger: Add an early call to g_ascii_strtoull() to avoid a GLib bug

Simon McVittie requested to merge wip/task481 into main

There is a difficult-to-reproduce failure mode in which g_ascii_string_to_unsigned() can fail to parse a valid integer, which was causing our tests to fail (but only on i386 and only in a specific non-interactive build environment). As far as I can make out, this is an error-handling issue in the way g_ascii_string_to_unsigned() calls g_ascii_strtoull(): if newlocale() clobbers errno (which it is within its rights to do, according to the usual errno conventions), then g_ascii_strtoull() would interpret that as a strtoull_l() failure.

We can work around this by ensuring that our first call to g_ascii_strtoull() is one that doesn't matter, so that by the time we actually call g_ascii_string_to_unsigned(), the cached C locale object inside GLib has already been initialized.

steamrt/tasks#481


Successful workaround for https://gitlab.gnome.org/GNOME/glib/-/issues/3418

/cc @refi64 @denittis

Merge request reports