31432 Commits

Author SHA1 Message Date
Philip Withnall
2cee7809d1 Merge branch 'main' into 'main'
Update Georgian translation

See merge request GNOME/glib!4511
2025-02-25 14:47:46 +00:00
Philip Withnall
f8341632fe
tests: Only change the behaviour of getpwuid() inside each test function
The `gutils-user-database` test uses `LD_PRELOAD` to load
`getpwuid-preload.so`, which contains overrides for `getpwuid()`,
`getpwnam_r()` and `getpwuid_r()`. These overrides clear the `pw_name`
field to `NULL` to test handling of a weird error case from an old
systemd implementation of those functions (see !2244).

When running the `G_DISABLE_ASSERT` CI job, this test was crashing
without any debugging output. The `G_DISABLE_ASSERT` CI job runs its
tests under `--setup thorough`, which was the culprit here: the function
overrides in `getpwuid-preload.so` were being loaded (via `LD_PRELOAD`)
into the `bash` process which runs `thorough-test-wrapper.sh` and
causing it to crash.

Interestingly, this couldn’t be reproduced locally with a comparable
version of bash. Perhaps it depends on the CI machine’s environment,
triggering bash to make a `getpwuid()` (or similar) call which it
wouldn’t normally do locally.

So, slightly change `getpwuid-preload.so` to additionally link to
`libglib-2.0.so` and query `g_test_get_path()` to work out whether it’s
being called inside a unit test. If not, don’t modify the return value.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #3272
2025-02-25 11:42:52 +00:00
Philip Withnall
1438e1c12e Merge branch 'translation' into 'main'
Update Chinese translation

See merge request GNOME/glib!4518
2025-02-25 09:44:59 +00:00
lumingzh
74ec63e29e update Chinese translation 2025-02-25 01:16:33 +00:00
Philip Withnall
3f323fe94f Merge branch 'main' into 'main'
doc: point to iconv(3) and iconv(3posix) for more details about iconv

See merge request GNOME/glib!4515
2025-02-25 00:56:09 +00:00
Reuben Thomas
5fc4248b74 doc: point to iconv(3) and iconv(3posix) for more details about iconv
The documentation in GLib of iconv is forgivably brief. Advanced users (e.g.
for streaming use, for which this API is recommended over the simpler GLib
APIs) will want to know more detail about what happens when there’s an
error: without knowing, you can’t really use this function for streaming.

Point to both iconv(3posix), which gives the fully-portable details, i.e.
all that a user of GLib can rely on, and iconv(3), which is rather easier to
read, and may be of interest to those writing GNU-specific code, or who know
that their GLib is built with libiconv.

The API already promises that it’s the “[s]ame as the standard UNIX routine
iconv()”, so it’s quite safe to point to the relevant man pages; looking at
the source code bears this out, as g_iconv merely calls iconv.
2025-02-25 00:56:07 +00:00
Philip Withnall
87dfae2246 Merge branch 'update_uk1' into 'main'
Update Ukrainian translation

See merge request GNOME/glib!4514
2025-02-24 23:54:57 +00:00
Philip Withnall
a0c5f5a9fb Merge branch 'main' into 'main'
Update Bulgarian translation

See merge request GNOME/glib!4516
2025-02-24 23:54:47 +00:00
Philip Withnall
f49674d4fd Merge branch 'Persian' into 'main'
Update file fa.po

See merge request GNOME/glib!4517
2025-02-24 23:50:50 +00:00
Philip Withnall
d9cd99f9b4 Merge branch 'th/gobject-inline-private-call' into 'main'
[th/gobject-inline-private-call] gobject: avoid GLIB_PRIVATE_CALL() for g_datalist_id_update_atomic

See merge request GNOME/glib!4513
2025-02-24 23:47:22 +00:00
Danial Behzadi
33528d2e8c Update file fa.po 2025-02-24 20:34:41 +00:00
Alexander Shopov
5b4d8c28ab Update Bulgarian translation
Originally from https://l10n.gnome.org/vertimus/glib/main/po/bg/
2025-02-24 21:07:22 +01:00
Thomas Haller
482e078083 gobject: avoid GLIB_PRIVATE_CALL() for g_datalist_id_update_atomic()
Cache the function pointer for g_datalist_id_update_atomic() in a static
variable in "gobject.c" to avoid looking it up repeatedly.

g_datalist_id_update_atomic() is anyway internal API. Like GData is not
a useful data structure in general, this function is only useful for
something specific inside GObject.

