Commit Graph

27178 Commits

Author SHA1 Message Date
Alexander Kanavin
b4d60ba136 glib/gfileutils.c: use 64 bits for value in get_tmp_file()
On 32 bit systems 'long' value will overflow in 2038 and become negative.
As it is used to index into letters array, and % operation preserves signs,
data corruption will then occur.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
2023-08-24 10:11:14 +01:00
Emmanuele Bassi
40fb81f0ea Merge branch 'backport-3529-menu-exporter-locking-glib-2-76' into 'glib-2-76'
Backport !3529 “gmenuexporter: synchronization in org_gtk_Menus_get_interface.” to glib-2-76

See merge request GNOME/glib!3531
2023-08-14 12:45:30 +00:00
André
572f8ab534 gmenuexporter: synchronization in org_gtk_Menus_get_interface.
Protects the mutation inside org_gtk_Menus_get_interface with
g_once_init_{enter,leave}.

Fixes #3051.
2023-08-14 09:15:29 +01:00
Philip Withnall
f522c3f94d
2.76.4
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-06 16:39:47 +01:00
Michael Catanzaro
3ed76cbbbd Merge branch 'backport-3473-errno-futex-glib-2-76' into 'glib-2-76'
Backport !3473 ”glib: reset errno to 0 when futex() returns EAGAIN” to glib-2-76

See merge request GNOME/glib!3479
2023-07-05 14:55:53 +00:00
Philip Withnall
ede36ac6ab Merge branch 'backport-3482-android-statx-glib-2-76' into 'glib-2-76'
Backport !3482 “glocalfileinfo: Fix incorrect use of struct statx.st_mtimensec on Android” to glib-2-76

See merge request GNOME/glib!3492
2023-07-05 11:58:15 +00:00
Luca Bacci
f3baa03b48 glocalfileinfo: Fix GLocalFileStat getters on MinGW x86
For some reason, `time_t` is defined as being 32 bits wide on that
platform, which causes truncation of the timestamps from `struct stat`.

Avoid that problem by consistently using a 64-bit return value from the
`struct stat` accessors.

Helps: #3039
2023-07-04 17:19:50 +01:00
Philip Withnall
4a9c00fa94 glocalfileinfo: Delete some redundant code
`_g_stat_has_field (statbuf, G_LOCAL_FILE_STAT_FIELD_ATIME)` will always
return `TRUE` on Windows (since it uses a basic `struct stat`), so the
platform-inspecific code is equivalent to the Windows-specific code.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-07-04 17:19:49 +01:00
Philip Withnall
0feee5b670 glocalfileinfo: Fix incorrect use of struct statx.st_mtimensec on Android
`GLocalFileStat` is a platform-specific abstraction around `struct stat`
or `struct statx`. If `struct statx` is available, it will use that by
preference as it has more features.

`glocalfileinfo.c` was, in some places, incorrectly accessing the fields
of `GLocalFileStat` directly rather than through its `_g_stat_*()`
getters. While it correctly accounted for the platform-specific
differences between `st_mtimensec` and `st_mtim.tv_nsec`, it hadn’t been
updated to deal with `stx_mtime`.

On Android, `st_mtimensec` is defined as a fallback for
`st_mtim.tv_nsec` (even though it doesn’t need to be). This caused GLib
to take the `st_mtimensec` code path rather than the `stx_mtime` code
path, and hence try to dereference `st_mtim` in a `struct statx`.

Fix that by correctly using the `_g_stat_*()` getters consistently.

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

Fixes: #3039
2023-07-04 17:19:49 +01:00
Bruce Cowan
2d3bcc9401 Update British English translation 2023-07-02 20:09:17 +00:00
Michael Catanzaro
2c97a0c06d Merge branch 'wip/pwithnall/backport-3468-macos-spawn-crash-glib-2-76' into 'glib-2-76'
Backport !3468 “Avoid stack overflow in gspawn on macOS” to glib-2-76

