Commit Graph

27346 Commits

Author SHA1 Message Date
Philip Withnall
06eecda823 gtask: Track pending GTasks if G_ENABLE_DEBUG is defined
Track the `GTask`s which are still alive (not finalised) in a shared
list, and provide a secret debugging function for printing that list.

Too often when debugging apps, I have found that a ‘leaked’ object is
actually still (validly) referenced by an ongoing `GTask` which hasn’t
completed for whatever reason. Or I have found that an operation has
obviously stalled, but there are no pointers available to the `GTask`
which is stalled, because it’s being tracked as a collection of closure
pointers from some `GSource` which is hard to get to in the debugger.

It will be very useful for debugging apps, if there’s a list of all the
still alive `GTask`s somewhere. This is that list.

The code is disabled if `G_ENABLE_DEBUG` is not defined, to avoid every
`GTask` construction/finalisation imposing a global locking penalty.

To use the new list, break in `gdb` while running your app, and call
`g_task_print_alive_tasks()`, or inspect the `task_list` manually:
```
(gdb) print g_task_print_alive_tasks()
16:44:17:788 GLib-GIO 5 GTasks still alive:
 • GTask 0x6100000ac740, gs_plugin_appstream_setup_async, ref count: 1, ever_returned: 0, completed: 0
 • GTask 0x6100000bf940, [gio] D-Bus read, ref count: 2, ever_returned: 0, completed: 0
 • GTask 0x6100000aac40, gs_plugin_loader_setup_async, ref count: 1, ever_returned: 0, completed: 0
 • GTask 0x61000006d940, gs_plugin_loader_job_process_async GsPluginJobRefine, ref count: 1, ever_returned: 0, completed: 0
 • GTask 0x610000118c40, [gio] D-Bus read, ref count: 2, ever_returned: 0, completed: 0
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-27 12:22:05 +01:00
Marco Trevisan
59a2235e9d Merge branch '98-current-path' into 'main'
gfileutils: Fix potential integer overflow in g_get_current_dir()

Closes #98

See merge request GNOME/glib!3375
2023-04-27 09:18:07 +00:00
Fran Dieguez
48ac9b32b3 Update Galician translation
(cherry picked from commit 665d01fbca)
2023-04-27 09:07:30 +00:00
Michael Catanzaro
68ad8334b6 Merge branch 'disable-coverity' into 'main'
ci: Disable the Coverity CI job

See merge request GNOME/glib!3401
2023-04-26 16:38:16 +00:00
Philip Withnall
8d527919b4 Merge branch 'update-errfmt-in-gunixconnection-part3' into 'main'
restore error messages in gunixconnection while maintaining older compiler support

See merge request GNOME/glib!3400
2023-04-26 16:27:34 +00:00
Philip Withnall
0c81ab6dac Merge branch 'task-shared-resource-docs' into 'main'
gtask: Document that g_task_run_in_thread() uses a shared resource

See merge request GNOME/glib!3395
2023-04-26 16:25:31 +00:00
Philip Withnall
73bf66dd2a Merge branch 'unix-fd-source-docs' into 'main'
glib-unix: Improve documentation for g_unix_fd_source_new()

See merge request GNOME/glib!3396
2023-04-26 16:11:42 +00:00
Philip Withnall
f9bfc12b6e ci: Disable the Coverity CI job
It’s not produced anything but false positives for several years now,
and it would be better to save the CI/analysis/triage resources and
instead focus on `scan_build` reports, which generally seem to be more
useful.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-26 14:30:20 +01:00
Sebastian Dröge
1df0e81b19 Merge branch 'pkj/fix-g_futex_simple' into 'main'
Avoid having g_futex_simple() inadvertently modify errno

See merge request GNOME/glib!3398
2023-04-26 06:29:43 +00:00
James Knight
55e93a8278 gio: switch gunixconnection ngettext with g_dngettext calls
This commit changes the use of `ngettext` with `g_dngettext`. The
project defined `g_dngettext` (with domain support) provides the same
functionality as `ngettext` with a NULL domain provided. The purpose of
this change is to help address a build error for certain compilers that
trigger a `format-nonliteral` error-promoted-warning when using
`ngettext` (see also [1][2]). The benefit of switching to use
`g_dngettext` is that the function is defined with `G_GNUC_FORMAT`. This
provides a hint to GNU GCC compilers to still sanity check these
arguments, but not generate a `format-nonliteral`.

[1]: 4ae8606b6f
[2]: 0ca660315a

Signed-off-by: James Knight <james.d.knight@live.com>
2023-04-25 23:25:38 -04:00
James Knight
0ca660315a Revert "Fix error format in gio/gunixconnection.c (part 2)"
This reverts commit 4ae8606b6f. The idea
for the change [1] was to address a build error for certain compilers
that trigger a `format-nonliteral` error-promoted-warning since these
compilers do not gracefully support `ngettext` usage. The changes
following a pattern from an old commit [2]; however, James Hilliard has
pointed out these changes do not work as intended. A deeper inspection
of the commit showed that the commit was from an old merge request that
was not pulled in, detailing why the changes did not work (see also
[3][4]).

Manipulating the sockets unit test confirms that the format values no
longer get a proper value:

    ...
    ok 9 /socket/address
    ok 10 /socket/unix-from-fd
    ok 11 /socket/unix-connection
    **
    GLib-GIO:ERROR:../gio/tests/socket.c:1493:test_unix_connection_ancillary_data: assertion failed (err == NULL): Expecting one fd, but got %d
     (g-io-error-quark, 0)
    ...

And reverting this change restores the original functionality:

    ...
    ok 9 /socket/address
    ok 10 /socket/unix-from-fd
    ok 11 /socket/unix-connection
    **
    GLib-GIO:ERROR:../gio/tests/socket.c:1493:test_unix_connection_ancillary_data: assertion failed (err == NULL): Expecting 1 control message, got 0 (g-io-error-quark, 0)
    ...

[1]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3390
[2]: 44b3d5d80445234041f6c59feb89645f7102c3a4
[3]: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/770
[4]: https://gitlab.gnome.org/GNOME/glib/-/issues/1744

Signed-off-by: James Knight <james.d.knight@live.com>
2023-04-25 23:21:58 -04:00
Peter Kjellerstedt
edd1e47f10 Avoid having g_futex_simple() inadvertently modify errno
If both __NR_futex and __NR_futex_time64 are defined, g_futex_simple()
will first call futex_time64(). If that fails with ENOSYS, then
futex_time() is called instead. However, errno was not saved and
restored in this case, which would result in g_futex_simple()
returning with errno set to ENOSYS, even if futex_time() succeeded.
2023-04-26 02:08:46 +02:00
Philip Withnall
c256af1c2d gthreadedresolver: Add some additional debug prints
These make it a bit easier to track the ongoing resolver tasks, as the
tasks and/or their closures are not tracked in a big list somewhere.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-25 15:35:54 +01:00
Philip Withnall
df9d3818ac glib-unix: Improve documentation for g_unix_fd_source_new()
In particular, document the type of the callback function.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-25 15:30:45 +01:00
Philip Withnall
885eb1d8e5 gtask: Document that g_task_run_in_thread() uses a shared resource
It’s a bad idea to use it without some care for how much it’s being
called in parallel, or dependencies between tasks. If the thread pool
gets exhausted by too many inter-dependent calls to
`g_task_run_in_thread()` then the process will livelock.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-25 15:29:55 +01:00
Philip Withnall
c176fcf2eb Merge branch 'doc-indentation' into 'main'
Fix small issues in docs

See merge request GNOME/glib!3393
2023-04-24 12:58:08 +00:00
Philip Withnall
d3e7b9e17c Merge branch 'context-checks' into 'main'
gmain: More explicitly document g_main_context_release() prereqs

See merge request GNOME/glib!3314
2023-04-24 12:52:51 +00:00
Philip Withnall
fd493cacf2 Merge branch 'ebassi/refcount-init-macros' into 'main'
Add init macros for refcounting types

See merge request GNOME/glib!3366
2023-04-24 12:13:16 +00:00
Philip Withnall
3926af723a gmain: Add precondition assertions to g_main_context_release()
As with the previous commit.

The logic has to be a little contorted here to avoid leaving the context
locked after emitting the critical warning. Execution does (and should)
continue after a critical warning by default, so we should do our best
to recover.

Inspired by https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3302.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-24 13:02:36 +01:00
Philip Withnall
44616ebafd gmain: More explicitly document g_main_context_release() prereqs
The documentation was fairly clear before, but we can make it clearer:
it’s a programming error to call `g_main_context_release()` if you have
not received a true return value from `g_main_context_acquire()` before.

Inspired by https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3302.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-24 12:49:23 +01:00
Emmanuele Bassi
e2e93056f2 Add init macros for refcounting types
We need a way to initialise refcounted types placed in static storage,
or on the stack. Using proper macros avoids knowing the magic constant
used for grefcount and gatomicrefcount.
2023-04-24 12:48:32 +01:00
Arjan Molenaar
84d8d5647e
Fix small issues in docs
This will make converting the docs to another format
(say, rst) somewhat easier.
2023-04-24 13:18:33 +02:00
Philip Withnall
28b1b9d9c3 Merge branch 'gmain-less-locks' into 'main'
gmain: Avoid some lock/unlock dance during g_main_context_iterate

See merge request GNOME/glib!3235
2023-04-24 10:29:41 +00:00
Philip Withnall
cba49eb6a1 Merge branch 'mutex-tests-more' into 'main'
glib/tests/[rec-]mutex: Allow each thread to work

See merge request GNOME/glib!3389
2023-04-24 10:25:05 +00:00
Philip Withnall
8ee3063721 Merge branch 'pgorszkowski/add_tests_for_g_signal_handlers_disconnect_matched' into 'main'
Test g_signal_handlers_disconnect_matched for G_SIGNAL_MATCH_ID match

See merge request GNOME/glib!3384
2023-04-24 10:20:21 +00:00
Marco Trevisan
103c9ebe3c Merge branch 'gvariant-typo' into 'main'
gvariant: Fix doc for g_variant_new_object_path

See merge request GNOME/glib!3392
2023-04-22 01:13:39 +00:00
Arnaud Rebillout
edb85b99f6 gvariant: Fix doc for g_variant_new_object_path
The parameter is named 'object_path', not 'string'.
2023-04-21 21:56:50 +07:00
Marco Trevisan
9308f2c353 Merge branch 'wip/3v1n0/gio-gmodule-visibility-dep' into 'main'
gmodule: Define a gmodule include dependency and use it in gio modules

Closes #2982

See merge request GNOME/glib!3386
2023-04-21 13:58:50 +00:00
Marco Trevisan
3594d9615b Merge branch 'update-errfmt-in-gunixconnection' into 'main'
Fix error format in gio/gunixconnection.c (part 2)

See merge request GNOME/glib!3390
2023-04-21 12:05:14 +00:00
James Knight
4ae8606b6f Fix error format in gio/gunixconnection.c (part 2)
Update a series of error messages to use `g_set_error_literal` instead
of `g_set_error`. This should prevent `format-nonliteral` compiler
issues when `-Werror` is configured:

    ../gio/gunixconnection.c: In function ‘g_unix_connection_receive_fd’:
    ../gio/gunixconnection.c:183:9: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
      183 |         nscm);
          |         ^~~~
    ../gio/gunixconnection.c:217:20: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
      217 |                    nfd);
          |                    ^~~
    ../gio/gunixconnection.c: In function ‘g_unix_connection_receive_credentials’:
    ../gio/gunixconnection.c:601:24: error: format not a string literal, argument types not checked [-Werror=format-nonliteral]
      601 |                        nscm);
          |                        ^~~~

This is similar to a previous change [1] made to `gunixconnection.c`.

[1]: 44b3d5d80445234041f6c59feb89645f7102c3a4

Signed-off-by: James Knight <james.d.knight@live.com>
2023-04-20 23:41:32 -04:00
Emmanuele Bassi
b8466bb54d Merge branch 'wip/3v1n0/macos-add-desktop-app-info' into 'main'
appmonitor: Skip the test under OSX

See merge request GNOME/glib!3388
2023-04-20 16:52:45 +00:00
Marco Trevisan (Treviño)
3aeef671d0 glib/tests/[rec-]mutex: Allow each thread to work
In non-perf mode, we were making only one thread to win the race to increase
the value, but since we're launching more threads anyways let's allow
more of them to have a chance to do something, to make the test more
valuable, even if it's still quick enough.
2023-04-20 17:01:05 +02:00
Gaël Bonithon
86b4b0453e gkeyfile: Fix group comment management
This removes the `comment` member of the GKeyFileGroup structure, which
seemed intended to distinguish comments just above a group from comments
above them, separated by one or more blank lines. Indeed:
* This does not seem to match any specification in the documentation,
  where blank lines and lines starting with `#` are indiscriminately
  considered comments. In particular, no distinction is made between the
  comment above the first group and the comment at the beginning of the
  file.