It can be easily seen that _local_g_datalist_id_update_atomic is never
read without having a GObject at hand (because we call it on
`&object->qdata`). Thus initializing the pointer in
g_object_do_class_init() (under lock) is sufficient to ensure
thread-safe initialization. Note that we still set the pointer via
g_atomic_pointer_set(). This is done in an attempt to pacify thread
sanatizer.

Note that also with LTO enabled, the GLIB_PRIVATE_CALL() call cannot be
inlined. Previously we get:

0000000000011300 <_weak_ref_set>:
   ...
   1131d:       e8 ee 03 ff ff          call   1710 <glib__private__@plt>
   11322:       8b 35 0c b2 05 00       mov    0x5b20c(%rip),%esi        # 6c534 <quark_weak_locations.lto_priv.0>
   11328:       4c 89 e1                mov    %r12,%rcx
   1132b:       49 8d 7c 24 10          lea    0x10(%r12),%rdi
   11330:       48 8d 15 b9 42 ff ff    lea    -0xbd47(%rip),%rdx        # 55f0 <weak_ref_data_get_or_create_cb.lto_priv.0>
   11337:       ff 90 80 00 00 00       call   *0x80(%rax)

afterwards:

0000000000011300 <_weak_ref_set>:
   ...
   1131d:       48 8d 7e 10             lea    0x10(%rsi),%rdi
   11321:       48 89 f1                mov    %rsi,%rcx
   11324:       48 8d 15 c5 42 ff ff    lea    -0xbd3b(%rip),%rdx        # 55f0 <weak_ref_data_get_or_create_cb.lto_priv.0>
   1132b:       8b 35 0b b2 05 00       mov    0x5b20b(%rip),%esi        # 6c53c <quark_weak_locations.lto_priv.0>
   11331:       ff 15 f9 b1 05 00       call   *0x5b1f9(%rip)        # 6c530 <_local_g_datalist_id_update_atomic.lto_priv.0>

Also note, that the point here is not to optimize _weak_ref_set() (which
is not a hot path). There is work in progress that will use
g_datalist_id_update_atomic() for more purposes (and during more
relevant code paths of GObject).
2025-02-24 17:41:18 +01:00
Yuri Chornoivan
c61a489bcc Update Ukrainian translation 2025-02-24 14:14:22 +00:00
Philip Withnall
7436b8056d Merge branch 'main' into 'main'
doc: Simplify instructions for testing with Automake

See merge request GNOME/glib!4510
2025-02-23 21:55:43 +00:00
Philip Withnall
2910f4b31a Merge branch 'cs-update' into 'main'
Update Czech translation

See merge request GNOME/glib!4512
2025-02-23 21:49:46 +00:00
AsciiWolf
3850646ed2 Update Czech translation 2025-02-23 17:38:26 +01:00
NorwayFun
e2463a846f Update Georgian translation 2025-02-23 06:39:18 +00:00
Philip Withnall
97bd09a04f Merge branch 'wip/smcv/girxml-search-path' into 'main'
tests: Search the appropriate directories for our GIR XML inputs

See merge request GNOME/glib!4509
2025-02-22 14:42:36 +00:00
Reuben Thomas
7804f13d26 doc: Simplify instructions for testing with Automake
This documentation used to link to GLib’s TAP harness. However, the built-in
Automake support works fine, and is simpler to use. Hence, remove most of
the old documentation, and refer users to the Automake manual, adding just
one hint for use with GLib.
2025-02-22 14:34:34 +02:00
Simon McVittie
2c358ec7f8 build: Factor out a variable for the GIR XML directory suffix
Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-21 20:12:48 +00:00
Simon McVittie
9f18bb6258 tests: Search the appropriate directories for our GIR XML inputs
During "as-installed" testing, we should search the GIR_DIR for GIR XML,
instead of hard-coding that it is `${prefix}/share/gir-1.0`. This is
not the case on at least Debian, in order to make it possible to
install more than one architecture's flavour of `GLib-2.0.gir`,
which contains some architecture-specific `#define`s.

Also search GOBJECT_INTROSPECTION_DATADIR/GIR_SUFFIX (in practice
something like `/usr/share/gir-1.0` in all cases) to accommodate
distributions like Debian that move the architecture-independent
majority of GIR XML into /usr/share to avoid duplication, leaving
only the architecture-specific minority of files like `GLib-2.0.gir`
in the GIR_DIR.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-21 16:40:47 +00:00
Simon McVittie
135850a534 tests: Reformat gi-compile-repository.py according to black(1)
Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-21 16:05:43 +00:00
Philip Withnall
05c7f11306 Merge branch 'th/datalist-update-atomic-no-keyid' into 'main'
[th/datalist-update-atomic-no-keyid] gdataset: drop "key_id" argument from GDataListUpdateAtomicFunc

