Commit Graph

27802 Commits

Author SHA1 Message Date
Alex Richardson
ab7e584e9f Cast via guintptr when adding/removing bitsflags on pointers
Round-tripping pointers via gsize is not guaranteed to work (the C standard
only requires this for (u)inptr_t) and in fact breaks on CHERI-enabled
systems such as Arm Morello where pointers are 128-bits but size_t is 64.
This means the current casts would strip the high bits of the pointer and
return a non-dereferenceable value. Fix this by casting the operand that
holds the pointer to guintptr instead of gsize.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-10-10 08:30:46 -07:00
Alex Richardson
c762d51134 gatomic: Use g(u)intptr where appropriate
This is required for CHERI systems such as Arm Morello, where gsize is
not large enough to hold a pointer. For all other architectures this
should not result in any functional changes since gsize is already the
same size (and I believe for most architectures even the same type)
as guintptr.

This is fully ABI compatible with all currently supported architectures
and should also be fully API compatible except for some rather unlikely
examples such as someone happening to use something like
`decltype(g_atomic_pointer_add(&a, 0))` in a C++ context where it
changes name mangling of some function.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-10-10 08:30:46 -07:00
Alex Richardson
877c575cd9 gbitlock: don't assume sizeof(gsize) == sizeof(gpointer)
Use a gpointer* instead of a gsize* as the g_atomic_pointer_* argument.
This is required for architectures such as Arm Morello where gsize is
64 bits but gpointer is 128 bits.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-10-10 08:30:46 -07:00
Philip Withnall
f7d2a58be6 Merge branch 'tests_meson_targets' into 'main'
glib/tests/meson.build: remove identical build targets

See merge request GNOME/glib!3629
2023-10-10 09:51:36 +00:00
Hannes Müller
5a1300db0a glib/tests/meson.build: remove identical build targets
If no error with -Werror=sign-conversion, the resulting object file
does not differ from compilation without -Werror=sign-conversion.
So the -Werror argument is now applied directly to string.c and testing.c.
Finally, the currently specific -Werror targets string-macro and
testing-macro are removed.
2023-10-10 11:16:25 +02:00
Philip Withnall
7e8fb7ba24 Merge branch 'hurd-codeowners' into 'main'
Add Hurd code owners

See merge request GNOME/glib!3627
2023-10-09 23:01:06 +00:00
Philip Withnall
8da3a5bb3e Merge branch 'stdio-include' into 'main'
glib-unix: Use full path to gstdio.h include

See merge request GNOME/glib!3628
2023-10-09 22:34:57 +00:00
Philip Withnall
2191b5aa05 glib-unix: Use full path to gstdio.h include
This fixes use of `glib-unix.h` from outside the GLib build path.

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

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3457#note_1864368
2023-10-09 22:18:18 +01:00
Philip Withnall
9b51346237 Merge branch 'wip/smcv/auto-unix-pipe' into 'main'
glib-unix: Add convenience API for pipes

See merge request GNOME/glib!3457
2023-10-09 18:00:36 +00:00
Simon McVittie
e80b0c4e4b gspawn: Use GUnixPipe on Unix
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-09 18:44:38 +01:00
Simon McVittie
9e20a7d0e7 tests: Exercise GUnixPipe
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-09 18:44:38 +01:00
Simon McVittie
26c7b308ba tests: Break out assert_fd_was_closed() into a header
Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-09 18:44:38 +01:00
Simon McVittie
f31db7d370 glib-unix: Add convenience API for pipes
We can't easily use g_autofd with g_unix_open_pipe, because its
parameter is an array of two fds that both need closing. Add an inline
convenience wrapper providing the obvious semantics.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-09 18:44:38 +01:00
Philip Withnall
240156d174 Merge branch '3098-keyfile-escaping' into 'main'
Revert "gkeyfile: Temporarily re-allow invalid escapes when parsing strings"

Closes #3098

See merge request GNOME/glib!3618
2023-10-09 16:50:56 +00:00
Simon McVittie
6fd1037361 gspawn: Use g_clear_fd() instead of reinventing it
g_clear_fd() is documented to be async-signal safe whenever the
fd is either negative or valid (which it should be here) and the error
is NULL (which it always is here).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-10-09 17:42:04 +01:00
Sergey Bugaev
e50cba31f6 docs: Add bugaevc and sthibaul as Hurd code owners
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
2023-10-09 15:08:38 +03:00
Philip Withnall
e93e1cb547 Merge branch 'g-wakeup-eintr-check' into 'main'
wakeup: Fix g_wakeup_acknowledge if signal comes in

