21615 Commits

Author SHA1 Message Date
Carlos Garnacho
1b03204e67 tests: Add splice cancellation test
This doesn't trigger the cancellation assertion issue when run locally
(the task didn't return yet, so the error is simply overwritten), but
perhaps it ever does in CI. Anyhow, it's good to have a cancellation
test.
2020-09-01 11:56:24 +01:00
Carlos Garnacho
40865e0ba7 goutputstream: Check individual close operations after splice
After a splice operation is finished, it attempts to 1) close input/output
streams, as per the given flags, and 2) return the operation result (maybe
an error, too).

However, if the operation gets cancelled early and the streams indirectly
closed, the splice operation will try to close both descriptors and return
on the task when both are already closed. The catch here is that getting the
streams closed under its feet is possible, so the completion callback would
find both streams closed after returning on the first close operation and
return the error, but then the second operation could be able to trigger
a second error which would be returned as well.

What happens here is up to further race conditions, if the task didn't
return yet, the returned error will be simply replaced (but the old one not
freed...), if it did already return, it'll result in:

GLib-GIO-FATAL-CRITICAL: g_task_return_error: assertion '!task->ever_returned' failed

Fix this by flagging the close_async() callbacks, and checking that both
close operations did return, instead of checking that both streams are
closed by who knows.

This error triggers a semi-frequent CI failure in tracker, see the summary at
https://gitlab.gnome.org/GNOME/tracker/-/issues/240
2020-09-01 11:56:24 +01:00
Philip Withnall
2560f61370 2.64.5
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2.64.5
2020-08-18 12:05:22 +01:00
Sebastian Dröge
b24969cefe Merge branch 'backport-1620-variant-depth-init-glib-2-64' into 'glib-2-64'
Backport !1620 “gvariant: Ensure GVS.depth is initialised” to glib-2-64

See merge request GNOME/glib!1621
2020-08-18 09:42:56 +00:00
Philip Withnall
2b6d4081e2 gvariant: Ensure GVS.depth is initialised
When byteswapping the depth was accidentally left uninitialised.

Coverity CID: #1430636
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-08-18 09:50:43 +01:00
Sebastian Dröge
03a53a9531 Merge branch 'backport-1617-subprocess-blocking-glib-2-64' into 'glib-2-64'
Backport !1617 “Ensure g_subprocess_communicate_async() never blocks” to glib-2-64

See merge request GNOME/glib!1618
2020-08-17 11:56:46 +00:00
Alexander Larsson
53c9497268 Ensure g_subprocess_communicate_async() never blocks
It turns out that our async write operation implementation is broken
on non-O_NONBLOCK pipes, because the default async write
implementation calls write() after poll() said there were some
space. However, the semantics of pipes is that unless O_NONBLOCK is set
then the write *will* block if the passed in write count is larger than
the available space.

This caused a deadlock in https://gitlab.gnome.org/GNOME/glib/-/issues/2182
due to the loop-back of the app stdout to the parent, but even without such
a deadlock it is a problem that we may block the mainloop at all.

In the particular case of g_subprocess_communicate() we have full
control of the pipes after starting the app, so it is safe to enable
O_NONBLOCK (i.e. we can ensure all the code using the fd after this can handle
non-blocking mode).

This fixes https://gitlab.gnome.org/GNOME/glib/-/issues/2182
2020-08-17 12:25:45 +01:00
Sebastian Dröge
94ef46477c Merge branch 'backport-1607-ios-frexpl-glib-2-64' into 'glib-2-64'
Backport !1607 “meson: Don't use gnulib for printf on iOS” to glib-2-64

See merge request GNOME/glib!1608
2020-08-06 09:46:08 +00:00
Nirbheek Chauhan
41af1187c3 meson: Don't use gnulib for printf on iOS
iOS and tvOS use the same printf family as macOS, and these all have
been available on macOS for a long time.

