Commit Graph

21470 Commits

Author SHA1 Message Date
Philip Withnall
0f0af5ae3a tests: Mark gdbus-threading as non-flaky any more
See previous commits and #1515.

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

Fixes: #1515
2020-02-24 09:03:02 +00:00
Philip Withnall
f74a987d21 tests: Use TestSignal rather than NameOwnerChanged to test signals
When testing that signals are delivered to the correct thread, and are
delivered the correct number of times, call `EmitSignal()` on the
`gdbus-testserver` to trigger a signal emission, and listen for that.

Previously, the code listened for `NameOwnerChanged` and connected to
the bus again to trigger emission of that. The problem with that is that
other things happening on the bus (for example, an old
`gdbus-testserver` instance disconnecting) can cause `NameOwnerChanged`
signal emissions. Sometimes, the `gdbus-threading` test was failing the
`signal_count == 1` assertion due to receiving more than one
`NameOwnerChanged` emission.

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

Helps: #1515
2020-02-24 09:03:02 +00:00
Philip Withnall
cd0ab355cd tests: Use GMainContext instead of GMainLoop in gdbus-threading
This is equivalent, but makes the loop exit conditions a little clearer,
since they’re actually in a `while` statement, rather than being a
`g_main_loop_quit()` call in a callback somewhere else in the file.

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

Helps: #1515
2020-02-24 09:03:02 +00:00
Philip Withnall
79ef610f03 tests: Wait until unsubscribing from a signal has completed
As with the previous commit, don’t stop iterating the `context` in
`test_delivery_in_thread_func()` until the unsubscription from a signal
is complete, and hence there’s a guarantee that no callbacks are pending
in the `thread_context`.

This commit uses the `GDestroyNotify` for
`g_dbus_connection_signal_subscribe()` as a synchronisation message from
the D-Bus worker thread to the `test_delivery_in_thread_func()` thread
to notify of signal unsubscription.

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

Fixes: #1515
2020-02-24 09:01:03 +00:00
Philip Withnall
af6dbece87 tests: Wait until unwatching the gdbus-testserver name has completed
Previously, the code in `ensure_gdbus_testserver_up()` created a proxy
object and watched its `name-owner` to see when the
`com.example.TestService` name appeared.

This ended up subscribing to three signals (one of them for name
ownership, and two unused for properties of the proxy), and was racy. In
particular, the `name-owner` property could be set before all D-Bus
messages had been processed — it could have been derived from getting
the owner of the name, for example.

This left unprocessed messages hanging around in the `context`, but that
context was never iterated again, which essentially leaked the
references held by those messages. That included a reference to the
`GDBusConnection`.

The first part of the fix is to simplify the code to use
`g_bus_watch_name_on_connection()`, so there’s only one signal
subscription to worry about.

The second part of the fix is to use the `GDestroyNotify` callback for
the watch data to be notified of when all D-Bus traffic has been
processed and the signal unsubscription is complete. At this point, it’s
guaranteed that there are no idle callbacks pending in the
`GMainContext`, since the `GDestroyNotify` callback is the last one
invoked on the `GMainContext`.

Essentially, this commit uses the `GDestroyNotify` callback as a
synchronisation message between the D-Bus worker thread and the thread
calling `ensure_gdbus_testserver_up()`.

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

Fixes: #1515
2020-02-24 09:01:03 +00:00
Philip Withnall
ac274b4005 tests: Add timeout to assert_connection_has_one_ref()
Iterate the given `context` while waiting, rather than sleeping. This
ensures that if the errant `GDBusConnection` ref is held by some pending
callback in the given `context`, it will actually be released.

Typically `context` is going to be the global default main context.

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

Helps: #1515
2020-02-24 09:00:59 +00:00
Philip Withnall
b2e543f6a4 tests: Take explicit connection and context when ensuring testserver up
This introduces no functional changes, but makes the code a little more
explicit about which connection and main context it’s operating on.

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

Helps: #1515
2020-02-24 07:46:22 +00:00
Philip Withnall
1a51681e6d gdbusconnection: Simplify some control flow
This removes an unhelpful `goto`. It introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 07:46:22 +00:00
Philip Withnall
bcee182a49 gdbusconnection: Drop an unnecessary GMainContext reference
`CallDestroyNotifyData` never uses that `GMainContext`, and holding a
ref to it could cause reference count cycles if the `GMainContext` is no
longer being iterated.

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