See merge request GNOME/glib!3480
2023-06-28 15:36:49 +00:00
Dario Saccavino
9f5590aee1 Avoid stack overflow in gspawn on macOS 2023-06-28 14:43:32 +01:00
Daniel P. Berrange
b74ff41bef glib: reset errno to 0 when futex() returns EAGAIN 2023-06-28 12:47:18 +01:00
Dušan Kazik
49c2fe77c1 Update Slovak translation 2023-06-14 13:52:23 +00:00
Leônidas Araújo
7f8bb8a2ea Update Brazilian Portuguese translation 2023-06-01 18:25:13 +00:00
Marco Trevisan
5ae2d68ac3 Merge branch 'backport-3446-glib-compile-schemas-failed-glib-2-76' into 'glib-2-76'
Backport !3446 “glib-compile-resources: Fix non-ASCII arg parsing on Windows” to glib-2-76

See merge request GNOME/glib!3447
2023-05-24 08:57:31 +00:00
Daniyar Tleulin
6c6a844a50 glib-compile-schemas: Fix non-ASCII arg parsing on Windows
When the source directory contains non-ASCII symbols,
argument parsing previously failed on MINGW64.

Fixes: #3003
2023-05-23 18:21:29 +01:00
Daniyar Tleulin
7e41ac18da glib-compile-resources: Fix non-ASCII arg parsing on Windows
When the source directory contains non-ASCII symbols,
argument parsing previously failed on MINGW64.

Fixes: #3003
2023-05-23 18:21:29 +01:00
Philip Withnall
69e209764b
2.76.3
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-23 11:55:59 +01:00
Emmanuele Bassi
791495e5b9 Merge branch 'backport-3430-gdb-fix-glib-2-76' into 'glib-2-76'
Backport !3430 “gobject_gdb.py: fix regression caused by bfbe7127d5” to glib-2-76

See merge request GNOME/glib!3434
2023-05-16 12:03:52 +00:00
Nelson Benítez León
0647121b38 gobject_gdb.py: fix regression caused by bfbe7127d5
commit bfbe7127d5 which did a code refactor in
gobject_gdb.py introduced a bug by failing to
return the signal name when a signal had no
'detail', this was preventing pretty printing
name for signals with no 'detail'.
2023-05-16 11:31:35 +01:00
Philip Withnall
42203f089d Merge branch 'backport-3291-dbus-connection-refcounting-glib-2-76' into 'glib-2-76'
Backport !3291 “gdbusconnection: Fix double unref on timeout/cancel sending a message” to glib-2-76

See merge request GNOME/glib!3427
2023-05-09 17:28:17 +00:00
Philip Withnall
60e06dd828 gdbusconnection: Improve refcount handling of timeout source
The ref on the timeout source owned by `SendMessageData` was being
dropped just after attaching the source to the main context, leaving it
unowned in that struct. That meant the only ref on the source was held
by the `GMainContext` it was attached to.

This ref was dropped when returning `G_SOURCE_REMOVE` from
`send_message_with_reply_timeout_cb()`. Before that happens,
`send_message_data_deliver_error()` is called, which normally calls
`send_message_with_reply_cleanup()` and destroys the source.

However, if `send_message_data_deliver_error()` is called when the
message has already been delivered, calling
`send_message_with_reply_cleanup()` will be skipped. This leaves the
source pointer in `SendMessageData` dangling, which will cause problems
when `g_source_destroy()` is subsequently called on it.

I’m not sure if it’s possible in practice for this situation to occur,
but the code certainly does nothing to prevent it, and it’s easy enough
to avoid by keeping a strong ref on the source in `SendMessageData`.

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

Helps: #1264
2023-05-09 18:10:16 +01:00
Philip Withnall
c4055424a4 gdbusconnection: Rearrange refcount handling of map_method_serial_to_task
It already implicitly held a strong ref on its `GTask` values, but
didn’t have a free function set so that they would be automatically
unreffed on removal from the map.

This meant that the functions handling removals from the map,
`on_worker_closed()` (via `cancel_method_on_close()`) and
`send_message_with_reply_cleanup()` had to call unref once more than
they would otherwise.

In `send_message_with_reply_cleanup()`, this behaviour depended on
whether it was called with `remove == TRUE`. If not, it was `(transfer
none)` not `(transfer full)`. This led to bugs in its callers.

For example, this led to a direct leak in `cancel_method_on_close()`, as
it needed to remove tasks from `map_method_serial_to_task`, but called
`send_message_with_reply_cleanup(remove = FALSE)` and erroneously didn’t
call unref an additional time.

Try and simplify it all by setting a `GDestroyNotify` on
`map_method_serial_to_task`’s values, and making the refcount handling
of `send_message_with_reply_cleanup()` not be conditional on its
arguments.

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