Closes https://gitlab.gnome.org/GNOME/glib/-/issues/1868
2020-08-06 10:17:43 +01:00
Emmanuele Bassi
d2a232aee0 Merge branch 'backport-1563-desktop-app-info-leak-glib-2-64' into 'glib-2-64'
Backport !1563 “gdesktopappinfo: Fix unnecessarily copied and leaked URI list” to glib-2-64

See merge request GNOME/glib!1565
2020-07-06 11:44:06 +00:00
Felix Riemann
47cdc8e35a gdesktopappinfo: Fix unnecessarily copied and leaked URI list
When an app is spawned using g_desktop_app_info_launch_uris_with_spawn
it will expand the various token in the app's commandline with the
URIs of the files to open. The expand_macro() function that is used for
this advances the pointer to the URI list to show up to which entries
it used.

To not loose the pointer to the list head a duplicate of the URI list
was actually passed to expand_macro(). However, it's not necessary to
create a copy of the URI list for that as expand_macro() will only
change which element the pointer will point to.

This behaviour actually caused the duplicated list to be leaked as the
the list pointer is NULL once all URIs are used up by expand_macro()
and thus nothing was freed at the end of the function.
2020-07-06 11:58:47 +01:00
Sebastian Dröge
2cbd8717e2 Merge branch 'backport-1517-win32-registry-assertions' into 'glib-2-64'
Backport !1517 “GWin32RegistryKey: Move assertions” to glib-2-64

See merge request GNOME/glib!1520
2020-07-02 14:30:16 +00:00
Sebastian Dröge
f418989128 Merge branch 'backport-1468-compile-resources-win32' into 'glib-2-64'
Backport !1468 “glib-compile-resources: Fix exporting on Visual Studio” to glib-2-64

See merge request GNOME/glib!1519
2020-07-02 14:29:54 +00:00
Philip Withnall
551bd5c1d1 2.64.4
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2.64.4
2020-07-02 13:58:20 +01:00
Baurzhan Muftakhidinov
8e7a483a73 Update Kazakh translation 2020-06-25 07:40:07 +00:00
Sebastian Dröge
d0e54ef794 Merge branch 'backport-1544-spawn-async-signal-safety-glib-2-64' into 'glib-2-64'
Backport !1544 “Resolve "calling malloc in fork child is undefined-behaviour"” to glib-2-64

See merge request GNOME/glib!1547
2020-06-24 11:58:49 +00:00
Philip Withnall
f99f0c2fab gspawn: Don’t use malloc() when running a binary under /bin/sh
Allocate a working buffer before calling `fork()` to avoid calling
`malloc()` in the async-signal-safe context between `fork()` and
`exec()`, where it’s not safe to use.

In this case, the buffer is used to assemble a wrapper around `argv` so
it can be run under `/bin/sh`.

See `man 7 signal-safety`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #2140
2020-06-24 11:40:22 +01:00
Philip Withnall
cc8715c3b7 gspawn: Don’t use malloc() when searching for a binary
Allocate a working buffer before calling `fork()` to avoid calling
`malloc()` in the async-signal-safe context between `fork()` and
`exec()`, where it’s not safe to use.

In this case, the buffer is used to assemble elements from `PATH` with
the binary from `argv[0]` to try executing them.

See `man 7 signal-safety`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2140
2020-06-24 11:40:22 +01:00
Philip Withnall
3548996c0e gspawn: Don’t use getenv() in async-signal-safe context
Query the environment before calling `fork()` so that it doesn’t have to
be called in the async-signal-safe context between `fork()` and
`exec()`.

See `man 7 signal-safety`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2140
2020-06-24 11:40:22 +01:00
Philip Withnall
45b8e60ac4 gspawn: Don’t use getrlimit() or sysconf() in async-signal-safe context
They’re not safe to call in an async-signal-safe context on Linux.
`sysconf()` is safe to call on FreeBSD and OpenBSD (at least), so
continue doing that.