* This distinction was only half implemented, resulting in confusion
  between comment above a group and comment at the end of the preceding
  group.

Instead, the same logic is used for groups as for keys: the comment
above a group is simply the sequence of key-value pairs of the preceding
group where the key is null, starting from the bottom.

The addition of a blank line above groups when writing, involved in
bugs #104 and #2927, is kept, but:
* It is now added as a comment as soon as the group is added (since a
  blank line is considered a comment), so that
  `g_key_file_get_comment()` returns the correct result right away.
* It is always added if comments are not kept.
* Otherwise it is only added if the group is newly created (not present
  in the original data), in order to really keep comments (existing and
  not existing).

Closes: #104, #2927
2023-04-20 16:59:04 +02:00
Gaël Bonithon
f74589f530 gkeyfile: Replace g_slice_*() with g_new*()/g_free_sized() 2023-04-20 16:52:19 +02:00
Marco Trevisan (Treviño)
d296e94559 appmonitor: Skip the test under OSX
Since commit c0ca3f99 this test is strictly depending on GDesktopAppInfo
that is not defined or available in macos, so skip the test as we do for
windows.

We could have done this at meson level too, but keeping it this way is
probably a better reminder that this should be adapted for such scenario
one day™

See: https://gitlab.gnome.org/GNOME/glib/-/jobs/2753753
2023-04-20 16:37:32 +02:00
Marco Trevisan
9f3c4ec940 Merge branch 'old-mac-sdk' into 'main'
gio: fix build on older macOS SDKs