Helps: #1264
2023-05-09 18:10:16 +01:00
Philip Withnall
ffbb66e263 gdbusprivate: Use G_SOURCE_REMOVE in a source callback
This is equivalent to the current behaviour, but a little clearer in its
meaning.

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

Helps: #1264
2023-05-09 18:10:16 +01:00
Philip Withnall
3ed468f572 gdbusprivate: Improve ownership docs for write_message_async()
The ownership transfers in this code are a bit complex, so adding some
extra documentation and `g_steal_pointer()` calls should hopefully help
clarify things.

This doesn’t introduce any functional changes, just code documentation.

Another drive-by improvement in the quest for #1264.

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

Helps: #1264
2023-05-09 18:10:16 +01:00
Philip Withnall
49cfe8d047 gdbusprivate: Ensure data->task is cleared when it returns
The existing comment in the code was correct that `data` is freed when
the task callback is called, because `data` is also pointed to by the
`user_data` for the task, and that’s freed at the end of the callback.

So the existing code was correct to take a copy of `data->task` before
calling `g_task_return_*()`.

After calling `g_task_return_*()`, the existing code unreffed the task
(which is correct), but then didn’t clear the `data->task` pointer,
leaving `data->task` dangling. That could cause a use-after-free or a
double-unref.

Avoid that risk by explicitly clearing `data->task` before calling
`g_task_return_*()`.

After some testing, it turns out this doesn’t actually fix any bugs, but
it’s still a good robustness improvement.

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

Helps: #1264
2023-05-09 18:10:16 +01:00
Philip Withnall
4d12d3c56d gdbusprivate: Improve docs on message ownership in MessageToWriteData
This doesn’t introduce any functional changes, but should make the code
a little clearer.

Drive-by improvements while trying to debug #1264.

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

Helps: #1264
2023-05-09 18:10:16 +01:00
Philip Withnall
d0501f6ac3 gdbusconnection: Improve docs of message ownership in closures
This introduces no functional changes, but makes it a little clearer how
the ownership of these `GDBusMessage` instances works. The free function
is changed to `g_clear_object()` to avoid the possibility of somehow
using the messages after freeing them.

Basically just some drive-by docs improvements while trying to debug
issue #1264.

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

Helps: #1264
2023-05-09 18:10:16 +01:00
Philip Withnall
feb9bd9fd2 gdbusconnection: Fix the type of a free function
This didn’t actually cause any observable bugs, since the structures of
`PropertyData` and `PropertyGetAllData` were equivalent for the members
which the free function touches.

Definitely should be fixed though.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-09 18:10:16 +01:00
Philip Withnall
a218dfea16 gdbusconnection: Fix double unref on timeout/cancel sending a message
This appears to fix an intermittent failure seen when sending a D-Bus
message with either of a cancellable or a timeout set.

In particular, I can reliably reproduce it with:
```
meson test gdbus-test-codegen-min-required-2-64 --repeat 10000
```

It can be caught easily with asan when reproduced. Tracking down the
location of the refcount mismatch was a little tricky, but was
simplified by replacing a load of `g_object_ref (message)` calls with
`g_dbus_message_copy (message, NULL)` to switch `GDBusMessage` handling
to using copy semantics. This allowed asan to home in on where the
refcount mismatch was happening.

The problem was that `send_message_data_deliver_error()` takes ownership
of the `GTask` passed to it, but the
`send_message_with_replace_cancelled_idle_cb()` and
`send_message_with_reply_timeout_cb()` functions which were calling it,
were not passing in a strong reference as they should have.

Another approach to fixing this would have been to change the transfer
semantics of `send_message_data_deliver_error()` so it was `(transfer
none)` on its `GTask`. That would probably have resulted in cleaner
code, but would have been a lot harder to verify/review the fix, and
easier to inadvertently introduce new bugs.

The fact that the bug was only triggered by the cancellation and timeout
callbacks explains why it was intermittent: these code paths are
typically never hit, but the timeout path may sometimes be hit on a very
slow test run.

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

Fixes: #1264
2023-05-09 18:10:16 +01:00
Marco Trevisan
00ae70bffb Merge branch 'backport-3425-win32-network-monitor-error-glib-2-76' into 'glib-2-76'
Backport !3425 “gwin32networkmonitor: Fix returning address of local variable” to glib-2-76