Helps: #1515
2020-02-24 07:46:22 +00:00
Philip Withnall
cc11c79e4b gdbusproxy: Simplify a pointer theft
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 07:46:22 +00:00
Philip Withnall
d9dab2b319 gdbusproxy: Tidy up some memory management code
Use `g_clear_object()` to tidy things up. This introduces no functional
changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 07:46:22 +00:00
Philip Withnall
72afc79346 gdbusproxy: Replace home-grown weak ref implementation with GWeakRef
The fix for bgo#651133 (commit 7e0f890e38) introduced a kind of weak
ref, which had to be thread-safe due to the fact that `GDBusProxy`
operates in one thread but can emit signals in another.

Since that commit, `GWeakRef` was added, which does the same thing. Drop
the custom code in favour of it; this should be functionally equivalent,
but using an RW lock rather than a basic mutex, which should reduce
contention.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 07:46:22 +00:00
Philip Withnall
b302ee956e tests: Move refcount checks to the end of each test in gdbus-threading
These checks used to be a precondition on test_threaded_singleton(); but
the earlier tests could leave the refcount of the shared connection in a
bad state, and this wouldn’t be caught until later.

Factor out the check, increase the iteration count to 1000 (so the check
blocks for up to 1s rather than 100ms), and call it in more places.

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

https://gitlab.gnome.org/GNOME/glib/issues/1515
2020-02-24 07:46:22 +00:00
Philip Withnall
6b786ac3e9 tests: Port gdbus-threading to use g_assert_*() rather than g_assert()
g_assert() can be compiled out with G_DISABLE_ASSERT, which renders the
test rather useless.

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

https://gitlab.gnome.org/GNOME/glib/issues/1515
2020-02-24 07:46:22 +00:00
Changwoo Ryu
7e926cb93a Update Korean translation 2020-02-22 10:47:39 +00:00
Simon McVittie
83b7aa5099 Merge branch 'wip/hadess/avoid-unintended-success' into 'master'
ci: Don't ignore xdg-desktop-portal build failure

Closes #2043

See merge request GNOME/glib!1377
2020-02-21 19:36:15 +00:00
Bastien Nocera
f333a8058d ci: Fix xdg-desktop-portal build
Newer versions of xdg-desktop-portal need a newer PipeWire, so use the
latest release that doesn't contain this change to avoid having
something else to build.
2020-02-21 19:50:12 +01:00
Bastien Nocera
7263fc5591 ci: Don't ignore xdg-desktop-portal build failure
CI scripts are done using a shell with 'set -e' enabled, but using
'&&' means that the line won't "fail". Run the different commands
sequentially instead.

Spotted by Simon McVittie <smcv@collabora.com>

Closes: #2043
2020-02-21 18:49:56 +01:00
Nirbheek Chauhan
167fbe5be9 Merge branch 'fix-w32-csharp-exception-handling' into 'master'
Fix win32 C# exception handling when running inside a debugger

Closes #2025

See merge request GNOME/glib!1373
2020-02-20 15:14:21 +00:00
Efstathios Iosifidis
d7672af573 Update Greek translation 2020-02-18 23:09:30 +00:00
Nirbheek Chauhan
0cfbe8f3b0 gwin32: Do not register a crash handler unless requested
Fixes https://gitlab.gnome.org/GNOME/glib/issues/2025
2020-02-18 23:24:52 +05:30
Nirbheek Chauhan
6919a719c1 gwin32: Do not ignore exceptions when running under a debugger
We're supposed to return `EXCEPTION_CONTINUE_SEARCH` here to tell the
vectored exception handler (VEH) to move on to the next exception
handler instead of skipping them all and trying to continue execution.

Swallowing exceptions messes up CLR exception processing and breaks C#
code. For more details, see:
https://blogs.msdn.microsoft.com/jmstall/2006/05/24/beware-of-the-vectored-exception-handler-and-managed-code/

Fixes https://gitlab.gnome.org/GNOME/glib/issues/2025
2020-02-18 23:24:52 +05:30
Sebastian Dröge
b947efb021 Merge branch 'g-set-object-strict-aliasing' into 'master'
gobject: Fix strict aliasing warnings with g_set_object()

See merge request GNOME/glib!1372
2020-02-18 13:25:31 +00:00
Philip Withnall
51acb01f73 gobject: Fix strict aliasing warnings with g_set_object()
When calling `g_set_object()` for a type derived from `GObject`, GCC 9.2
was giving the following strict aliasing warning:
```
../../source/malcontent/libmalcontent-ui/user-controls.c:1001:21: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
 1001 |   if (g_set_object (&self->user, user))
/opt/gnome/install/include/glib-2.0/gobject/gobject.h:744:33: note: in definition of macro ‘g_set_object’
  744 |   (g_set_object) ((GObject **) (object_ptr), (GObject *) (new_object)) \
      |                                 ^~~~~~~~~~
```