See merge request GNOME/glib!3385
2023-04-20 13:12:06 +00:00
Peter Williams
bb19523a0a gio: fix build on older macOS SDKs
The merge request !2848 added code to automatically detect the module
prefix on macOS, with a test for the Mac #define TARGET_OS_OSX. However,
older versions of the SDK (at least 10.11) don't provide this #define,
leading to build failure. If the #define is missing, fall back to
checking TARGET_OS_MAC. On newer SDKs this symbol is also true for
watchOS, etc., but in those situations TARGET_OS_OSX is available.
2023-04-20 08:54:23 -04:00
Emmanuele Bassi
5f9f1104b9 Merge branch 'do-not-redefine-null-c++' into 'main'
gmacros: Do not redefine NULL on C++

Closes #2973

See merge request GNOME/glib!3387
2023-04-20 10:53:41 +00:00
Marco Trevisan (Treviño)
164f199afc gmacros: Do not redefine NULL on C++
Even though having NULL as nullptr should be the standard for newer C++
versions, it may break some headers, so let's not touch it for now.

Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/2973
2023-04-19 23:03:43 +02:00
Marco Trevisan (Treviño)
7d5242d34e gmain: Do not dead-look if calling g_main_loop_run from a GSource
This should fail and warn but not leaving the context acquired and
locked.