See merge request GNOME/glib!4508
2025-02-21 15:30:25 +00:00
Thomas Haller
6ce489bf83 gdataset: drop "key_id" argument from GDataListUpdateAtomicFunc
None of the users actually care about this parameter. And it's unlikely
that they ever will. Also, the passed "key_id" is the argument from
g_datalist_id_update_atomic(). If the caller really cared to know the
"key_id" in the callback, they could pass it as additional user data.
2025-02-21 15:24:51 +01:00
Philip Withnall
b4224a5d6d Merge branch 'th/gdataset-misc' into 'main'
[th/gdataset-misc] minor improvements in gdataset.c (around g_datalist_id_remove_multiple())

See merge request GNOME/glib!4507
2025-02-21 12:47:57 +00:00
Thomas Haller
70623887ad gdataset: avoid initializing "out_idx" if datalist_find() fails
In some sense, it might be desirable to always initialize out parameters
to something.

However, this fallback index G_MAXUINT32 is not really useful for any
caller. That is, no caller can blindly access the index without checking
whether datalist_find() found (and returned) an entry.

Also, a caller cannot check for whether a entry was found via `if (idx
== G_MAXUINT32)`, because that theoretically is also a valid index.

The only sensible way to use datalist_find() is by accessing "idx"
if-and-only-if an entry was found. And all callers did that.

There is no point for initializing the value.

Uninitialized values can be even preferable over a non-useful
initialization to G_MAXUINT32, because if there is a buggy access them
under valgrind, there will be at least a warning.
2025-02-21 11:09:29 +01:00
Thomas Haller
3024d9b47e gdataset: remove/inline internal function g_data_remove_internal()
This internal function only had one caller. Drop it.
2025-02-21 11:09:29 +01:00
Thomas Haller
82977db352 gdataset/trivial: adjust obsolte code comment
The code comment was no longer correct. g_data_remove_internal() does
not depend on this anymore. It also just calls datalist_find(), which
searches the entire list.
2025-02-21 10:00:45 +01:00
Thomas Haller
76d77d1cab gdataset: avoid initializing temporary array with NULL in g_data_remove_internal()
The code comment was correct in the past, and how the code was then we
had to ensure the array is initialized.

This is no longer the case. We will only access the array at the indexes
from zero to up to (found_keys-1). And those places get always
initialized before we use them (as we increment found_keys at the same
time).

There is no longer a need to initialize this array to zero. Drop this.

Fixes: 3437414dd4f7 ('gdataset: use lookup index in g_datalist_id_remove_multiple()')
2025-02-21 09:55:26 +01:00
Philip Withnall
e35c796e62
2.83.4
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2.83.4
2025-02-20 12:37:13 +00:00
Philip Withnall
c753d26b84 Merge branch 'wip/smcv/gdbus-clear-signal' into 'main'
gdbus: Add g_clear_dbus_signal_subscription() inline convenience function

See merge request GNOME/glib!4493
2025-02-20 00:48:33 +00:00
Simon McVittie
030fbca6c2 gdbus: Add g_clear_dbus_signal_subscription() inline convenience function
This is like g_clear_signal_handler(), but for GDBus signal subscriptions.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-02-20 00:10:02 +00:00
Philip Withnall
0b08232416 Merge branch 'mcatanzaro/mr4206-followup' into 'main'
gcancellable: remove sketchy source ref/unref

See merge request GNOME/glib!4477
2025-02-19 23:32:27 +00:00
Philip Withnall
3a4beabc29 Merge branch 'wip/3v1n0/gmain-more-atomic' into 'main'
gmain: Use atomic logic to handle internal GSource flags

See merge request GNOME/glib!4488
2025-02-19 23:27:51 +00:00
Marco Trevisan (Treviño)
14da9d459c gio/tests/cancellable: Actually init atomic values with atomic functions
This is to make thread sanitizer happy, even those aren't really issues.
2025-02-19 19:38:12 +01:00
Marco Trevisan (Treviño)
ee836d7723 gmain: Use atomic logic to init the ref counting
Ensure we're consistent with the field usage
2025-02-19 19:38:12 +01:00
Marco Trevisan (Treviño)
42283ffb45 gmain: Use atomic logic to set and use dispose function
It can be read/written in a racy way, so let's be safer.
2025-02-19 19:38:12 +01:00
Marco Trevisan (Treviño)
a5bc497021 gmain: Use atomic logic to handle internal GSource flags
We use flags in both locked paths and in public ones (to check if a
source is destroyed or running), but those checks are not using atomic
logic, thus they lead to races in various tests.

