Commit Graph

26384 Commits

Author SHA1 Message Date
Chun-wei Fan
08e0fef632 glib-private.c: Add private API to override invalid parameter handler
...if supported, as in the previous commit.  We will eventually use
these private API to override the invalid parameter handler as needed
in the other parts of GLib and the tests.

We also now use _set_thread_local_invalid_parameter_handler()
instead of just _set_invalid_parameter_handler() to be safer, if
that is available.

This can be expanded upon in the future if we desire to use a stricter
or more customized invalid parameter handler.
2022-11-03 00:11:45 +08:00
Chun-wei Fan
b92b17f021 build: Check for invalid parameter overriding on Windows
Allow one to override the invalid parameter handler if we have the
following items:

* _set_invalid_parameter_hander() or
  _set_thread_local_parameter_handler()
* _CrtSetReportMode() as a function or macro

Currently, we are doing this on Visual Studio to allow GSpawn to work on
Windows as well as having the log writer support color output, as we
might be passing in file descriptors that are invalid, which will cause
the CRT to abort unless the default invalid parameter handler is
overridden.
2022-11-03 00:11:45 +08:00
Ray Strode
274150a391 gspawn: Provide less brute force fdwalk implementation on macOS
It seems macOS has a way to query open fds for a process, so this
commit tries to use it, instead of just trying all fds between
0 and $BIGNUMBER.
2022-11-02 11:31:08 -04:00
Simon McVittie
92730c6226 Merge branch 'revert-it-all-and-let-god-sort-em-out' into 'main'
Revert "Handling collision between standard i/o file descriptors and newly created ones"

Closes #2795, #2785, and #16

See merge request GNOME/glib!3029
2022-11-02 14:34:39 +00:00
Ray Strode
aaae515e13 Revert "gstdio: Temporarily disable g_close() warning on macOS"
This reverts commit 5190354ad9.

Now that g_close isn't called from gspawn anymore, we can reenable
the g_close warning on macOS.

Closes: #2785
2022-11-02 09:40:28 -04:00
Ray Strode
168fd4f2b3 gspawn: Don't use g_close when doing fdwalk to close potentially invalid fds
Some platforms (e.g., macOS) don't currently have a way
to close only open fds in preparation for exec. On these
platforms, glib just bites the bullet and calls g_close for
the whole fileno range.

g_close only allows valid fds to be given to it, though.

This commit ensures close is called instead of g_close on
those platforms by splitting the safe_fdwalk implementation
that operates on invalid fds off to its own function and
only using it as a fall back.
2022-11-02 09:36:26 -04:00
Ray Strode
ac4dbc82e1 gspawn: Make sure pipe fds end up at the right place
It's possible when gspawn sets up its pipes for standard io,
that the pipe fds themselves end up in the standard io range
reserved for stdin, stdout, stderr.

This commit protects against that problem by relocating the
fds up, outside of the range.

Closes: #16
2022-11-02 09:36:26 -04:00
Ray Strode
e3ae492550 tests: Add g_spawn_test for when stdio fd range is exposed
This commit adds a test to make sure GSpawn still works even
if fds 0, 1, and 2 are closed before it's run.
2022-11-02 09:36:26 -04:00
Ray Strode
2399585860 gspawn: Rename CHILD_DUP2_FAILED to CHILD_DUPFD_FAILED
The error code is already used for both F_DUPFD and dup2
already, and having dup2 in the name is oddly specific.

This renames the error code for clarity.
2022-11-02 09:06:34 -04:00
Ray Strode
e5782dcafc glib-unix: Add test to make sure g_unix_open_pipe will intrude standard range
Now that we know it's a bad idea to avoid the standard io fd range
when getting pipe fds for g_unix_open_pipe, we should test to make sure
we don't inadvertently try to do it again.

This commit adds that test.
2022-11-02 09:06:34 -04:00
Ray Strode
dad97d24d5 Revert "Handling collision between standard i/o file descriptors and newly created ones"
g_unix_open_pipe tries to avoid the standard io fd range
when getting pipe fds. This turns out to be a bad idea because
certain buggy programs rely on it using that range.

This reverts commit d9ba615090

Closes: #2795
Reopens: #16
2022-11-02 09:06:34 -04:00
Philip Withnall
451ed353f5 Merge branch 'wip/smcv/tests-license' into 'main'
Add a SPDX LicenseRef for the license historically used for tests

See merge request GNOME/glib!3049
2022-11-02 12:55:50 +00:00
Simon McVittie
2673b262aa custom-dispatch: Change SPDX-License-Identifier to match license grant
The SPDX-License-Identifier said LGPL-2.1-or-later, but the license
grant was a permissive license, which we now identify as
LicenseRef-old-glib-tests.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 12:35:45 +00:00
Simon McVittie
32b0dd24e3 Add a SPDX LicenseRef for the license historically used for tests
Some of GLib's unit tests are under an apparently GLib-specific
permissive license, vaguely similar to the BSD/MIT family but with the
GPL's lack-of-warranty wording. This is not on SPDX's list of
well-known licenses, so we need to use a custom license name prefixed
with LicenseRef if we want to represent this in SPDX/REUSE syntax.

