Commit Graph

27665 Commits

Author SHA1 Message Date
Jonas Ådahl
cf55c31170 gio/tests: Add test case for exit status when being ptraced
The test case will fail with the

    g_assert_false (g_subprocess_get_successful (proc));

assert failing. Without the fix, it'll hit sometimes, but rather
unreliably. When running `meson test --repeat 100`, it'll reproduce
anywhere between the first or much later, but mostly before the 20th
iteration on my system.

Helps: #3071
2023-08-12 19:30:00 +01:00
Jonas Ådahl
8d78fa7887 main: Don't treat si_pid from pidfd as child exiting
We might repeatedly get si_pid == 0 for a child that hasn't exited,
meaning we won't get a correct exit status. This seems to happen when
the glib application tracks a ptrace():ed child process; the correct
exit status of the process using e.g. a BPF program, where one can
observe that glib appears to get it wrong.

Fixes: #3071
2023-08-12 19:08:46 +01:00
René de Hesselle
439204ed7d Re-enable macOS CI on a new self-hosted runner
Allow two more tests to fail on macOS for the time being:
https://gitlab.gnome.org/GNOME/glib/-/issues/3069
https://gitlab.gnome.org/GNOME/glib/-/issues/3070
2023-08-11 19:33:19 +02:00
Kukuh Syafaat
3513be4e35 Update Indonesian translation 2023-08-11 12:05:11 +00:00
Marco Trevisan (Treviño)
694eb3aa02 gspawn: Mark child setup in g_spawn_sync() as call scope
While it's only called one time, this is something that can only happen
during the function call, so it's more correct to mark it as call scope,
so that bindings don't have to wait for the callback invocation to
cleanup the data.
2023-08-10 23:37:48 +02:00
Marco Trevisan (Treviño)
ff23b24254 gspawn, gdataset: Restore nullable callback functions
As per commit 5d738ddc some callbacks are not nullable anymore even
though they should be.

This breaks the introspection as some arguments won't be considered
nullable anymore.

You can notice this in https://gitlab.gnome.org/3v1n0/gjs/-/pipelines/558839
where some some tests are running against stable g-i version and others
(the failing ones) against the devel one.
2023-08-10 23:37:14 +02:00
Maciej S. Szmigiero
faa11d0910 GTree: Add a G_STATIC_ASSERT for MAX_GTREE_HEIGHT
Makes sure we don't accidentally set it too small and overflow a tree path
array.

Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
2023-08-09 15:15:13 +02:00
Maciej S. Szmigiero
f08191e398 GTree: Check for node counter overflow when adding new elements
Currently, when adding new elements to GTree we blindly increment the node
counter, which is only of guint size (so 32-bit even on 64-bit Unix
platforms).

This is even more problematic because the only way to check whether
particular GTree is empty is to check whether its node count is zero.
This will obviously give wrong answer if this counter overflows.

Let's fix this by adding an appropriate check when adding a new node.

For the recently added g_tree_{insert,replace}_node () API we can simply
return NULL in such case.

However, the older g_tree_{insert,replace} () API doesn't have any ability
to return an error so for them we follow the example of
g_ptr_array_extend () and g_ptr_array_set_size () by calling g_error ()
when this happens.

Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
2023-08-09 15:15:09 +02:00
Maciej S. Szmigiero
1237525da2 GTree: Annotate the real return value type of g_tree_nnodes ()
g_tree_nnodes () is returning a signed integer type (gint), however the
tree node counter value type is really an unsigned integer (guint).

This means that the returned size will be negative if the container holds
more than G_MAXINT elements.

Add a note to this function that its return value can be cast back to
guint in order to support its full range of values.