See merge request GNOME/glib!3624
2023-10-05 16:53:54 +00:00
Ray Strode
7bbd4328f6 wakeup: Fix g_wakeup_acknowledge if signal comes in
It's not very likely, but there is a small chance that an
incoming signal could disturb the non-blocking read calls in
g_wakeup_acknowledge, leading to a subsequent spurious wake up.

This commit addresses the problem by doing the usual EINTR
loop (which is already present on the write side incidentally)
2023-10-05 09:55:49 -04:00
Philip Withnall
24f5711287 Merge branch 'wip/chergert/fix-eventfd-overreads' into 'main'
wakeup: do single read when using eventfd()

See merge request GNOME/glib!3621
2023-10-05 09:38:15 +00:00
Philip Withnall
4863561a46 Merge branch 'once-init-annotations' into 'main'
gthread: Fix optional/nullable annotations for g_once_init_*()

See merge request GNOME/glib!3581
2023-10-04 22:43:49 +00:00
Philip Withnall
da278bdd0b Merge branch 'wip/chergert/queue-for-sourcelist' into 'main'
gmain: avoid a GList traversal when removing source

See merge request GNOME/glib!3620
2023-10-04 22:40:58 +00:00
Philip Withnall
57b41b8fec Merge branch 'g-once-enter-ptr' into 'main'
gthread: introduce g_once_init_{enter,leave}_pointer

See merge request GNOME/glib!3577
2023-10-04 22:22:54 +00:00
Christian Hergert
de79831e3c wakeup: do single read when using eventfd()
Previously, this would loop as long as read() got the expected number of
bytes back, which is 8. That means every successful read() of the eventfd
would perform an additional syscall() as a followup.

This is not ideal because eventfd (unless used as an EFD_SEMAPHORE) will
reset the counter as part of the read(). So that means that we either do
an additional throw-away syscall() or potentially race against a producer
generating new events before this change.
2023-10-04 14:01:23 -07:00
Christian Hergert
5e96ed64c9 gmain: avoid a GList traversal when removing source
Currently the GSourceList has it's own allocation plus a secondary
allocation for the GList which contains it (from GMainContext). Not only
are these a pointer chase, but they are on separate cachelines too. Without
changing the code much we can at least keep things on the same cacheline
so that the pointer chase matters less.

Since the GList becomes embedded in the GSourceList you can use a
g_queue_unlink() directly removing the link without traversing the GList
like was done before.

Furthermore, we can simplify some code with g_queue_push_tail_link()
instead of some extra branching.
2023-10-04 13:37:06 -07:00
Philip Withnall
bd13ec30a9 Merge branch 'mcatanzaro/null' into 'main'
Document NULL pointer pitfall in toolchain requirements

See merge request GNOME/glib!3598
2023-10-04 14:13:43 +00:00
Alex Richardson
5ecd3cbe52 gobject: use g_once_init_enter_pointer for GType initializers
GType is either an integer or a pointer, so we have to use the _pointer
version here to support architectures such as Morello.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
See also: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3578
2023-10-04 14:50:54 +01:00
Michael Catanzaro
77d1093108 Merge branch '3111-drop-unnecessary-include' into 'main'
tests: Drop unnecessary include from gsubprocess-testprog.c

Closes #3111

See merge request GNOME/glib!3617
2023-10-04 13:22:08 +00:00
Michael Catanzaro
2b0c17f458 Document NULL pointer pitfall in toolchain requirements
I'm not aware of any platforms where this is a problem in practice, but
it's definitely nonportable and doesn't hurt to document it.
I wonder about CHERI....
2023-10-04 14:04:08 +01:00
Philip Withnall
a66cc62f56 Merge branch 'fix-constructor-test-warning-clang' into 'main'
tests/constructor: Fix "unknown pragma ignored" warning on clang

See merge request GNOME/glib!3611
2023-10-04 13:00:26 +00:00
Alex Richardson
a1dfecf11f Use g_once_init_{enter,leave}_pointer where appropriate
This should not result in any functional changes, but will eventually
allow glib to be functional on CHERI-enabled systems such as Morello.

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-10-04 13:57:16 +01:00
Alex Richardson
726eca7c89 gthread: introduce g_once_init_{enter,leave}_pointer
These functions can be used to initalize pointer-type variables rather
than a gsize. This is required to support CHERI-enabled platforms where
gsize cannot be used to store pointers. Follow-up changes will migrate
the uses of g_once_init that store pointers to the new API

Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842
2023-10-04 13:57:16 +01:00
Luca Bacci
c287e69c0a tests/constructor: Fix "unknown pragma ignored" warning on clang 2023-10-04 13:43:05 +01:00
Philip Withnall
9c81ff46a2 Merge branch 'fix-z-format-tests' into 'main'
tests: Fix gdatetime test on non-UTC systems