This will reduce performance in the (already low performance) fallback
case where `/proc` is inaccessible to a forked process on Linux, while
spawning a subprocess.

See `man 7 signal-safety`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2140
2020-06-24 11:40:21 +01:00
Philip Withnall
923315ef82 gspawn: Don’t use g_assert() in async-signal-safe context
Use the error handling infrastructure which already exists for other
failures in the async-signal-safe context.

`g_assert()` is unlikely to have caused problems in practice because it
is only async-signal-unsafe when the assertion condition fails.

See `man 7 signal-safety`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2140
2020-06-24 11:40:21 +01:00
Philip Withnall
d24acc7ea5 gspawn: Don’t use g_ascii_isdigit() in async-signal-safe context
While `g_ascii_isdigit()` *is* currently async-signal-safe, it’s going
to be hard to remember to keep it that way if the implementation changes
in future.

It seems more robust to just reimplement it here, given that it’s not
much code.

See `man 7 signal-safety`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2140
2020-06-24 11:40:21 +01:00
Philip Withnall
539d51836a gspawn: Don’t use g_close() in async-signal-safe context
Use normal `close()` instead, which is guaranteed to be
async-signal-safe.

See `man 7 signal-safety`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2140
2020-06-24 11:40:21 +01:00
Philip Withnall
92eac2f424 gspawn: Audit for async-signal-safety
Functions called between `fork()` and `exec()` have to be
async-signal-safe.

Add a comment to each function which is called in that context, and
`FIXME` comments to the non-async-signal-safe functions which end up
being called as leaves of the call graph.

The following commits will fix those `FIXME`s.

See `man 7 signal-safety`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #2140
2020-06-24 11:40:21 +01:00
Philip Withnall
aae98ce774 tree: Fix various ableist language
In almost all cases, rewording the documentation/comments made things
more specific and a little clearer.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1544#note_846645
2020-06-24 11:40:21 +01:00
Matej Urbančič
4abdd10e48 Updated Slovenian translation 2020-06-22 21:00:31 +02:00
Nirbheek Chauhan
175b7e2727 Merge branch 'backport-1522-meson-printf-checks-glib-2-64' into 'glib-2-64'
Backport !1522 “meson: Fix gnulib printf checks” to glib-2-64

See merge request GNOME/glib!1523
2020-06-09 04:00:23 +00:00
Nirbheek Chauhan
d8d5664ba9 meson: Fix gnulib printf checks
Some typos, and accidental usage of the strings `'true'` / `'false'`
instead of the booleans `true` / `false`.
2020-06-08 15:20:00 +01:00
Руслан Ижбулатов
98570e2d69 GWin32RegistryKey: Move assertions
While these assertions look right at the first glance,
they actually crash the program. That's because GObject
insists on initializing all construct-only properties
to their default values, which results in
g_win32_registry_key_set_property() being called multiple
times with NULL string, once for each unset property.

If "path" is actually set by the caller, a subsequent
call to set "path-utf16" to NULL will fail an assertion,
since absolute_path is already non-NULL.

With assertions moved the set-to-NULL calls bail out before
an assertion is made.
2020-06-05 12:47:26 +01:00
Chun-wei Fan
e56a2865cb glib-compile-resources: Fix exporting on Visual Studio
Have the generated .c code decorate the prototypes with "G_MODULE_EXPORT"
instead of "extern" when --internal is not being used, so that we also
export the symbols from the generated code on Visual Studio-style
compilers.  If --internal is used, we decorate the prototypes with
"G_GNUC_INTERNAL", as we did before.

Note that since the generated .c code does not attempt to include the
generated headers (if one is also generated), the gnerated headers are
still generated as they were before.
2020-06-05 11:58:47 +01:00
Sebastian Dröge
2068a6c484 Merge branch 'backport-1504-win32-poll-glib-2-64' into 'glib-2-64'
Backport !1504 “win32 gpoll: Fix wait for at least one thread to return” to glib-2-64