This will also make sure that we take this into account in future Glib
versions.

Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
2023-08-09 14:57:14 +02:00
Luming Zh
c5ad8187e2 Update Chinese (China) translation 2023-08-08 16:47:12 +00:00
Sabri Ünal
76f7961a7b Update Turkish translation 2023-08-08 11:07:17 +00:00
Daniel Mustieles
9a48871c33 Updated Spanish translation 2023-08-08 08:16:35 +02:00
Fran Dieguez
db411295db Update Galician translation 2023-08-08 00:10:23 +00:00
Piotr Drąg
4d1e9a9520 Update Polish translation 2023-08-06 12:40:39 +00:00
Hugo Carvalho
e8af76ad25 Update Portuguese translation 2023-08-04 15:59:03 +00:00
Artur So
daf778a194 Update Russian translation 2023-08-03 15:54:42 +00:00
Michael Catanzaro
306d4567d2 Replace setlocale() with uselocale() in GSettings l10n tests
It's not safe to use setlocale() to mutate the locale in a threaded
program. Lots of other tests still do this, and I'm not putting in the
effort to fix them comprehensively in the absense of actual failures on
CI, but I figured it'd be good to fix the tests that I was touching.
2023-08-03 09:45:58 -05:00
Michael Catanzaro
736000e49e Remove setenv() use from GSettings l10n tests
This definitely does not do anything on Linux. I bet it's not needed on
other platforms, either. It's unsafe and may crash; there is no safe way
to mutate the environment in threaded programs.
2023-08-03 09:16:27 -05:00
Michael Catanzaro
92de7298c8 Add test for l10n="time" gschema attribute
This is a copy of the existing test_l10n, modified to use LC_TIME
instead of LC_MESSAGES. It's not safe as each call to g_setenv() or
setlocale() could cause the test to crash; there is no safe way to
change a threaded process's environment, and a threaded process's locale
can only be safely changed using uselocale(), not with setlocale().

The calls to g_setenv() are definitely not needed on Linux. I wonder
whether removing these will break the test on other platforms?

The calls to setlocale() should be replaced by a dance of
uselocale() -> duplocale() -> newlocale() -> uselocale() on Linux. But
this is not portable and this is a cross-platform test. We would have to
make the test platform-specific to do this. macOS and at least FreeBSD
provide these functions via xlocale.h, but this isn't portable.
2023-08-03 09:16:26 -05:00
Michael Catanzaro
34e4c4af77 gsettingsschema: fix l10n=time attribute
It's supposed to be possible to translate settings values using LC_TIME
rather than LC_MESSAGES to determine which translation to use, but
Sebastian Keller noticed that it's not working properly. I've
implemented his proposed solution, which is to actually temporarily
change LC_MESSAGES to match LC_TIME for just as long as necessary to
force gettext to use the desired message catalog.

Fixes #2575
2023-08-03 09:10:58 -05:00
Michael Catanzaro
dc4a191587 Merge branch 'typos' into 'main'
Fix typos

See merge request GNOME/glib!3520
2023-08-01 21:29:05 +00:00
Federico Gallo Herosa
89be3d357d
Fix typos
Fix typo in gio/gappinfo (duplicated word)
Fix typo in gio/gtlsdatabase.c (duplicated word)
Fix typo in gio/gapplication.c (duplicated word, previous words rearranged to improve readability)
Fix typo in glib/tests/gvariant.c (duplicated word)
Fix typo in glib/win_iconv.c (duplicated word)
Fix typo in gio/gschema.dtd (meaning, missing letter)
Fix typo in gio/gdbusintrospection.c (duplicated word)
Fix typo in gio/gdbusintrospection.c (duplicated word).
2023-08-01 15:33:21 -03:00
Philip Withnall
e1f4c5806f
2.77.1
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-30 20:44:31 +03:00
Philip Withnall
98782e22e3 Merge branch 'win32' into 'main'
m4macros: drop unused m4 files

See merge request GNOME/glib!3518
2023-07-30 14:52:58 +00:00
Marc-André Lureau
f52dfe02cb m4macros: drop unused m4 files
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2023-07-30 17:03:07 +04:00
Philip Withnall
d803c63c81 Merge branch 'more-type-query-tests' into 'main'
tests: Add some more tests for g_type_query()

See merge request GNOME/glib!3517
2023-07-30 12:52:28 +00:00
Emmanuele Bassi
0cc84f9f3e Merge branch '931-gprivate-optimisations' into 'main'
GPrivate: eliminate a malloc for pthread_key_t on most platforms

Closes #931