Most of the newer tests seem to be licensed under LGPL-2.1-or-later
instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-02 12:34:19 +00:00
Philip Withnall
7ee767213b Merge branch 'mcatanzaro/#2799' into 'main'
gproxyresolver: lookup_finish() should better parallel lookup_async()

Closes #2799

See merge request GNOME/glib!3045
2022-11-02 09:47:32 +00:00
Philip Withnall
0e9e51767a Merge branch 'variant-docs' into 'main'
docs: Convert GVariant Specification to reStructuredText

See merge request GNOME/glib!3044
2022-11-02 09:40:24 +00:00
Xavier Claessens
f6edb52bda Merge branch 'wip/3v1n0/some-meson-fixmes' into 'main'
meson: Handle various build system FIXME's

See merge request GNOME/glib!3012
2022-11-01 23:36:04 +00:00
Michael Catanzaro
7f85fd126b gproxyresolver: lookup_finish() should better parallel lookup_async()
In g_proxy_resolver_lookup_async() we have some error validation that
detects invalid URIs and directly returns an error, bypassing the
interface's lookup_async() function. This is great, but when the
interface's lookup_finish() function gets called later, it may assert
that the source tag of the GTask matches the interface's lookup_async()
function, which will not be the case.

As suggested by Philip, we need to check for this situation in
g_proxy_resolver_lookup_finish() and avoid calling into the interface
here if we did the same in g_proxy_resolver_lookup_async(). This can be
done by checking the source tag.

I added a few new tests to check the invalid URI "asdf" used in the
issue report. The final case, using async GProxyResolver directly,
checks for this bug.

Fixes #2799
2022-11-01 13:40:35 -05:00
Emmanuele Bassi
c33edff7fa Apply 2 suggestion(s) to 1 file(s) 2022-11-01 17:38:22 +00:00
Patrick Monnerat
f2c590f494 tests/mkenums.py: add a test case for symbolic expression evaluation 2022-11-01 16:06:20 +01:00
Patrick Monnerat
96fa9752b2 glib-mkenums: evaluate private symbols too
This allows them to be referenced in other symbols value computation.

In addition, this fixes the automatically assigned value of a public
symbol that is preceded by a private one:

        typedef enum {
          /*< private >*/
          ENUM_VALUE_PRIVATE,
          /*< public >*/
          ENUM_VALUE_PUBLIC,                    <--- value is 1, not 0.
        } SomeExampleEnum;
2022-11-01 15:46:13 +01:00
Philip Withnall
993325400d Merge branch 'task-strdup-avoidance' into 'main'
task: Don't overwrite source names

See merge request GNOME/glib!2869
2022-11-01 13:26:17 +00:00
Philip Withnall
088df783c0 docs: Convert GVariant Specification to reStructuredText
This is a verbatim conversion of the GVariant Specification from
https://people.gnome.org/~desrt/gvariant-serialisation.pdf /
https://raw.githubusercontent.com/ostreedev/gvariant-rs/master/docs/gvariant-serialisation.pdf
to reStructuredText.

This is for several reasons:
 1. The canonical copy has gone offline due to people.gnome.org being
    shut down.
 2. GLib is the reference implementation of GVariant, so should probably
    host the specification (unless someone wants to host it on
    freedesktop-specs).
 3. Moving it out of a PDF and into reStructuredText should allow for
    amendments. The specification has a few problems, typos and
    oversights in its original form, and it would be good to canonically
    fix them without having to write a separate addendum document.

This conversion is verbatim, and does not change the content of the
document at all, even to fix typos and broken links (which there are a
small number of in the PDF).

This describes what I’m labelling as version 1.0 of the GVariant
serialisation format. Updates to the specification can bump this version
number, in subsequent commits.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-11-01 13:12:53 +00:00
Matthias Clasen
13e48ff963 tests: Tweak the task tests
Tweak the g_task_set_name test to use a non-literal string,
so we don't test g_task_set_static_name twice.
2022-11-01 11:48:52 +00:00
Matthias Clasen
525e3953ef tests: Add a test for g_task_set_static_name()
The test checks that the original string
is returned by g_task_get_name().
2022-11-01 11:48:46 +00:00
Matthias Clasen
99c7d60869 gtask: Add g_task_set_static_name()
Similar to g_source_set_static_name, this avoids
strdup overhead for debug-only information in
possibly hot code paths.

