Commit Graph

25649 Commits

Author SHA1 Message Date
Philip Withnall
d48470df52 tests: Fix TAP output from spawn-singlethread test
The output from the echo program ends up being outputted with the stdout
from the unit test in some tests. Ensure that the input to the echo
program is therefore a valid TAP comment, rather than garbage, so that
it’s safely ignored by a TAP parser looking at the output from the test.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
75a39114d8 tests: Fix non-TAP output from socket test
This was breaking strict TAP parsers, such as Meson’s.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
8dde15a5b3 tests: Fix gengiotypefuncs.py helper script
It seems this script has potentially never worked properly under Python
3. It’s supposed to list all the `_get_type()` functions it can find in
the GIO headers, but since the regex string passed to `re.search()` was
not a Python regex, nothing was matching.

Fix that, and do another few small cleanups to the script.

This makes the `defaultvalue` test not skip all the types.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
f977ddf34f tests: Fix non-TAP output from debugcontroller test
When running under a strict TAP parser this was previously producing
problematic non-conforming output.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
1b377e6574 build: Drop MALLOC_PERTURB_ from test environments
It’s set already by Meson, to an actually random value.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-21 12:50:31 +01:00
Philip Withnall
12ed2aa982 Merge branch 'fix-once-memcheck-test' into 'main'
tests: Reduce number of threads in once test under valgrind

See merge request GNOME/glib!2729
2022-06-21 11:36:50 +00:00
Philip Withnall
2c75c392eb gtlscertificate: Hold a ref on the root certificate when building chains
This is unlikely to be a bug in practice, as the certificate pointed to
by `root` should have a ref held on it as the issuer of another
certificate in the chain.

However, we can’t guarantee that’s how the `GTlsCertificate`
implementation behaves, so keep a temporary ref on `root` until it’s no
longer needed.

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

Coverity CID: #1489985
2022-06-21 12:11:27 +01:00
Philip Withnall
fb377b70d0 Merge branch 'gio-dont-include-gtrace' into 'main'
gio: Don't bundle gtrace in static builds

See merge request GNOME/glib!2758
2022-06-21 09:56:18 +00:00
Olivier Crête
1cc685abc4 gio: Don't bundle gtrace in static builds
They're already in the libglib.a file and it prevents the build
from completing.
2022-06-20 16:09:51 -04:00
Philip Withnall
9a2bedb22c Merge branch 'update-codeowners' into 'main'
docs: Add Marco Trevisan as a co-maintainer

See merge request GNOME/glib!2754
2022-06-20 16:03:07 +00:00
Philip Withnall
9cc2859e08 docs: Add Marco Trevisan as a co-maintainer 2022-06-20 16:03:01 +00:00
Philip Withnall
01ac1d902f gobject: Fix crash when disposing a GtkAccelGroup
This is a partial revert of commit fa8c7c0da using the approach
suggested (and tested) by Kjell Ahlstedt.

It is intended to be temporary pending a proper dig into what’s causing
the regression, just so we can get the 2.73.1 release out.

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

Helps: #2672
2022-06-20 16:32:00 +01:00
Philip Withnall
150a63e6b5 Merge branch 'iss2655' into 'main'
gdatetime: Pad numbers with numeric space

Closes #2655

See merge request GNOME/glib!2698
2022-06-20 14:03:57 +00:00
Maksym Hazevych
7169f6e1e5 gdatetime: Use figure space for %e
Helps: #2655
2022-06-20 14:46:23 +01:00
Maksym Hazevych
7074122f30 gdatetime: Pad numbers with numeric space
Padding numbers with a typical space character doesn't align them well
because it has a different size. Instead, we need to use the "U+2007"
figure (numeric) space that has the same size as a numerical digit.
This is only visible when using the `tnum` font feature that
makes numbers monospace.

Closes #2655
2022-06-20 14:28:09 +01:00
Philip Withnall
f1916032e4 tests: Add tests for modifiers for GDateTime’s %l placeholder
They were missing.

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