This was due to the `(GObject **)` cast.

Pass the pointer through a union to squash this warning. We already do
some size and type checks of the dereferenced type, which should catch
casual errors. The `g_object_ref()` and `g_object_unref()` calls which
subsequently happen inside the `g_set_object()` function also do some
dynamic type checks.

Add a test.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-18 12:15:52 +00:00
Philip Withnall
4a1dcdfb7c Merge branch 'wip/oholy/gunixmountmonitor-thread-safe' into 'master'
gunixmounts: Make GUnixMountMonitor thread-safe

Closes #2030

See merge request GNOME/glib!1357
2020-02-18 10:17:24 +00:00
Ondrej Holy
501558eaa1 gunixmounts: Remove pending sources when finalizing
mtab_file_changed_id is	not currently removed when finalizing, which
could potentially lead to segfaults. Let's remove the source when
finalizing to avoid this.
2020-02-18 09:16:47 +01:00
Ondrej Holy
ab278c0072 gunixmounts: Prevent race when mtab file changed
mtab_file_changed_id might be set on thread default context, but it is
always cleared on the global context because of usage of g_idle_add. This
can cause the emission of redundant "mounts-change" signals. This should
not cause any issues to the client application, but let's attach the idle
source to the thread-default context instead to avoid those races for sure.
2020-02-18 09:16:47 +01:00
Ondrej Holy
898a9c332e gunixmounts: Prevent invalid time_read timestamps
The `get_mounts_timestamp()` function uses `mount_poller_time` when
`proc_mounts_watch_source` is set, but the `mount_poller_time` is not
initialized in the same time as `proc_mounts_watch_source`. This may
cause that zero, or some outdated value is returned. Let's initialize
`mount_poller_time` to prevent invalid values to be returned.
2020-02-18 09:10:03 +01:00
Ondrej Holy
972b977659 gunixmounts: Make GUnixMountMonitor thread-safe
The Nautilus test suite often crashes with "GLib-FATAL-CRITICAL:
g_source_is_destroyed: assertion 'g_atomic_int_get (&source->ref_count)
> 0' failed" if it is started with "GIO_USE_VOLUME_MONITOR=unix". This
is because GUnixMountMonitor is simultaneously used from multiple
threads over GLocalFile and GVolumeMonitor APIs. Let's add guards for
proc_mounts_watch_source and mount_poller_time variables to prevent
those crashes.

Fixes: https://gitlab.gnome.org/GNOME/glib/issues/2030
2020-02-18 09:09:50 +01:00
Philip Withnall
f0e7bc16ab Merge branch '1919-relative-paths' into 'master'
build: Rework path construction to reliably add prefix

Closes #1919

See merge request GNOME/glib!1369
2020-02-17 19:46:54 +00:00
Sebastian Dröge
8e0bd39b51 Merge branch '1517-bus-ownership-race' into 'master'
gdbusnameowning: Subscribe to NameLost before calling RequestName

Closes #1517

See merge request GNOME/glib!1367
2020-02-17 19:07:23 +00:00
Piotr Drąg
341c58b44a Update Polish translation 2020-02-16 15:44:35 +01:00
Philip Withnall
ccbb2d8e8a gdbusnameowning: Subscribe to NameLost before calling RequestName
There was a slight race in name ownership: a gap between calling
`RequestName` (or receiving its reply) and subscribing to `NameLost`. In
that gap, another process could request and receive the name, and this
one wouldn’t know about it.

Fix that by subscribing to `NameAcquired` and `NameLost` before calling
`RequestName`, and then unsubscribing again if the subscriptions turn
out not to be necessary (if the process can’t own the requested name).

Spotted and diagnosed by Miika Karanki.

One of the tests needs an additional iteration of the main loop in order
to free all the signal closures before it can complete its checks.

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

Fixes: #1517
2020-02-16 10:00:31 +00:00
Philip Withnall
4d5900541b Merge branch 'patch-1' into 'master'
Fix oss-fuzz coverage link

See merge request GNOME/glib!1366
2020-02-16 09:05:05 +00:00
Asier Sarasua Garmendia
5ca0862e63 Update Basque translation 2020-02-15 12:18:47 +00:00
pdknsk
4ccaff05a9 Fix oss-fuzz coverage link 2020-02-15 08:23:25 +00:00
Fran Dieguez
8312a4c52f Update Galician translation 2020-02-14 20:40:23 +00:00
Philip Withnall
dff212effc Merge branch 'wip/tingping/socket-client-data-races-fix' into 'master'
gsocketclient: Refactor g_socket_client_connect_async()

