Commit Graph

24753 Commits

Author SHA1 Message Date
Simon McVittie
2fd4382821 Merge branch '2620-timezone-offset' into 'main'
gtimezone: Fix assertion failure when called with a huge offset

Closes #2620

See merge request GNOME/glib!2554
2022-03-16 16:23:35 +00:00
Philip Withnall
7ab9359af0 gtimezone: Fix assertion failure when called with a huge offset
This looks like a regression from commit 3356934db5, but prior to that
commit there was always an assertion failure when calling
`g_time_zone_new_offset()` with an offset which is too large (such as 44
hours), ever since the function was added in commit cf24867b93.

It would be ideal if we could return a `NULL` timezone to indicate the
error, but that’s not part of the API for `g_time_zone_new_offset()`, so
we have to go with the dated and not-ideal approach of returning the UTC
timezone and letting the caller figure it out.

Another potential approach would be to reduce the `offset` modulo 24
hours. This makes the error less easily detectable than if returning
UTC, though, and still returns an invalid result: `+44:00` is not the
same timezone as `+20:00` (it’s one day further ahead).

Add a unit test.

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

Fixes: #2620
2022-03-16 12:52:13 +00:00
Philip Withnall
7f0f87355b Merge branch 'mcatanzaro/typo' into 'main'
gtlsconnection: fix typo in docs

See merge request GNOME/glib!2552
2022-03-16 12:43:21 +00:00
Michael Catanzaro
69a1867d51 gtlsconnection: fix typo in docs
Grrr, copy/paste error detected.
2022-03-16 10:38:34 +00:00
Philip Withnall
b86750cb63 Merge branch 'wip/pwithnall/more-test-fixes' into 'main'
tests: More flaky test fixes to converter-stream and test-printf

See merge request GNOME/glib!2551
2022-03-16 10:32:44 +00:00
Philip Withnall
96caca2b7a tests: Explicitly close stream in converter-stream
When the test has finished writing all the expanded content into the
socket, explicitly close the output stream, which should make the input
stream readable and non-blocking.

The code intended to do this before, but only as a side-effect of
dropping its last reference to `right`. If another reference was being
held to `right` somewhere else, it wouldn’t end up being closed, which
would lead to failures like
https://gitlab.gnome.org/GNOME/glib/-/jobs/1890000:
```
(/var/tmp/gitlab_runner/builds/Ff4WDDRj/0/GNOME/glib/_build/gio/tests/converter-stream:56570): GLib-GIO-DEBUG: 12:56:23.280: GSocketClient: Connection successful!
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1042:test_converter_pollable: assertion failed (error == NULL): Resource temporarily unavailable (g-io-error-quark, 27)
stderr:
```

This is a bit of a guess (I’m not sure it’ll fix the intermittent test
error, as I haven’t been able to reproduce that locally), but it’s worth
a try.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-14 17:59:37 +00:00
Philip Withnall
dbe34687d0 tests: Skip vasprintf() placeholder checks on FreeBSD and macOS
The `vasprintf()` version on those platforms seems to do less rigorous
checking of format placeholders.

See https://gitlab.gnome.org/GNOME/glib/-/jobs/1890001 and
https://gitlab.gnome.org/GNOME/glib/-/jobs/1890000.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-14 17:59:37 +00:00
Philip Withnall
1094144b7a Merge branch 'gdbus-auth-test-timeout' into 'main'
tests: Various fixes to gdbus-auth, gdbus-non-socket, gdbus-connection-flush, spawn-multithreaded tests

See merge request GNOME/glib!2548
2022-03-14 12:52:43 +00:00
Simon McVittie
dbda5a4e38 Merge branch 'scheduled-ci-fixes' into 'main'
fuzzing: Fix test failure with G_DISABLE_ASSERT