See merge request GNOME/glib!3428
2023-05-09 16:36:59 +00:00
Philip Withnall
59e4ca1a4b gwin32networkmonitor: Fix returning address of local variable
Something has changed recently which causes this error to now be emitted
when building on Windows msys2-mingw32:
```
../gio/gwin32networkmonitor.c: In function 'win_network_monitor_get_ip_info':
../gio/gwin32networkmonitor.c:92:15: error: storing the address of local variable 'prefix' in '*dest' [-Werror=dangling-pointer=]
   92 |         *dest = (guint8 *) &prefix.Prefix.Ipv4.sin_addr;
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

If `IP_ADDRESS_PREFIX` is defined as a scalar rather than a pointer,
that could explain the problem.

Change the function to always operate on a pointer to avoid any
potential such issues.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-05-09 14:10:12 +01:00
Marco Trevisan
b7ac1a3787 Merge branch 'backport-3398-futex-errno-glib-2-76' into 'glib-2-76'
Backport !3398 “Avoid having g_futex_simple() inadvertently modify errno” to glib-2-76

See merge request GNOME/glib!3402
2023-04-27 09:21:48 +00:00
Fran Dieguez
665d01fbca Update Galician translation 2023-04-27 09:07:24 +00:00
Michael Catanzaro
1db9976099 Merge branch 'backport-3400-error-literals-dngettext-glib-2-76' into 'glib-2-76'
Backport !3400 “Revert "Fix error format in gio/gunixconnection.c (part 2)"” to glib-2-76

See merge request GNOME/glib!3403
2023-04-26 18:02:40 +00:00
James Knight
aae4df5c6b 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-26 17:30:18 +01:00
James Knight
a47bd14e83 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-26 17:30:18 +01:00
Peter Kjellerstedt
d5c5685ad3 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 15:06:37 +01:00
Marco Trevisan (Treviño)
41ae5b5632
2.76.2
Signed-off-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
2023-04-21 16:46:05 +02:00
Marco Trevisan (Treviño)
4ed5539d0a 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


(cherry picked from commit fe38a02c62)
2023-04-21 10:00:34 -04:00
James Knight
e82348db62 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>


(cherry picked from commit 4ae8606b6f)
2023-04-21 08:05:50 -04:00
Marco Trevisan (Treviño)
aa3e3225a7 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


(cherry picked from commit d296e94559)
2023-04-20 13:10:00 -04:00
badcel
fd92dfd78a gsocket: Explicitly mark size parameter as (in)
The generated gir file marks the size parameter as "out" by default. This is wrong in the context of a caller allocated buffer with a given size. Explicitly marking the size parameter as (in) fixes the issue.


(cherry picked from commit f510fa0227)
2023-04-20 08:46:14 -04:00
Marco Trevisan (Treviño)
d677b483a7 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


(cherry picked from commit 164f199afc)
2023-04-20 08:37:27 -04:00
Marco Trevisan
45300ae6ea Merge branch 'signal-handler-matching-docs' into 'main'
gsignal: Clarify documentation for GSignalMatchType matching

See merge request GNOME/glib!3377
2023-04-14 13:53:49 +00:00
Philip Withnall
2d8e38c00d gsignal: Clarify documentation for GSignalMatchType matching
The use of ‘OR’ in the existing documentation suggests that the matching
is disjunctive, but it’s actually conjunctive. Clarify that in the
documentation and add a test.

Spotted while reviewing
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3376.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2023-04-14 13:55:20 +01:00
Emmanuele Bassi
2f828ef2d4 Merge branch '95-markup-docs' into 'main'
docs: Add simple GMarkup parser example

Closes #95

See merge request GNOME/glib!3364
2023-04-13 21:37:41 +00:00
Emmanuele Bassi
b94d0c2168 Merge branch '799-app-info-monitor-docs' into 'main'
gappinfo: Clarify one-shot behaviour of GAppInfoMonitor::changed in docs

Closes #799

See merge request GNOME/glib!3346
2023-04-13 21:37:36 +00:00
Emmanuele Bassi
2af45f9c20 Merge branch 'libicu-tests' into 'main'
unicode: add tests for g_utf8_normalize() and empty strings

See merge request GNOME/glib!3326
2023-04-13 21:35:51 +00:00