Helps: #2655
2022-06-20 14:27:06 +01:00
Philip Withnall
4101770274 Merge branch 'mcatanzaro/xdgmime-corruption' into 'main'
xdgmime: fix double free

See merge request GNOME/glib!2753
2022-06-20 12:48:30 +00:00
Philip Withnall
46a6f49066 Merge branch 'meson-add-test-setup' into 'main'
build: Use add_test_setup() to allow tests to be run under valgrind

See merge request GNOME/glib!2752
2022-06-20 11:09:55 +00:00
Philip Withnall
f5baecdb36 build: Use add_test_setup() to allow tests to be run under valgrind
This means we can specify the standard options for testing GLib under
valgrind consistently, so that developers can use `meson test
--setup=valgrind` to run them.

Port the existing valgrind CI to use them (this will not change its
functional behaviour).

Suggested by Marco Trevisan at
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2717#note_1478891.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-20 11:54:10 +01:00
Philip Withnall
b2f4df95e8 Merge branch 'coverity-is-stupid' into 'main'
gobject: Change GObject notify semantics under static analysis

See merge request GNOME/glib!2747
2022-06-17 15:47:39 +00:00
Michael Catanzaro
f95ca6cb71 xdgmime: fix double free
We free xdg_dirs[i] twice, but fail to free xdg_dirs itself.

Also, since free() is NULL-safe, there is no need for the second check
here.

Discovered in: https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/16#note_1432025
2022-06-17 08:49:03 -05:00
Philip Withnall
4a8120ec22 Merge branch 'meson-dependency-lookups' into 'main'
meson: simplify iconv/intl lookups using Meson's builtin dependency lookup

See merge request GNOME/glib!2734
2022-06-17 10:36:29 +00:00
Eli Schwartz
1532c5878e
NEWS: add stub entry for iconv option deprecation
As per review comment, this is miscellaneous enough that it could be
forgotten about at release time, but should still be mentioned.
Guarantee it by starting work on that now.
2022-06-16 12:07:03 -04:00
Eli Schwartz
26435b570f
meson: simplify intl lookups using Meson's builtin dependency lookup
intl is complicated to look up. Some of that complexity now resides in
Meson, since 0.59.0, via a `dependency('intl')` lookup, so use that
instead.

The Meson lookup doesn't include all the checks here, but likewise this
meson.build doesn't include all the checks in Meson. Particularly, the
following are different:

- Meson accurately detects support built into libc, even if that
  conflicts with an external library version (which should be detected as
  broken and thus not-found, but glib does not do so).

  The problem here is that depending on which libintl.h header is first
  in the search path, the *gettext symbols may be the libc ABI, or they
  may be renamed to libintl_*gettext, then additionally take over the
  *gettext names via a macro, in order to invoke the external library
  version even on systems where there is a libc builtin. This means that
  checking for `cc.has_function()` correctly reports that there is such
  a function in libc, but that unfortunately does not mean it is usable,
  because source code referencing `ngettext` etc. will expect to be
  linked to `libintl_ngettext`.

- glib checks whether the found intl requires pthread, rather than
  simply trusting the result of `cc.find_library()` for the external
  library case.

Do the heavy lifting by using Meson to check for intl, and select the
correct implementation, but do a post-discovery check if the symbol is
linkable both with/without pthread.

The logic is still a bit hairy, and eventually more of the logic could
be moved into Meson. But it's better than before.

Fixes incorrect detection of intl on musl-based systems (which have a
less capable libc intl), when GNU libintl is installed as an external
library.
2022-06-16 12:04:59 -04:00
Eli Schwartz
24ec80cfb4
meson: simplify iconv lookups using Meson's builtin dependency lookup
iconv is complicated to look up. That complexity now resides in
Meson, since 0.60.0, via a `dependency('iconv')` lookup, so use that
instead.

No effort is made to support the old option for which type of iconv to
use. It was a false choice, because if only one was available, then
that's the only one you can use, and if both are available, the external
iconv shadows the builtin one and renders the builtin one unusable,
so there is still only one you can use.