See merge request GNOME/glib!2542
2022-03-14 12:25:32 +00:00
Baurzhan Muftakhidinov
8e89da90a3 Update Kazakh translation 2022-03-12 17:40:53 +00:00
Philip Withnall
c455d0efb7 tests: Correctly exit and join the worker threads in spawn-multithreaded
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
3f753b0fa3 tests: Fix the prototype of a GChildWatchFunc in spawn-multithreaded
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
ca99cf032d tests: Use separate GMainContext in thread in spawn-multithreaded
Otherwise the `start_thread()` threads and the main thread are competing
to iterate the global default context, which is probably not what was
intended.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
54748d3b7c tests: Lower thread TTLs in spawn-multithreaded
Otherwise the test takes forever, for no discernible benefit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
7b004d4052 tests: Fix a memory leak in spawn-multithreaded
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
8cb44235df tests: Remove sources when done in spawn-multithreaded
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
d6f99e5093 tests: Remove global variables from spawn-multithreaded
They make everything a lot harder to reason about, and easily allow for
state to leak between tests.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:46:07 +00:00
Philip Withnall
fd43391583 tests: Use g_assert_*() rather than g_assert() in spawn-multithreaded
It won’t get compiled out with `G_DISABLE_ASSERT`.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 01:12:19 +00:00
Philip Withnall
8cff531520 tests: Isolate directory access for gdbus-connection-flush test
When multiple tests were run in parallel, this would race on its access
to `~/.dbus-keyrings` to authenticate with the D-Bus server, since the
keyring directory was not appropriately sandboxed to the unit test.

Use `G_TEST_OPTION_ISOLATE_DIRS` to automatically isolate each unit
test’s directory usage.

This should hopefully fix the failure seen in
https://gitlab.gnome.org/GNOME/glib/-/jobs/1849524, where the following
was in the log for a test executed in parallel:
```
GDBus-DBUS_COOKIE_SHA1: Deleted stale lock file '/home/user/.dbus-keyrings/org_gtk_gdbus_general.lock'
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-12 00:03:05 +00:00
Philip Withnall
a3c768732d tests: Isolate directory access for gdbus-non-socket test
When multiple tests were run in parallel, this would race on its access
to `~/.dbus-keyrings` to authenticate with the D-Bus server, since the
keyring directory was not appropriately sandboxed to the unit test.

Use `G_TEST_OPTION_ISOLATE_DIRS` to automatically isolate each unit
test’s directory usage.

This should hopefully fix the failure seen in
https://gitlab.gnome.org/pwithnall/glib/-/jobs/1879558.
```
228/266 glib:gio / gdbus-non-socket             FAIL     8.64 s (killed by signal 6 SIGABRT)
…
--- stderr ---
GDBus-DBUS_COOKIE_SHA1: Deleted stale lock file '/home/user/.dbus-keyrings/org_gtk_gdbus_general.lock'
**
GLib-GIO:ERROR:../gio/tests/gdbus-non-socket.c:253:test_non_socket: assertion failed (error == NULL): Exhausted all available authentication mechanisms (tried: EXTERNAL, DBUS_COOKIE_SHA1) (available: EXTERNAL, DBUS_COOKIE_SHA1) (g-io-error-quark, 0)
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-11 23:56:18 +00:00
Philip Withnall
404d5d40e0 tests: Ensure timeout source is removed in gdbus-auth test
If the whole set of tests takes more than 5 seconds, the failure timeout
from the first test could still trigger, causing an incorrect failure.

Ensure the timeout is removed at the end of each test.i