See merge request GNOME/glib!3507
2023-07-30 10:56:53 +00:00
Emmanuele Bassi
f7bc7d6f3e Merge branch '473-gvariant-systemtap' into 'main'
GVariant: add probes for SystemTap

Closes #473

See merge request GNOME/glib!3508
2023-07-30 10:56:22 +00:00
Philip Withnall
c2df874e0b tests: Add some more tests for g_type_query()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-30 13:51:00 +03:00
Emmanuele Bassi
95f372086a Merge branch 'revert-3509' into 'main'
Revert "build-sys: drop -mms-bitfields GCC flag"

See merge request GNOME/glib!3514
2023-07-30 10:50:05 +00:00
Emmanuele Bassi
338a9c35d2 Merge branch 'metered-docs' into 'main'
gnetworkmonitor: Expand guidelines for metered data use

See merge request GNOME/glib!3515
2023-07-30 10:45:38 +00:00
Philip Withnall
1f59981f7f Merge branch 'th/fix-main-context-release-owner-check' into 'main'
gmain: drop owner check assertion in g_main_context_release()

Closes #3054

See merge request GNOME/glib!3513
2023-07-30 10:09:09 +00:00
Emmanuele Bassi
7211c07693 Merge branch '623-type-query-dynamic' into 'main'
gtype: Allow g_type_query() to be called on dynamic types

Closes #623