See merge request GNOME/glib!1507
2020-05-22 10:32:16 +00:00
majordaw
66b56ee9d8 win32 gpoll: Fix wait for at least one thread to return
When timeout grater than 0 in g_poll function, the WaitForMultipleObjects
call will wait for all the threads to return, but when only one thread
got an event the others will sleep until the timeout elapses, and causes
a stall. Triggering the stop event in g_poll in this case is useless as
it is triggered when all the threads where already signaled or timed-out.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/2107
2020-05-22 09:15:47 +01:00
Philip Withnall
af1edc1c33 2.64.3
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2.64.3
2020-05-20 11:45:25 +01:00
Philip Withnall
f39b885c0b Merge branch 'backport-1493-meson-typo-glib-2-64' into 'glib-2-64'
Backport !1493 “meson: Remove stray ], in O_DIRECTORY check” to glib-2-64

See merge request GNOME/glib!1495
2020-05-19 16:48:33 +00:00
Chris Packham
15e73829aa meson: Remove stray ], in O_DIRECTORY check
A stray ], was leftover from the autotools -> meson conversion. Remove
it.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
2020-05-19 16:35:06 +01:00
Sebastian Dröge
50ccd7b714 Merge branch 'backport-1439-stpcpy-fix-glib-2-64' into 'glib-2-64'
Backport !1439 “Fix stpcpy() detection“ to glib-2-64

See merge request GNOME/glib!1501
2020-05-19 15:29:12 +00:00
Martin Storsjö
3c5512222c meson: Don't misdetect stpcpy on windows platforms on clang
See https://github.com/mesonbuild/meson/issues/3672 and
https://github.com/mesonbuild/meson/issues/5628 for explanations
of cases where meson misdetects functions due to clang builtins (that
always are available, regardless of whether the platform actually
provides them).

The same also happens on GCC 10, which added support for __has_builtin.
2020-05-19 15:46:45 +01:00
Cheng-Chia Tseng
c49ee9efbd Update Chinese (Taiwan) translation 2020-05-17 17:11:02 +00:00
Cheng-Chia Tseng
d06de90330 Update Chinese (Taiwan) translation 2020-05-17 17:00:33 +00:00
Cheng-Chia Tseng
e55f6a95b5 Update Chinese (Taiwan) translation 2020-05-17 16:54:18 +00:00
Emmanuele Bassi
624e18f0fb Merge branch 'backport-1440-format-nonliteral-glib-2-64' into 'glib-2-64'
Backport !1440 -Wformat-nonliteral fixes to glib-2-64

See merge request GNOME/glib!1470
2020-05-14 14:08:27 +00:00
Emmanuele Bassi
46756977a1 Merge branch 'backport-1448-dbus-tests-glib-2-64' into 'glib-2-64'
Backport !1448 memory monitor test dependency fixes to glib-2-64

See merge request GNOME/glib!1471
2020-05-14 14:06:55 +00:00
Emmanuele Bassi
b53de16538 Merge branch 'backport-1481-ptr-array-corruption-fix' into 'glib-2-64'
Backport !1481 “array: fix corrupt state of GPtrArray after g_ptr_array_extend_and_steal()” to glib-2-64

See merge request GNOME/glib!1483
2020-05-14 14:06:14 +00:00
Emmanuele Bassi
f66e56bc2b Merge branch 'backport-1472-thread-deprecation-warnings-glib-2-64' into 'glib-2-64'
Backport !1472 “gthread: ignore deprecated declarations in static inline functions” to glib-2-64

See merge request GNOME/glib!1486
2020-05-14 14:05:12 +00:00
Simon Marchi
5ee80104ac gthread: ignore deprecated declarations in static inline functions
With a trivial file that just includes glib.h:

    #include <glib.h>