This will hopefully fix the CI failure seen here:
https://gitlab.gnome.org/pwithnall/glib/-/jobs/1879558.
```
204/266 glib:gio / gdbus-auth                   FAIL     9.21 s (killed by signal 5 SIGTRAP)
…
ok 1 /gdbus/auth/client/EXTERNAL
Bail out! GLib-GIO-FATAL-ERROR: Timeout waiting for client
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-11 23:47:22 +00:00
Balázs Úr
91411338dc Update Hungarian translation 2022-03-10 19:44:52 +00:00
Sebastian Dröge
8bf6e498e6 Merge branch 'vasprintf-leak-fix' into 'main'
gprintf: Fix a memory leak with an invalid format in g_vasprintf()

See merge request GNOME/glib!2547
2022-03-10 08:09:04 +00:00
Philip Withnall
aa4385c1d9 gprintf: Clarify error behaviour of g_vasprintf() in docs
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-09 18:19:05 +00:00
Marek Černocký
c604cb1555 Fixech Czech translation 2022-03-09 19:09:26 +01:00
Philip Withnall
d6ad10404f tests: Add some tests for g_string_append_vprintf()
This adds coverage of one previously uncovered branch in `gstring.c`.
Real progress!

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-09 14:09:57 +00:00
Philip Withnall
27e1509cd6 tests: Add some tests for g_vasprintf() invalid format strings
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-09 14:08:49 +00:00
Philip Withnall
7329c6e09b gprintf: Fix a memory leak with an invalid format in g_vasprintf()
If using the fallback implementation of `g_vasprintf()`.

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

Coverity CID: #1474726
2022-03-09 14:07:34 +00:00
Fabio Tomat
09a5ce5776 Update Friulian translation 2022-03-09 09:47:28 +00:00
Philip Withnall
b1315988fc fuzzing: Fix test failure with G_DISABLE_ASSERT
https://gitlab.gnome.org/GNOME/glib/-/jobs/1875915
```
../fuzzing/fuzz_paths.c: In function ‘LLVMFuzzerTestOneInput’:
../fuzzing/fuzz_paths.c:7:16: error: variable ‘skipped_root’ set but not used [-Werror=unused-but-set-variable]
    7 |   const gchar *skipped_root;
      |                ^~~~~~~~~~~~
cc1: all warnings being treated as errors
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-08 11:52:30 +00:00
Yosef Or Boczko
b3a568d19e Update Hebrew translation 2022-03-07 18:48:25 +00:00
Emmanuele Bassi
618d6873fd Merge branch 'wip/pwithnall/ci-fixes' into 'main'
Various unit test fixes

See merge request GNOME/glib!2538
2022-03-07 09:24:10 +00:00
Piotr Drąg
4ebf316835 Update Polish translation 2022-03-06 14:44:54 +00:00
Luna Jernberg
791c0be71a Update Swedish translation 2022-03-06 12:47:06 +00:00
Daniel Șerbănescu
ffb33887b5 Update Romanian translation 2022-03-06 11:47:59 +00:00
Philip Withnall
918fcd7928 2.71.3
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-04 21:03:41 +00:00
Philip Withnall
f0baa136f9 Merge branch 'canon-fix' into 'main'
glib: fix buffer overflow in g_canonicalize_filename()

See merge request GNOME/glib!2451
2022-03-04 20:16:29 +00:00
Marc-André Lureau
56e87ae1b5 glib: fix buffer overflow in g_canonicalize_filename()
The output pointer must not go past the ending \0.

warning: HEAP[testglib.exe]:
warning: Heap block at 0000011EA35745A0 modified at 0000011EA35745BF past requested size of f

Fixes commit 9a30a495ec "gfileutils: Improve performance of g_canonicalize_filename()"

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-03-04 20:16:29 +00:00
Philip Withnall
4d237daf32 tests: Add more debug output to gdbus-threading test
It periodically hangs due to the `GDBusConnection` having more than 1
ref (and never losing them), so there’s potentially a leaking ref
somewhere:
```
(/builds/alexander.klauer/glib/_build/gio/tests/gdbus-threading:17767): GLib-GIO-DEBUG: 13:18:12.268: refcount of 0x55fe85b1a260 is not right, sleeping
\# GLib-GIO-DEBUG: refcount of 0x55fe85b1a260 is not right, sleeping
```

Add some more debug output to try and track the problem down.