Add tests.
2023-04-19 22:52:43 +02:00
Marco Trevisan (Treviño)
f8e440335c gmain: Avoid locking dance in g_main_loop_run()
We do it during initialization, this may be if necessary handled by GCond in
case we need to acquire the lock.
2023-04-19 22:04:13 +02:00
Marco Trevisan (Treviño)
e7c2ead41b gmain: Avoid some lock/unlock dance during g_main_context_iterate
A context iteration we're doing lots of lock/unlocks and that's fine to give
other threads contexts a chance to run, but we're doing it also just to call
other functions that require locking, and this can be avoided.

Other threads can still have a chance to run while releasing the ownership
of the context.
2023-04-19 21:58:22 +02:00
Marco Trevisan
aa72638301 Merge branch 'fix-gsocket-receive-from-annotation' into 'main'
gsocket: Explicitly mark size parameter as (in)

See merge request GNOME/glib!3382
2023-04-19 19:19:41 +00:00
Marco Trevisan (Treviño)
fe38a02c62 gmodule: Define a gmodule include dependency and use it in gio modules
Various gio modules include gmodule.h that requires the
gmodule-visibility.h to be already built.

To make this easier, just provide a dependency and use it where we are
building modules that do not depend on libgio_dep (that already includes
that).

Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2982
2023-04-19 21:10:29 +02:00
Anders Jonsson
d4708c180d Update Swedish translation 2023-04-19 16:58:48 +00:00
Przemyslaw Gorszkowski
74d49e447f Test g_signal_handlers_disconnect_matched for G_SIGNAL_MATCH_ID match
Signed-off-by: Przemyslaw Gorszkowski <pgorszkowski@igalia.com>
2023-04-18 12:50:55 +02:00
Marco Trevisan
9f111c3416 Merge branch 'valgrind-variable' into 'main'
meson: Add glib_valgrind_suppressions variable to glib pkg-config file

See merge request GNOME/glib!3361
2023-04-17 12:52:28 +00:00
Marco Trevisan (Treviño)
c2e46b3789 meson: cleanup pkg-config variables definitions
Use more readable and shorter syntax
2023-04-17 14:25:52 +02:00
Marco Trevisan (Treviño)
ade79bcb50 meson: Add tests for generated pkg-config files
Ensure things are generated as we expect and avoid we regress on that.
2023-04-17 14:25:52 +02:00
Philip Withnall
7c1ef5c9ec Merge branch 'no-usleep-on-0' into 'main'
gtimer: Avoid doing anything on g_usleep (0)

See merge request GNOME/glib!3381
2023-04-17 11:44:36 +00:00