We also add a macro wrapper for g_task_set_name that
uses __builtin_constant_p to decide whether to use
g_task_set_name or g_task_set_static_name.
2022-11-01 11:48:38 +00:00
Matthias Clasen
794ee60306 gdbusconnection: Set a name on all sources
We already set names on most sources, this
one was just forgotten. This lets us set
a static name, and prevents g_task_attach_source
from setting a non-static one.
2022-11-01 11:48:33 +00:00
Matthias Clasen
01f2c5aec9 gtask: Don't overwrite source names
Only set a name in g_task_attach_source
if the source does not already have one.

Including a new test by Philip Withnall.
2022-11-01 11:48:08 +00:00
Philip Withnall
110cddb90c Merge branch 'wip/smcv/os-detect' into 'main'
docs: Mention platform-specific predefined macros

See merge request GNOME/glib!2997
2022-11-01 11:00:03 +00:00
Philip Withnall
debf3e4a87 Merge branch 'sandbox-check' into 'main'
gio: Create a sandbox checking function

See merge request GNOME/glib!3037
2022-11-01 10:45:05 +00:00
Simon McVittie
871237b9d5 docs: Mention platform-specific predefined macros
The platform-specific predefined macros provided by various compilers
sometimes capture subtle differences of meaning, like the distinction
between the Linux kernel and a glibc-based (GNU/Linux) user-space.
It would be difficult to capture those subtleties in GLib-specific
convenience macros, particularly for platforms that we don't use
ourselves.

Instead, recommend that anyone who is already writing platform-specific
code should use the platform-specific predefined macros directly.

Alternative to !2986.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-11-01 10:40:37 +00:00
Robert Ancell
bfd7074dfc gio: Fix formatting 2022-11-01 10:20:36 +00:00
Robert Ancell
5a83f384d1 Fix meson formatting 2022-11-01 10:20:36 +00:00
Robert Ancell
568763e776 gio: Create a sandbox checking function 2022-11-01 10:20:36 +00:00
Patrick Monnerat
0120cd772a glib-mkenums: feature use of previous symbols in evaluation
Enum symbols can be defined with a value computed from previously
defined enum symbols. The current evaluator does not support this and
requires a literal integer expression.

This commit introduces a C symbol namespace that is filled along
code generation and provided as a local namespace for new symbols
evaluation, effectively allowing definitions such as:

	typedef enum {
	  a = 4;
	  b = a + 2;
	}  myenum;

to be successfully processed.
2022-11-01 02:12:26 +01:00
Marco Trevisan (Treviño)
c6eddf897b ci: Do not use installed tests in debian-stable build
Setting installed_tests option enforces various test files to be
installed, this causes meson to build tools that might have not built
otherwise but that are still required for testing.

Also, disabling installed tests lead to slightly different code paths
when it comes to using test test files.

So, disable it for debian so that we can ensure that at test time we
have set all the dependencies between test programs and the used
resources (that can be libraries, external programs or modules).
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
038ef36b99 gobject/tests/meson: Make gobject-query.py test depend on gobject-query util
The utility is used by the script, so we need to depend on it.
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
a106ce4445 gobject/tests/meson: Add support to add extra depends args to python tests 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
eef2b0b39e gmodule/tests/meson: Make tests depending on loaded libraries and modules 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
82fc49fa10 glib/tests/meson: Add test programs dependencies to single tests
Various glib tests (such as the spawn ones) depend on local binaries
being built, this may not happen (especially when not using installed
tests), thus ensure such dependencies via the newly added extra_programs
key
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
495017e2db glib/tests/meson: Compile tests extra programs using same strategy as gio
This allows also to keep track of targets and to make possible for a
test to depend on a particular test program
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
c490e3c522 gio/tests/meson: Add resource plugin as test dependency 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
407c45ddaf gio/tests/meson: Add fake-service-name as gdbus-names dependency
It uses a fake name owner that we didn't depend on
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
ed013f9550 gio/tests/meson: Make giomodule test to depend on built modules
These are loaded dynamically so we need to ensure they're available at
test time
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
ff195b6e0d gio/tests/meson: Add dbus-launch as dependency of gdbus-address-get-session 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
fd2b4e4ca4 gio/tests/meson: Add glib-compile-schemas as dependency for gsettings test 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
0525a32c09 gio/tests/meson: Add fake-document-portal as dependency of dbus-appinfo
It uses the portal, but it doesn't depend on it.
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
cb85b26dd2 gio/tests/meson: Add gdbus-connection-flush-helper as dependency of connection tests 2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
01349e8e7f gio/tests/meson: Add gdbus-testserver prog as dependency of GDbus tests
Most gdbus tests launch the gdbus-testserver binary, so add it as
dependency of such tests.
2022-11-01 01:56:27 +01:00
Marco Trevisan (Treviño)
caf75d8f9c gio/tests/meson: Add basic-application as prerequisite of gapplication
It's currently commented code, but in any case it's better to build it
earlier
2022-11-01 01:56:27 +01:00