This meant that when configuring glib with -Diconv=libc on systems that
had an external iconv, the configure check would detect a valid libc
iconv, try to use it, and then fail during the build because iconv.h
belongs to the external iconv and generates machine code using the
external iconv ABI, but fails to link to the iconv `find_library()`.
Meson handles this transparently.
2022-06-16 12:04:59 -04:00
Philip Withnall
ccc7006d53 Merge branch 'fix-unix-open-pipes-introspection' into 'main'
glib-unix: Mark GLib.unix_open_pipe fds input array as fixed-size

See merge request GNOME/glib!2751
2022-06-16 11:17:28 +00:00
Philip Withnall
594a70bf5f Merge branch 'gvdb-as-wrap' into 'main'
build: Move gvdb to a subproject

See merge request GNOME/glib!2733
2022-06-16 09:29:43 +00:00
Philip Withnall
b3f49d08a6 build: Move gvdb to a subproject
Rather than carrying the copylib around inside GLib, which is a pain to
synchronise and affects our code coverage statistics.

This requires updating the CI images to cache the new subproject,
including updating the `cache-subprojects.sh` script to pull in git
submodules.

It also requires adding `gioenumtypes_dep` to be added to the
dependencies list of `libgio`, since it needs to be build before GVDB as
it’s pulled in by the GIO headers which GVDB includes.

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

Helps: #2603
2022-06-16 10:12:07 +01:00
Marco Trevisan (Treviño)
3a197d7500 glib-unix: Mark GLib.unix_open_pipe fds input array as fixed-size 2022-06-15 21:46:51 +02:00
Marco Trevisan (Treviño)
e5841beba6 gioerror: Map ENOSYS to G_IO_ERROR_NOT_SUPPORTED
If a wrong syscall is used, we can assume that such feature is not
supported at higher level.
2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
587f5f25d0 gioerror: Map ENETDOWN to G_IO_ERROR_NETWORK_UNREACHABLE 2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
3d6f843097 gioerror: Map ENOMSG, EBADMSG and ENODATA to G_IO_ERROR_INVALID_DATA 2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
19417b1a67 gioerror: Map ENFILE to G_IO_ERROR_TOO_MANY_OPEN_FILES
ENFILE stands for "Too many open files in system", so we can definitely
group it together with EMFILE ("Too many open files").
2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
6bc6b7ef30 gioerror: Map ETXTBSY to G_FILE_ERROR_BUSY
It's a busy text file, but we don't care much about specifics so we
can just return the generic busy error.
2022-06-15 20:44:10 +02:00
Marco Trevisan (Treviño)
d2ca48ad97 gioerror: Add G_IO_ERROR_NO_SUCH_DEVICE to map ENODEV 2022-06-15 20:43:56 +02:00
Marco Trevisan (Treviño)
9e09894414 gioerror: Handle EMLINK error as too-many-links error
This used to be a FreeBSD only error but it's actually defined also in
linux.
2022-06-15 20:41:53 +02:00
Marco Trevisan (Treviño)
35c6c5c663 tests: Add unit test for GIOErrorEnum conversion functions 2022-06-15 20:41:52 +02:00
Marco Trevisan (Treviño)
04718a9692 gfile: Implement interface API to make symbolic links asynchronously
The interface was ready for this API but it was not provided.

So implement this, using a thread that calls the sync API for now.

Add tests.

Helps with: GNOME/glib#157
2022-06-15 19:49:38 +02:00
Marco Trevisan (Treviño)
fe9e35624a gfile: Check that using NULL symlink_value as a programmer error
And also ensure that a null strings gives an error.
2022-06-15 19:49:38 +02:00
Philip Withnall
7674fd1504 docs: Add a testing policy
This documents our existing testing best practices, and tries to explain
some of the rationale around them.

There’s some new policy around performance tests, specifying that they
are good to keep around if they are high quality (so they can be used
again, the effort put into them not thrown away, and the numbers
compared over time) and that they should be runnable automatically to
avoid bitrot.

Everything else just documents existing practice.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-14 15:19:32 +01:00
Philip Withnall
9274a04cf1 Merge branch '2670-socket-client-cancellable-leak' into 'main'
gsocketclient: Fix still-reachable references to cancellables