See merge request GNOME/glib!3613
2023-10-04 12:41:30 +00:00
Philip Withnall
ef28253e57 tests: Separate invalid escaping tests for GKeyFile
One test key was serving two purposes, which meant tests for it couldn’t
be separated out. It was testing escape-at-end-of-line and also
invalid-escape.

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

Helps: #3098
2023-10-04 11:30:02 +01:00
Philip Withnall
76d77cf623 Revert "gkeyfile: Temporarily re-allow invalid escapes when parsing strings"
This reverts commit 4a96727642.

It was a temporary workaround to prevent disruption to apps late on in
the 2.78 cycle. Since we’re now early in the 2.80 cycle, let’s revert
the workaround and allow apps more time to fix their error handling for
`GKeyFile`.

Fixes: #3098
2023-10-04 11:01:35 +01:00
Emmanuele Bassi
ab83d965e8 Merge branch 'version-bump' into 'main'
build: Post-release version bump

See merge request GNOME/glib!3605
2023-10-04 09:33:58 +00:00
Philip Withnall
62c33e653f tests: Fix gdatetime test on non-UTC systems
Commit 0b114b2687 accidentally made the
tests only pass on systems running in a UTC timezone, as it checked the
local timezone `%Z` format against `UTC`.

This happens to pass on all the GLib CI runners except the macOS one,
which is running under CET.

Make the formatting tests timezone-independent by running them with UTC
datetimes. There’s already a separate test for checking that `%Z` works
correctly in a non-UTC timezone (`test_z`).

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

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3611#note_1859208
2023-10-04 10:14:20 +01:00
Philip Withnall
e00ca9967f tests: Drop unnecessary include from gsubprocess-testprog.c
It’s not actually needed on any platform, and causes compilation
problems on platforms where it’s not available.

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

Fixes: #3111
2023-10-04 10:06:37 +01:00
Philip Withnall
2046a1b9d2 Merge branch 'mcatanzaro/security' into 'main'
Expand security policy to cover previous stable branch

See merge request GNOME/glib!3597
2023-10-04 08:33:52 +00:00
Philip Withnall
31e96edbdd Merge branch 'glib-2.78.0-g_assert_cmpint' into 'main'
gtestutils.h: Fix warning with -Wsign-conversion caused by g_assert_cmpint

See merge request GNOME/glib!3590
2023-10-04 08:30:43 +00:00
Philip Withnall
9f6b42af6e Merge branch 'vectored-exception-handlers' into 'main'
Small fixes and cleanups for Vectored Exception Handlers

See merge request GNOME/glib!3569
2023-10-04 08:19:57 +00:00
Philip Withnall
fdfaa993e6 Merge branch 'fix-unaligned-dirent64' into 'main'
Buffer needs to be aligned correctly to receive linux_dirent64.

See merge request GNOME/glib!3582
2023-10-03 17:43:13 +00:00
Sebastian Wilhelmi
9a48cbf27b Buffer needs to be aligned correctly to receive linux_dirent64. 2023-10-03 17:43:12 +00:00
Philip Withnall
199fa27321 Merge branch 'update-strv-annotations' into 'main'
Update GStrv annotations

See merge request GNOME/glib!3612
2023-10-03 17:29:28 +00:00
Philip Withnall
f3469858f3 Merge branch 'uncomment' into 'main'
gdesktopappinfo: Do not search Comment field

See merge request GNOME/glib!3610
2023-10-03 17:12:59 +00:00
badcel
85d2a7549d
Update GStrv annotations 2023-10-03 16:09:03 +02:00
Florian Müllner
794b18df34 gdesktopappinfo: Do not search Comment field
The Comment field provides a user-visible description of the app,
which usually contains generic words ("and", "or", "not", "is", ...)
that add noise when used for search.

It made some sense to match against the field as a fallback for
Keywords, before that key was well established. However that key
has been around for years now, so hopefully every app where additional
terms are helpful uses it by now.

With that, the downside of added noise outweighs the benefit, so
it's time to stop matching on comments.
2023-10-03 14:05:27 +02:00
Philip Withnall
2f1f97d58d Merge branch 'wip/paveloom/tcp-connection-leak' into 'main'
Make sure the `GTask` is freed on a graceful disconnect

See merge request GNOME/glib!3607
2023-10-03 10:41:16 +00:00
Philip Withnall
c1528778e6 Merge branch 'fix_3116' into 'main'
glocalfileinfo: Preserve microseconds for access/modify times

Closes #3116

See merge request GNOME/glib!3587
2023-10-03 10:00:55 +00:00
Philip Withnall
b4e6a834a2 Merge branch 'tls-callbacks' into 'main'
Make use of TLS callbacks for static builds on Windows

Closes #3087

See merge request GNOME/glib!3560
2023-10-03 10:00:44 +00:00