See: https://gitlab.gnome.org/alexander.klauer/glib/-/jobs/1865968

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-04 19:53:04 +00:00
Philip Withnall
54ee8e5414 tests: Add more debug output to converter-stream test
It’s periodically failing on FreeBSD and I can’t reproduce the failure
locally nor work out what it is from the logs:
```
Bail out! GLib-GIO:ERROR:../gio/tests/converter-stream.c:1041:test_converter_pollable: assertion failed (res != -1): (-1 != -1)
stderr:
**
GLib-GIO:ERROR:../gio/tests/converter-stream.c:1041:test_converter_pollable: assertion failed (res != -1): (-1 != -1)
```

Add some more debug output to get the value of `error`, in the hope that
will provide some insight.

See: https://gitlab.gnome.org/GNOME/glib/-/jobs/1866486

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-04 19:51:17 +00:00
Emmanuele Bassi
cbca44ca32 Merge branch '2598-main-loop-unref' into 'main'
gmain: Fix reference leak of GMainLoop in some situations

Closes #2598

See merge request GNOME/glib!2535
2022-03-04 19:22:22 +00:00
Philip Withnall
80d3018c1d tests: Make the 642026 test take 100× less time
It’s a tradeoff of time against reproducibility of the failure conditions
this test is testing for. If this test is run 100× on CI (which it will
be every few weeks), that should be often enough to catch a regression
here.

A regression in this code is unlikely, though.

This change is motivated by the fact that periodically this test times
out, and even when it doesn’t, it takes on average 240s of CI runner
time during each CI run. That’s a lot of resources.

See: https://gitlab.gnome.org/GNOME/glib/-/jobs/1862013

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-04 19:21:40 +00:00
Emmanuele Bassi
0c4c8d1005 Merge branch '2611-revert-option-changes' into 'main'
Revert "gapplication: Expose zero-valued numbers in handle-local-options"

Closes #2611

See merge request GNOME/glib!2536
2022-03-04 19:21:21 +00:00
Philip Withnall
141d3f68d3 tests: Mark network-address test as expected to succeed on macOS
Commit 13c4b9579b seems to have fixed
`network-address` so that it’s reliable everywhere, including on macOS.

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

Helps: #1392
2022-03-04 19:07:02 +00:00
Philip Withnall
9469922d5c tests: Allow g_mkdir_with_parents() to fail with EPERM
As well as with `EACCES`. This can happen if the filesystem as a whole
is read-only, and has been spotted in the wild on macOS:
```
Bail out! GLib:ERROR:../glib/tests/fileutils.c:756:test_mkdir_with_parents: assertion failed (errno == EACCES): (1 == 13)
stderr:
**
GLib:ERROR:../glib/tests/fileutils.c:756:test_mkdir_with_parents: assertion failed (errno == EACCES): (1 == 13)
```

See: https://stackoverflow.com/q/68766316/2931197
See: https://gitlab.gnome.org/GNOME/glib/-/jobs/1866500

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-04 18:59:22 +00:00
Philip Withnall
d497bdebc0 Merge branch 'remove_type-test' into 'main'
Move tests/type-test.c to glib/tests/types.c

See merge request GNOME/glib!2527
2022-03-04 18:39:40 +00:00
Philip Withnall
23e935a342 Revert "gapplication: Expose zero-valued numbers in handle-local-options"
This reverts commit 1ed67a9c44.

It turns out that including options, with their default values, in the
`handle-local-options` signal, which weren’t set on the command line,
breaks some applications.

In particular, it breaks Inkscape, which is the application this commit
was originally meant to fix (a different problem).

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

Fixes: #2611
Breaks: #2329
See: !1953
2022-03-04 18:16:12 +00:00
Philip Withnall
4f5da83381 gmain: Fix reference leak of GMainLoop in some situations
When calling `g_main_loop_run()` it’s possible for a reference to the
`GMainLoop` to leak if this thread had to wait to acquire ownership of
the `GMainContext`.

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

Fixes: #2598
2022-03-04 17:37:09 +00:00
Emmanuel Fleury
208dfe9ddc Move tests/type-test.c to glib/tests/types.c
Helps issue #1434
2022-03-04 16:24:20 +00:00
Emmanuel Fleury
9933e2b54c Convert tests/type-test.c to g_test framework 2022-03-04 16:24:20 +00:00