Commit Graph

21805 Commits

Author SHA1 Message Date
Philip Withnall
e4a690f5dd gcancellable: Fix minor race between GCancellable and GCancellableSource
There’s a minor race condition between cancellation of a `GCancellable`,
and disposal/finalisation of a `GCancellableSource` in another thread.

Thread A                               Thread B
 g_cancellable_cancel(C)
 →cancellable_source_cancelled(C, S)
                                       g_source_unref(S)
                                       cancellable_source_dispose(S)
 →→g_source_ref(S)
 →→# S is invalid at this point; crash

Thankfully, the `GCancellable` sets `cancelled_running` while it’s
emitting the `cancelled` signal, so if `cancellable_source_dispose()` is
called while that’s high, we know that the thread which is doing the
cancellation has already started (or is committed to starting) calling
`cancellable_source_cancelled()`.

Fix the race by resurrecting the `GCancellableSource` in
`cancellable_source_dispose()`, and signalling this using
`GCancellableSource.resurrected_during_cancellation`. Check for that
flag in `cancellable_source_cancelled()` and ignore cancellation if it’s
set.

The modifications to `resurrected_during_cancellation` and the
cancellable source’s refcount have to be done with `cancellable_mutex`
held so that they are seen atomically by each thread. This should not
affect performance too much, as it only happens during cancellation or
disposal of a `GCancellableSource`.

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

Fixes: #1841
2020-02-29 20:15:39 +00:00
Philip Withnall
4093321c9a tests: Use g_assert_*() in cancellable test rather than g_assert()
`g_assert()` is compiled out if `G_DISABLE_ASSERT` is defined, and
`g_assert_*()` gives more detailed failure messages.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-28 16:06:46 +00:00
Sebastian Dröge
2cad4fb5bf Merge branch 'wip/hadess/avoid-all-remote-files-crash' into 'master'
gcontenttype: Fix crash in _get_generic_icon_name()

See merge request GNOME/glib!1398
2020-02-28 14:49:51 +00:00
Bastien Nocera
a7181ad397 gcontenttype: Fix crash in _get_generic_icon_name()
Guard against NULL type being passed to
g_content_type_get_generic_icon_name() just as we protect
g_content_type_get_description(), otherwise it will cause a crash.

See https://gitlab.gnome.org/GNOME/gtk/issues/2482
2020-02-28 15:09:50 +01:00
Simon McVittie
08a4a2e6f4 Merge branch 'installed-tests' into 'master'
tests: Move memory_monitor_tests under installed_tests_enabled

See merge request GNOME/glib!1395
2020-02-28 14:02:32 +00:00
Jan Alexander Steffens (heftig)
7bdcfcf73a
tests: Move memory_monitor_tests under installed_tests_enabled
So they're not installed when the latter is disabled.
2020-02-28 14:10:25 +01:00
Simon McVittie
fdbd9ed7f7 tests: Skip MemoryMonitor test if GObject-Introspection is too old
Distributions will likely want to update GLib before
GObject-Introspection, to avoid circular dependencies.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-02-28 12:42:36 +00:00
Timm Bäder
5f38ae5ffc macros: Define G_GNUC_FALLTHROUGH for more compilers
Some compilers have __GNUC__ defined as a value less than 6, but do
support implicit-fallthrough via __attribute__((fallthrough)). Define
G_GNUC_FALLTHROUGH for those that support __has_attribute.
2020-02-28 09:34:38 +01:00
Philip Withnall
369626e310 2.64.0
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-27 16:11:22 +00:00
Sebastian Dröge
21471b4258 Merge branch '2049-array-crash' into 'master'
garray: Fix copying an array with reserved elements

Closes #2049

See merge request GNOME/glib!1390
2020-02-27 15:20:52 +00:00
Philip Withnall
d22c762221 garray: Fix copying an array with reserved elements
Spotted by Mohammed Sadiq. `g_array_copy()` was doing a `memcpy()` of
the data from the old array to the new one, based on the reserved
elements in the old array (`array->alloc`). However, the new array was
allocated based on the *assigned* elements in the old array
(`array->len`).

So if the old array had fewer assigned elements than allocated elements,
`memcpy()` would fall off the end of the newly allocated data block.
This was particularly obvious when the old array had no assigned
elements, as the new array’s data pointer would be `NULL`.

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

Fixes: #2049
2020-02-27 14:48:36 +00:00
Philip Withnall
423b2bbc95 gsocks5proxy: Fix SOCKS5 username/password authentication
It was checking for the main SOCKS5 version number, rather than the
subnegotiation version number. The username/password authentication
protocol is described in https://tools.ietf.org/html/rfc1929.

Spotted and diagnosed by lovetox.

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