Closes #1995, #1872, #1902, #1989, and #1871

See merge request GNOME/glib!1339
2020-02-14 19:10:59 +00:00
Philip Withnall
8f7faac10f Merge branch '1633-drop-gio-launch-desktop' into 'master'
gdesktopappinfo: Use `sh` rather than `gio-launch-desktop`

Closes #1633

See merge request GNOME/glib!1362
2020-02-14 19:00:29 +00:00
Patrick Griffis
2722620e32 Refactor g_socket_client_connect_async()
This is a fairly large refactoring. The highlights are:

- Removing in-progress connections/addresses from GSocketClientAsyncConnectData:

  This caused issues where multiple ConnectionAttempt's would step over eachother
  and modify shared state causing bugs like accidentally bypassing a set proxy.

  Fixes #1871
  Fixes #1989
  Fixes #1902

- Cancelling address enumeration on error/completion

- Queuing successful TCP connections and doing application layer work serially:

  This is more in the spirit of Happy Eyeballs but it also greatly simplifies
  the flow of connection handling so fewer tasks are happening in parallel
  when they don't need to be.

  The behavior also should more closely match that of g_socket_client_connect().

- Better track the state of address enumeration:

  Previously we were over eager to treat enumeration finishing as an error.

  Fixes #1872
  See also #1982

- Add more detailed documentation and logging.

Closes #1995
2020-02-14 18:15:20 +00:00
Philip Withnall
2b533ca99a gdesktopappinfo: Use sh rather than gio-launch-desktop
There were some problems about where to install `gio-launch-desktop` to
support multiarch systems without circular dependencies. Simon McVittie
suggested that, actually, given the current set of platforms supported
by `GDesktopAppInfo` (they’re all POSIX), we could just use `sh`.

That simplifies things nicely. `gio-launch-desktop` can always be
resurrected (and the multiarch debate continued and resolved) if needed
in future.

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

Fixes: #1633
2020-02-14 18:09:18 +00:00
Philip Withnall
4a153abebe Merge branch 'wip/smcv/but-what-if-capabilities' into 'master'
Make tests pass if we are euid != 0 with capabilities

Closes #2029, #2028, and #2027

See merge request GNOME/glib!1363
2020-02-14 11:45:01 +00:00
Balázs Úr
d0c9855bd2 Update Hungarian translation 2020-02-13 18:44:21 +00:00
Simon McVittie
b9d04b37b0 tests: Cope with having CAP_DAC_OVERRIDE, even if not euid 0
Some CI platforms invoke these tests with euid != 0 but with
capabilities. Detect whether we have Linux CAP_DAC_OVERRIDE or other
OSs' equivalents, and skip tests that rely on DAC permissions being
denied if we do have that privilege.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Fixes: https://gitlab.gnome.org/GNOME/glib/issues/2027
Fixes: https://gitlab.gnome.org/GNOME/glib/issues/2028
2020-02-13 17:33:45 +00:00
Simon McVittie
6e28ce2860 tests: Don't assume that unprivileged uids are bound by RLIMIT_NPROC
Some CI platforms invoke tests as euid != 0, but with capabilities that
include CAP_SYS_RESOURCE and/or CAP_SYS_ADMIN. If we detect this,
we can't test what happens if our RLIMIT_NPROC is too low to create a
thread, because RLIMIT_NPROC is bypassed in these cases.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Fixes: https://gitlab.gnome.org/GNOME/glib/issues/2029
2020-02-13 17:33:45 +00:00
Emin Tufan Çetin
1c69f92535 Update Turkish translation 2020-02-12 17:38:01 +00:00
Philip Withnall
3847bc2e0e Merge branch 'fallback-setattr-failure' into 'master'
GThread - Check if sched_setattr is allowed by the system policies before depending on it

See merge request GNOME/glib!1356
2020-02-12 17:05:16 +00:00
Sebastian Dröge
9308ef9a4b GThread - Check if sched_setattr is allowed by the system policies before depending on it
On Fedora it's apparently not allowed so we'll have to fall back to the
thread-spawner thread in GThreadPool instead.
2020-02-12 17:56:11 +02:00
Philip Withnall
551576fb96 Merge branch 'main-context-freeing-of-sources' into 'master'
GMainContext - Fix memory leaks and memory corruption when freeing sources while freeing a context

See merge request GNOME/glib!1353
2020-02-12 15:26:06 +00:00
Sebastian Dröge
d6886d898f Merge branch 'docs-object-manager-example' into 'master'
docs: Don’t install object manager example separately

See merge request GNOME/glib!1359
2020-02-11 12:53:22 +00:00