Fix them by atomically change and read the values.
And this fixes various tests in thread sanitizer.
2025-02-19 19:36:21 +01:00
Marco Trevisan
30fbe0e859 Merge branch 'wip/3v1n0/gmain-source-reffing-fixes' into 'main'
glib/gmain: Avoid potential dispose race on GSource due to refcount dance

Closes #3612

See merge request GNOME/glib!4501
2025-02-19 18:26:19 +00:00
Marco Trevisan (Treviño)
7097359597 gmain: Ensure old reference is valid during unref
We were checking this already, leading to an extra atomic read that
isn't needed.
2025-02-19 19:03:29 +01:00
Marco Trevisan (Treviño)
5d117b021a gmain: Avoid unneeded atomic read on GSource ref
In g_source_ref() we can just ensure that the value we've referenced was
valid, instead of checking it before, since if get to such state the
GSource is broken anyways, but at least we can avoid doing an unneeded
atomic read.

Reason why we don't bother resetting the reference in case of failure.
2025-02-19 19:03:29 +01:00
Marco Trevisan (Treviño)
6052374c78 gmain: Go back to using the standard unref logic if the final unref failed
If going from 1 -> 0 references failed, then we should restart the unref
process, by potentially re-entering in the dispose function again if
instead something else re-references us and we're going to drop the last
one again.
2025-02-19 19:03:29 +01:00
Marco Trevisan (Treviño)
7b61cc8277 glib/gmain: Avoid potential dispose race on GSource due to refcount dance
During g_source_unref() we might end up calling dispose from
multiple threads, and due to the ref/unref dance we were doing we could
end up initiating a GSource finalization while another thread was about
to revive the source.

This was because we were unreffing a source in a thread, and potentially
re-reffing it, at the same time, but it was not guaranteed that the
final decrement and test couldn't be followed by a further re-ref.

To avoid this, do not do any ref/unref/re-ref/re-unref dance while we're
about to dispose, but instead follow a bit more the g_object_unref()
logic, and start the disposal phase only if we're about to drop the last
reference, and only after the potential disposal call is done, we do an
actual ref count decrement, which may lead to the finalization or not.

We don't bother following the same logic at later point, since after
disposal we should really have just one thread running and revival of a
finalizing GSource isn't supported anyways.

With this logic we can also avoid doing unneeded context locking when
we've enough references on a GSource that disposal is unlikely to
happen.

Closes: #3612
2025-02-19 18:59:33 +01:00
Philip Withnall
01289dd242 Merge branch 'gwin32-com-free-cpp-fix' into 'main'
gwin32.h: Avoid including unknwn.h

Closes #3613

See merge request GNOME/glib!4502
2025-02-19 13:22:03 +00:00
Chun-wei Fan
d920a86e25 gwin32.h: Avoid including unknwn.h
It pulls in windows.h causing conflict for code that assume windows.h is not
previously included.

Thanks to Luca Bacci for proposing this fix, and @Osyotr for pointing
out this issue!

Fixes issue #3613.
2025-02-19 20:52:01 +08:00
Philip Withnall
67a2f8c593 Merge branch '3560-register-object-with-closures' into 'main'
gdbusconnection: Add g_dbus_connection_register_object_with_closures2() API

Closes #3560

See merge request GNOME/glib!4431
2025-02-18 18:45:03 +00:00
Marco Trevisan
c8a81f1b8e Merge branch 'date-time-iso8601-overflow' into 'main'
gdatetime: Fix integer overflow when parsing very long ISO8601 inputs

See merge request GNOME/glib!4498
2025-02-18 18:44:56 +00:00
Philip Withnall
cbd5c9b3cc
tests: Add some missing GDateTime ISO8601 parsing tests
This improves test coverage, adding coverage for some lines which I
spotted were not covered while testing the preceding commits.

It doesn’t directly test the preceding commits, though.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-18 18:20:56 +00:00
Philip Withnall
0ffdbebd9a
gdatetime: Factor out an undersized variable
For long input strings, it would have been possible for `i` to overflow.
Avoid that problem by using the `tz_length` instead, so that we count up
rather than down.

This commit introduces no functional changes (outside of changing
undefined behaviour), and can be verified using the identity
`i === length - tz_length`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2025-02-18 17:31:48 +00:00