Closes #2670

See merge request GNOME/glib!2745
2022-06-14 14:12:51 +00:00
Philip Withnall
2e1218ebe1 Merge branch 'freeze-shenanigans' into 'main'
Fix problems with notify-in-instance-init and add unit tests

Closes #2665

See merge request GNOME/glib!2737
2022-06-14 10:32:21 +00:00
Philip Withnall
0932f71460 gobject: Change GObject notify semantics under static analysis
Coverity notices the `g_object_unref()` call in `g_object_notify()`, but
not the paired `g_object_ref()` call. It therefore incorrectly assumes
that every call to `g_object_notify()` frees the object. This causes a
lot (hundreds) of false positive reports about double-frees or
use-after-frees.

I can’t find a way to fix this using a model file, so the other options
are:
 * Manually mark every report as a false positive and keep updating them
   as the code changes over time. This would take a lot of maintainer
   effort.
 * Comment out the `g_object_ref()`/`g_object_unref()` calls when
   running static analysis (but not in a normal production build). This
   is ugly, but cheap and shouldn’t impact maintainability much.

So this commit implements option 2.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-14 11:25:50 +01:00
Philip Withnall
56d371942e gsocketclient: Fix still-reachable references to cancellables
`GSocketClient` chains its internal `GCancellable` objects to ones
provided by the caller in two places using `g_cancellable_connect()`.
However, it never calls `g_cancellable_disconnect()`, instead relying
(incorrectly) on the `GCancellable` provided by the caller being
short-lived.

In the (valid) situation where a caller reuses one `GCancellable` for
multiple socket client calls, or for calls across multiple socket
clients, this will cause the internal `GCancellable` objects from those
`GSocketClient`s to accumulate, with one reference left each (which is
the reference from the `g_cancellable_connect()` closure).

These `GCancellable` instances aren’t technically leaked, as they will
all be freed when the caller’s `GCancellable` is disposed, but they are
no longer useful and there is no bound on the number of them which will
hang around.

For a program doing a lot of socket operations, this still-reachable
memory usage can become significant.

Fix the problem by adding paired `g_cancellable_disconnect()` calls.
It’s not possible to add a unit test as we can’t measure still-reachable
memory growth before the end of a unit test when everything has to be
freed.

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

Fixes: #2670
2022-06-14 11:15:18 +01:00
Philip Withnall
af7ba68a00 gobject: ifdef out some inline functions if they’re not used
This prevents `-Wunused-function` warnings on platforms which don’t have
`HAVE_OPTIONAL_FLAGS` defined.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-06-14 11:10:09 +01:00
Matthias Clasen
10a1c16b59 Avoid atomics during construction
During construction, we have exclusive access to
the object, so there is no need to use atomics
for setting or reading the optional_flags member.
2022-06-14 11:09:53 +01:00
Matthias Clasen
b92f1fcbc5 Handle notify freezing with custom constructors
g_object_new_with_custom_constructor needs to handle
freezing notifications in the same way as
g_object_new_internal.

Fixing a bug pointed out by Christian Hergert.
2022-06-12 12:01:25 -04:00
Matthias Clasen
dccab10d9f Add another testcase
This is similar to the notify-in-init testcase
added recently, but with a custom constructor.
2022-06-12 12:01:16 -04:00
Matthias Clasen
58ab960a87 Handle a corner-case of notify avoidance
The corner-case we are handling here is that
we don't freeze the notify queue in g_object_init
(because there's no custom ->notify vfunc, but
then we gain a notify handler during instance
init, and instance init also triggers a
notification. Handle this by jit freezing
notification in g_object_notify_by_spec_internal.

Note that this is bad code - instance init really
shouldn't be doing things like this.

Testcase included.

Fixes: #2665
2022-06-12 12:01:08 -04:00
Matthias Clasen
9444ace2c8 Unconditionally mark objects as in-construction
This will be used for things other than
custom constructors in the following commits.
2022-06-12 12:01:08 -04:00