Fixes: #1986
2020-02-27 12:16:41 +00:00
Philip Withnall
67610c7c0f Merge branch 'shell-ci-fixes' into 'master'
ci: Correctly propagate exit status in run-style-check-diff.sh

See merge request GNOME/glib!1387
2020-02-27 11:20:14 +00:00
Philip Withnall
5292efdc75 Merge branch 'sam/use-g-define-quark' into 'master'
Update GError docs to use G_DEFINE_QUARK

See merge request GNOME/glib!1389
2020-02-27 11:07:58 +00:00
Philip Withnall
c5d661b4c4 build: Fix shellcheck warnings in various old build and test scripts
Most of these scripts can probably just be deleted (see issue #2045),
but for now it was easier to just mechanically fix the shellcheck
warnings in them, rather than think about whether we actually needed the
script.

Fixes done using shellcheck 0.7.0 with default options. I haven’t tested
any of the changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-27 10:33:45 +00:00
Philip Withnall
00dfb1de0f ci: Ensure run-check-todos.sh exits on the first error it encounters
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-27 10:33:45 +00:00
Philip Withnall
23d26cfe7e ci: Fix various shellcheck warnings in the shell scripts
I haven’t tested any of them. This is entirely mechanical. I used
shellcheck 0.7.0 with default options.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-27 10:33:45 +00:00
Sam Thursfield
dcbaae4fa2 Update GError docs to use G_DEFINE_QUARK 2020-02-26 20:06:13 +01:00
Simon McVittie
70c5fd53e9 Merge branch 'test-dbus-posix_spawn' into 'master'
gtestdbus: Use posix_spawn() to spawn dbus-daemon

See merge request GNOME/glib!1388
2020-02-26 13:57:47 +00:00
Marek Černocký
2bd7ade25d Updated Czech translation 2020-02-26 14:07:19 +01:00
Philip Withnall
eb867c3d2f gtestdbus: Use posix_spawn() to spawn dbus-daemon
This speeds up tests which use `GTestDBus` significantly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-26 10:45:45 +00:00
Alan Mortensen
c01517644b Updated Danish translation 2020-02-25 20:45:40 +01:00
Emmanuele Bassi
f55ff88531 Merge branch 'document-generated-headers-caveats-for-genmarshal-too' into 'master'
docs: Document generated headers caveats for genmarshal

See merge request GNOME/glib!1386
2020-02-25 11:45:41 +00:00
Philip Withnall
95479256df ci: Correctly propagate exit status in run-style-check-diff.sh
Spotted by Daniel Stone: the addition of the `echo` commands in commit
65541f1ad meant that the exit status from `clang-format-diff.py` was
being lost.

The incorrect use of `set +e` rather than `set -e` meant that
intermediate commands could fail without the failure being noticed.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-25 11:11:42 +00:00
Sebastian Dröge
cf72043ade Merge branch 'warning-fixes' into 'master'
Some minor clang warning fixes

See merge request GNOME/glib!1384
2020-02-24 21:52:57 +00:00
Nirbheek Chauhan
3732f9bd07 docs: Document generated headers caveats for genmarshal
And also link to the Meson FAQ that explains why this is needed so
people aren't just cargo-culting code.
2020-02-25 03:14:50 +05:30
Philip Withnall
276fff2b96 Merge branch 'issue-1783' into 'master'
Document Meson use for GLib tools

Closes #1783

See merge request GNOME/glib!861
2020-02-24 17:25:38 +00:00
Philip Withnall
37a3da891b tests: Add some assertions to avoid unused variable warnings on Clang
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 16:18:58 +00:00
Philip Withnall
99a325356d tests: Fix a compiler warning about string+int arithmetic
Clang warns about string+int not appending to the string (to try and
catch newbie mistakes). While this test didn’t expect that to happen, it
was substituting the same constant string in multiple places for no good
reason. Switch to a single static const string, which should also fix
the compiler warning.

We have to define the string length since it’s used in various
stack-allocated array lengths. This is the easiest fix without more
major refactoring of the test to be less 90s.

Also make things a bit more static.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 16:18:58 +00:00
Emmanuele Bassi
653e0f0813 Add links to Meson docs for genmarshal and mkenums 2020-02-24 16:14:33 +00:00
Emmanuele Bassi
83c13e52d5 docs: Mention Meson's gnome.mkenums_simple()
The mkenums_simple() function generates idiomatic GObject code, and
avoids templates and custom command line arguments.
2020-02-24 16:14:33 +00:00
Emmanuele Bassi
79cdd531d0 Add example of using glib-genmarshal with Meson
We're using Meson for GLib itself, and we recommend people to use it
for their own projects, so it would be good to have our documentation
present examples on how to use Meson with our tools.
2020-02-24 16:14:33 +00:00
Emmanuele Bassi
040803b34d Add example of using glib-mkenums with Meson
We're using Meson for GLib itself, and we recommend people to use it
for their own projects, so it would be good to have our documentation
present examples on how to use Meson with our tools.

Let's move the template example into its own section while we're at it,
since it's referenced by both Meson and Autotools examples.

Fixes: #1783
2020-02-24 15:46:35 +00:00
Emmanuele Bassi
15a4cf4d3f Ensure that we use @basename@ in the glib-mkenums docs
The documentation for @filename@ is not accurate either.
2020-02-24 15:08:49 +00:00
Philip Withnall
b90eb15f3e 2.63.6
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 15:05:38 +00:00
Sebastian Dröge
360fb9dfbf Merge branch '2002-g-io-channel-read-line-nuls' into 'master'
giochannel: Fix read_line() when nul is not a line terminator

Closes #2002

See merge request GNOME/glib!1319
2020-02-24 14:35:52 +00:00
Philip Withnall
c8811da56a giochannel: Fix read_line() when nul is not a line terminator
And add a test for it.

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

Fixes: #2002
2020-02-24 14:12:30 +00:00
Sebastian Dröge
2b06b6498b Merge branch 'speed-up-actions-test' into 'master'
tests: Speed up the GIO actions test

See merge request GNOME/glib!1298
2020-02-24 13:16:09 +00:00
Sebastian Dröge
1b06461104 Merge branch '1515-gdbus-threading-timeout' into 'master'
tests: Bump the refcount timeout in gdbus-threading

See merge request GNOME/glib!1382
2020-02-24 13:11:40 +00:00
Sebastian Dröge
e3c69acf01 Merge branch '938-gdbus-tool-message-bus-connections' into 'master'
gdbus-tool: Require message bus connections for most commands

Closes #938

See merge request GNOME/glib!926
2020-02-24 12:53:57 +00:00
Sebastian Dröge
ff44c490d4 Merge branch 'sched_setattr-no-gerror' into 'master'
GThread: Don't g_error() if setting the thread scheduler settings fails

Closes #2039

See merge request GNOME/glib!1374
2020-02-24 12:29:26 +00:00
Emmanuele Bassi
ea461c430c Merge branch 'installed-tests-parallel' into 'master'
ci: Enable parallelisation when running installed tests

See merge request GNOME/glib!1383
2020-02-24 12:25:19 +00:00
Philip Withnall
238c774970 tests: Reduce iteration counts on gdbus-threading test
When running under CI, each iteration takes so long that the total test
time is around 200s. If the CI runner is highly loaded, this can tip it
over the timeout of 360s.

Reduce the iteration counts unless running the test thoroughly.

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

Helps: #1515
2020-02-24 12:24:02 +00:00
Emmanuele Bassi
f17ebdede5 Merge branch 'timezone-utc-cleanup' into 'master'
gtimezone: Tidy up UTC timezone creation

See merge request GNOME/glib!1185
2020-02-24 11:46:48 +00:00
Philip Withnall
cfe8d423d4 tests: Bump the refcount timeout in gdbus-threading
Currently the test waits for 1s before deciding that a refcount has been
leaked. But slow test machines might take longer than that between
scheduling different threads to sort out the refcount, so increase the
timeout.

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

Helps: #1515
2020-02-24 11:37:36 +00:00
Emmanuele Bassi
cf91f0dca9 Merge branch 'hash-table-docs' into 'master'
ghash: Document the iteration order over a hash table is not defined

See merge request GNOME/glib!1381
2020-02-24 11:33:57 +00:00
Emmanuele Bassi
8bf3a662c8 Merge branch 'gapplication-docs-typo' into 'master'
gapplication: Fix a minor typo in the documentation

See merge request GNOME/glib!1299
2020-02-24 11:20:51 +00:00
Philip Withnall
97f9fc62c1 Merge branch 'fix-cpu-family-in-ci' into 'master'
gitlab-ci: 64-bit ARM is aarch64, not arm64

See merge request GNOME/glib!1376
2020-02-24 11:18:11 +00:00
Philip Withnall
177851c9b7 gdbus-tool: Require message bus connections for most commands
Previously, if the `--address` option was passed to `gdbus-tool`, it
would treat the connection as peer to peer. However, almost all the
commands `gdbus-tool` supports require a message bus (introspection,
calling a method with a destination, etc.). Only the `signal` command
would ever work on a peer-to-peer connection (if no `--dest` was
specified).

So change the `--address` option to generally create message bus
connections.

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

Fixes: #938
2020-02-24 11:17:31 +00:00
Philip Withnall
2d7b2a014b ci: Enable parallelisation when running installed tests
This should speed up CI runs significantly, as the installed tests are
currently running in series.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-24 11:06:00 +00:00