See merge request GNOME/glib!3516
2023-07-30 09:04:35 +00:00
Thomas Haller
07f8a5daa3 gmain: drop owner check assertion in g_main_context_release()
As commit 44616ebafd ('gmain: More explicitly document
g_main_context_release() prereqs') correctly notes, you need to have the
context acquired before releasing it (just like a ref must match an
unref).

Commit 3926af723a ('gmain: Add precondition assertions to
g_main_context_release()') then goes one step further, and requires that
the calling thread is also the owner (the thread, that acquired the
context).

This is something which has been documented by g_main_context_release()
for years:
> Releases ownership of a context previously acquired **by this thread**

With acquire/release and g_main_context_is_owner() we track the thread
that acquired the context. That is mainly useful for asserting
correctness to not accessing the context from an unexpected thread.
Note that g_main_context_acquire() returns FALSE and does nothing when
the context is already acquired from another thread. Methods like
g_main_context_{prepare,query,dispatch}() require that the calling
thread is the owner (although, they don't assert for that, which they
maybe should).

With the assertion, it means you cannot pass an acquired context to
another thread for release. Obviously, if you pass on an acquired
context to another thread, the only next thing you can do is
g_main_context_release() (no acquire,prepare,query,dispatch). But it's
still useful to be able to release it, and to be able to keep it
acquired for a prolonged time.

libnm needs that, as it integrates a GMainContext into another
GMainContext. For that, it needs to acquire the inner context and keep
it acquired for as long as the context is integrated. Otherwise, when a
source gets attached to the inner context, the inner context is not
woken up (see g_source_attach_unlocked()). In commit e26a8a5981 ('Add
G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING'), a flag was introduced to solve
that same problem, without keeping the inner context acquired all the
time. Note that G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING is a flag of the
GMainContext, so it only works if the user who integrates the inner
context also controls how the context was created.  For libnm, having
the inner context acquired at all times is no problem, because it's
understood that the user gives up agency on the inner context while it's
integrated. The only thing to consider is that the outer context might
be iterated on another thread. When calling prepare,query,dispatch on
the inner context, the code will notice it, release the inner context
and re-acquire it on the new thread ([1]).  This works just fine, but it
requires that g_main_context_release() works from any thread.

So, in order to not break NetworkManager, let’s drop the ownership
assertion. However, NetworkManager is strictly breaking the API contract
here, and GLib reserves the right to re-add this assertion in future.

Still keep the assertion for the owner_count.

(Commit and commit message significantly updated by Philip Withnall; all
errors are his.)

[1] 9f01cff04f/src/libnm-glib-aux/nm-shared-utils.c (L4944)

Related: 3926af723a ('gmain: Add precondition assertions to g_main_context_release()')
Related: c67dd9d3fe ('gmain: Add a missing return on error path in g_main_context_release()')

Closes #3054
2023-07-30 11:53:34 +03:00
Philip Withnall
d9b23c5466 gtype: Allow g_type_query() to be called on dynamic types
There’s no reason that anyone can think of that this should be
disallowed. It’s useful for language runtimes like GJS to be able to
find out the allocation size of dynamic GObjects.

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

Fixes: #623
2023-07-30 11:25:42 +03:00
Matej Urbančič
43cec2d622 Update Slovenian translation 2023-07-29 13:42:00 +00:00
Philip Withnall
02bc1382b2 gnetworkmonitor: Expand guidelines for metered data use
Clarify how much is too much.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-29 15:22:15 +03:00
Philip Withnall
627dc1415c Revert "build-sys: drop -mms-bitfields GCC flag"
This reverts commit 252bbcd207.

After further discussion in !3511, we’ve decided that there are risks
associated with this change, and it’s not the best way of addressing the
original problem.

The original motivation for the change turned out to be that
`-mms-bitfields` was not handled by `windres`, which was receiving it
from `pkg-config --cflags glib-2.0` in some projects. However, if
`windres` is claiming to accept CFLAGS then it should accept (and
ignore) `-mms-bitfields`, since the `-m` family of options are defined
in `man gcc`, just like `-I`, `-D`, etc.

There is some question that there might still be third party projects
which are built with an old enough compiler that `-mms-bitfields` is not
the compiler default. For that reason, we should either still continue
to specify `-mms-bitfields` in the `.pc` file, or add a test to assert
that third party projects are always compiled with `-mms-bitfields` set.
But adding a new test for all third-party compilations is risky (if we
get it wrong, things will break; and it’s a test which may behave
differently on different platforms), so it seems safer to just keep
`-mms-bitfields` in `.pc` for now.

Once all compilers which we require specify `-mms-bitfields` by default,
we can finally drop this flag (without adding a test for third-party
compilations).

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3511
2023-07-29 11:54:22 +03:00
Danial Behzadi
6e77bb3315 Update Persian translation 2023-07-29 01:46:42 +00:00
Danial Behzadi
74b1f636b7 Update Persian translation 2023-07-29 01:45:00 +00:00
Yuri Chornoivan
17bfd6c9a5 Update Ukrainian translation 2023-07-28 17:48:10 +00:00
Philip Withnall
39864716d6 Merge branch 'fix_3050' into 'main'
Strip query sections from file: URIs

Closes #3050

See merge request GNOME/glib!3502
2023-07-28 12:52:36 +00:00
Lukáš Tyrychtr
b504cc0841 gfile: Strip query sections from file: URIs
According to https://url.spec.whatwg.org/#file-state
a file URI can have a fragment and query string, so just ignore them
and don't raise an invalid URI error.

Fixes: #3050
2023-07-28 15:04:49 +03:00
Philip Withnall
215a6ed80c gconvert: Rename an internal variable
The old name was not quite correct: the part of a URI which is just past
the scheme might be the hostname or the path. It isn’t necessarily just
a path.

This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-28 15:04:49 +03:00
Yosef Or Boczko
67eb8f112f Update Hebrew translation 2023-07-28 06:00:39 +00:00
Ekaterine Papava
782b06d92f Update Georgian translation 2023-07-28 05:15:30 +00:00
Balázs Úr
7e9db39996 Update Hungarian translation 2023-07-26 23:43:43 +00:00
Michael Catanzaro
b01d801207 Merge branch 'issue-2929' into 'main'
Fix build race between gio subdirs and gversionmacros.h

Closes #2929

See merge request GNOME/glib!3512
2023-07-26 17:36:05 +00:00
Simon McVittie
9d203a9e39 Merge branch 'wip/smcv/prctl-undumpable' into 'main'
testutils: Use prctl PR_SET_DUMPABLE to silence core dumps on Linux

See merge request GNOME/glib!3510
2023-07-26 15:06:07 +00:00
Simon McVittie
71d44e8d71 testutils: Use prctl PR_SET_DUMPABLE to silence core dumps on Linux
Otherwise, crashing tests like assert-msg-test will still report to
pipe-based crash reporting frameworks like systemd-coredump, even though
the RLIMIT_CORE limit is zero.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-07-26 15:42:06 +01:00