Compiled with:

    gcc -c test.c \
      -I /tmp/glib/include/glib-2.0/ \
      -I /tmp/glib/lib/x86_64-linux-gnu/glib-2.0/include \
      -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_28 \
      -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28 \
      -fmax-errors=1 \
      -Werror

We get:

    In file included from /tmp/glib/include/glib-2.0/glib/gasyncqueue.h:32,
                     from /tmp/glib/include/glib-2.0/glib.h:32,
                     from test.c:1:
    /tmp/glib/include/glib-2.0/glib/gthread.h: In function ‘g_rec_mutex_locker_new’:
    /tmp/glib/include/glib-2.0/glib/gthread.h:396:3: error: ‘g_rec_mutex_lock’ is deprecated: Not available before 2.32 [-Werror=deprecated-declarations]
      396 |   g_rec_mutex_lock (rec_mutex);
          |   ^~~~~~~~~~~~~~~~
    /tmp/glib/include/glib-2.0/glib/gthread.h:196:17: note: declared here
      196 | void            g_rec_mutex_lock                (GRecMutex      *rec_mutex);
          |                 ^~~~~~~~~~~~~~~~
    compilation terminated due to -fmax-errors=1.

The problem is that the code in the static inline functions uses
g_rec_mutex_lock, introduced after 2.28.  This code is compiled
regardless of if it's actually used or not.

Suppress the warning by using G_GNUC_BEGIN_IGNORE_DEPRECATIONS /
G_GNUC_END_IGNORE_DEPRECATIONS.  There are precedents for doing that,
for example g_main_context_pusher_new in gmain.h.

Tested by building with all variations of GLIB_VERSION_MIN_REQUIRED /
GLIB_VERSION_MAX_ALLOWED:

    for i in $(seq 26 2 64); do
      gcc -c test.c \
        -I/tmp/glib/include/glib-2.0 \
        -I/tmp/glib/lib/x86_64-linux-gnu/glib-2.0/include \
        -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_$i \
        -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_$i \
        -fmax-errors=1 \
        -Werror
    done

Fixes: #2094
2020-05-07 11:10:21 +01:00
Christoph Reiter
b715f7535a Merge branch 'backport-1480-msys2-ci-fix-glib-2-64' into 'glib-2-64'
Backport !1480 “CI: Make sure we use meson 0.49.2 in MSYS2” to glib-2-64

See merge request GNOME/glib!1484
2020-05-07 09:48:18 +00:00
Christoph Reiter
857a91833c CI: Make sure we use meson 0.49.2 in MSYS2
pip in MSYS2 seems to install scripts into $USERPROFILE instead of $HOME
which means the MSYS2 meson, which is newer, wins. Make sure $USERPROFILE
is in PATH as well.
2020-05-07 09:48:49 +01:00
Thomas Haller
ebc518da45 array: fix corrupt state of GPtrArray after g_ptr_array_extend_and_steal()
g_ptr_array_extend_and_steal() leaves the GPtrArray in an invalid state,
so if you would try to append another pointer, it leads to a crash.

Also adjust the test case so that it would result in the crash (without
the fix).

Fixes: 0675703af08d ('Adding g_ptr_array_extend_and_steal() function to glib/garray.c')
2020-05-07 09:44:40 +01:00
Simon McVittie
d020a73b66 Merge branch 'backport-1477-dbus-keyring-handling-glib-2-64' into 'glib-2-64'
Backport !1477 D-Bus keyring handling fixes to glib-2-64

See merge request GNOME/glib!1478
2020-05-05 18:46:28 +00:00
Philip Withnall
f3b6700256 gdbusauthmechanismsha1: Reduce syscalls from ensure_keyring_directory()
There’s no need to call `access()` and then `stat()` on the keyring
directory to check that it exists, is a directory, and has the right
permissions. Just call `stat()`.

This eliminates one potential TOCTTOU race in this code.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1954
2020-05-05 17:46:31 +01:00