Commit Graph

23085 Commits

Author SHA1 Message Date
Philip Withnall
6cca256526 Merge branch 'wip/avoid-searching-path' into 'master'
spawn: Don't set a search path if we don't want to search PATH

See merge request GNOME/glib!1902
2021-02-01 11:58:51 +00:00
Simon McVittie
07bf886cf3 Merge branch 'wip/smcv/address-sanitizer' into 'master'
Start to ignore known leaks under AddressSanitizer

See merge request GNOME/glib!1905
2021-02-01 11:32:56 +00:00
Simon McVittie
f378352051 tests: Mark tests with AddressSanitizer-detected leaks
Various tests have leaks where it isn't clear whether the data is
intentionally not freed, or leaked due to a bug. If we mark these
tests as TODO, we can skip them under AddressSanitizer and get the
rest to pass, giving us a baseline from which to avoid regressions.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-01 11:19:59 +00:00
Simon McVittie
41ed1c6d5d gutils: Tell AddressSanitizer not to track previous XDG directories
We reset these in some unit tests, and must deliberately leak them to
avoid having to break API.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-01 10:44:35 +00:00
Simon McVittie
023793071b glib-private: Add wrappers for telling AddressSanitizer to ignore leaks
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-01 10:44:35 +00:00
Simon McVittie
9fef98cf84 gtestutils: Default to -m no-undefined under AddressSanitizer
AddressSanitizer detects memory leaks, NULL parameters where only a
non-NULL parameter is expected, and other suspicious behaviour, so if
we try to test that sort of thing we can expect it to fail.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-01 10:44:35 +00:00
Simon McVittie
98804781ce glib-private: Add infrastructure to detect AddressSanitizer
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-01 10:44:35 +00:00
Simon McVittie
5685546ab1 gio: Don't run gsocketclient-slow test under sanitizers
AddressSanitizer, UndefinedBehaviourSanitizer and probably others
involve adding instrumentation into the code under test, which doesn't
go well with LD_PRELOAD modules that absolutely need to be
self-contained.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-01 10:44:35 +00:00
Simon McVittie
def3e33c36 error test: Don't test programmer error if asked not to
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-02-01 10:44:35 +00:00
Emmanuel Fleury
2fd429046d Fix several missing initializer warnings in gio/gapplication.c:g_application_parse_command_line()
gio/gapplication.c: In function ‘g_application_parse_command_line’:
gio/gapplication.c:545:11: error: missing initializer for field ‘arg_description’ of ‘GOptionEntry’ {aka ‘struct _GOptionEntry’}
  545 |           N_("Enter GApplication service mode (use from D-Bus service files)") },
      |           ^~
gio/gapplication.c:557:11: error: missing initializer for field ‘arg_description’ of ‘GOptionEntry’ {aka ‘struct _GOptionEntry’}
  557 |           N_("Override the application’s ID") },
      |           ^~
gio/gapplication.c:569:11: error: missing initializer for field ‘arg_description’ of ‘GOptionEntry’ {aka ‘struct _GOptionEntry’}
  569 |           N_("Replace the running instance") },
      |           ^~
2021-02-01 11:14:21 +01:00
Emmanuel Fleury
0cc48ee937 Fix missing initializer warning in gio/gdbusobjectmanagerserver.c
gio/gdbusobjectmanagerserver.c:892:1: error: missing initializer for field ‘padding’ of ‘GDBusInterfaceVTable’ {aka ‘const struct _GDBusInterfaceVTable’}
  892 | };
      | ^
2021-02-01 11:14:21 +01:00
Emmanuel Fleury
68e69a4128 Fix missing initializer warning in gio/gdbusconnection.c:g_dbus_connection_register_object_with_closures()
gio/gdbusconnection.c: In function ‘g_dbus_connection_register_object_with_closures’:
gio/gdbusconnection.c:5527:5: error: missing initializer for field ‘padding’ of ‘GDBusInterfaceVTable’ {aka ‘struct _GDBusInterfaceVTable’}
 5527 |     };
      |     ^
2021-02-01 11:14:21 +01:00
Emmanuel Fleury
80fa64d974 Fix missing initializer warning in gio/gdelayedsettingsbackend.c:delayed_backend_path_writable_changed()
gio/gdelayedsettingsbackend.c: In function ‘delayed_backend_path_writable_changed’:
gio/gdelayedsettingsbackend.c:406:7: error: missing initializer for field ‘index’ of ‘CheckPrefixState’
  406 |       CheckPrefixState state = { path, g_new (const gchar *, n_keys) };
      |       ^~~~~~~~~~~~~~~~
2021-02-01 11:14:21 +01:00
Sebastian Dröge
c07f8a70dc Merge branch 'th/gsignal-cleanup' into 'master'
[th/gsignal-cleanup] minor changes to GSignal related code

See merge request GNOME/glib!1900
2021-02-01 09:07:51 +00:00
Thomas Haller
8416211231 gsignal: use g_clear_signal_handler() macro to implement g_clear_signal_handler() function
We have a "good" implementation of g_clear_signal_handler() in
form of a macro. Use it, and don't duplicate the code.

Also add a comment to the documentation that "instance" in fact must
not point to a valid GObject instance -- if the handler ID is unset.

Also reword the documentation about the reasoning for why a macro
version exists. The reason is not to use the function "without
pointer cast". I don't think the non-macro version requires any
pointer cast, since "instance" is a void pointer. Was this referring
to the handler_id_ptr? That doesn't seem right either, because the
caller should always provide a "gulong *" pointer and nothing else.
2021-02-01 09:45:46 +01:00
Thomas Haller
7777f3bdbe gsignal: let g_clear_signal_handler() evaluate argument only once
Preferably macros behave function-like to minimize surprises. That
means for example that they evaluate all arguments exactly once.

Rework g_clear_signal_handler() to assign the macro parameters
to auto variables so they are accessed exactly once.

Also, drop the static assert for the size of (*handler_id_ptr).
As we now assign to a "gulong *" pointer, the compiler already
checks the types. In fact, the check is now stricter than before.
Previously it would have allowed a pointer to a "signed long".
This is a change in behavior of the macro and the stricter compile
check could cause a build failure with broken code.

Also, clear the handler id first, before calling
g_signal_handler_disconnect(). Disconnecting a signal invokes the
destroy notify, which can have side effects. It just feels cleaner
to first reset the *_handler_id_ptr, before those side effects
can happen. Of course, in practice it makes little difference.
2021-02-01 09:45:16 +01:00
Thomas Haller
cc4ffe4742 gsignal: use stack allocate temporary buffer in g_signal_new_valist()
g_signal_new_valist() is called by g_signal_new(), which is probably
the most common way to create a signal.

Also, in almost all cases is the number of signal parameters small.

Let's optimize for that by using a stack allocated buffer if we have
few parameters.
2021-02-01 09:43:29 +01:00
Simon McVittie
a85c126602 Expand test coverage for G_SPAWN_SEARCH_PATH
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-31 14:15:37 +00:00
Thomas Haller
e864c6577a spawn: prefer allocating buffers on stack for small sizes to avoid valgrind leaks
We preallocate buffers that are used after forked. That is because
malloc()/free() are not async-signal-safe and must not be used between
fork() and exec().

However, for the child process that exits without fork, valgrind wrongly
reports these buffers as leaked.
That can be suppressed with "--child-silent-after-fork=yes", but it is
cumbersome.

Work around by trying to allocate the buffers on the stack. At
least in the common cases where the pointers are small enough
so that we can reasonably do that.

If the buffers happen to be large, we still allocate them on the heap
and the problem still happens. Maybe we could have also allocated them
as thread_local, but currently glib doesn't use that.

[smcv: Cosmetic adjustments to address review comments from pwithnall]
2021-01-31 13:37:13 +00:00
Sebastian Dröge
abd1f4b32b Merge branch 'ricotz/for-master' into 'master'
gio: Add explicit virtual g-i annotations for undiscovered invoker relationship

See merge request GNOME/glib!1910
2021-01-31 09:56:18 +00:00
Philip Withnall
ede8900f4e Merge branch 'fix_more_warnings' into 'master'
Fix more warnings

See merge request GNOME/glib!1891
2021-01-30 22:34:40 +00:00
Rafael Fontenelle
e928ddd499 Update Brazilian Portuguese translation 2021-01-30 19:44:48 +00:00
Sebastian Dröge
5f6eb627ff Merge branch 'override-gio-querymodules' into 'master'
Meson: override gio-querymodules program

See merge request GNOME/glib!1909
2021-01-30 12:09:43 +00:00
Sebastian Dröge
96cf1b79c5 Merge branch 'wip/test-leaks' into 'master'
Fix straightforward memory leaks in tests

See merge request GNOME/glib!1908
2021-01-30 12:06:48 +00:00
Rico Tzschichholz
ce8d5e3478 gio: Add explicit virtual g-i annotations for undiscovered invoker relationship 2021-01-30 13:00:01 +01:00
Xavier Claessens
ebcca60b4d Meson: override gio-querymodules program
It is going to be used in Meson's gnome module, and if glib is built as
subproject it's better to use it.

See https://github.com/mesonbuild/meson/pull/8272.
2021-01-29 18:57:09 -05:00
Simon McVittie
d499c53158 threadpool test: Don't leak the thread pool
Detected by AddressSanitizer.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-29 20:26:05 +00:00
Simon McVittie
5b476d0d9c socket-service test: Don't leak writev vectors
Detected by AddressSanitizer.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-29 20:26:02 +00:00
Philip Withnall
3970ddec06 Merge branch '1054-check-bash-comp-dir' into 'master'
Check the completiondir from bash-completion package config file.

Closes #1054

See merge request GNOME/glib!1896
2021-01-29 17:21:31 +00:00
Frederic Martinsons
525bbb7712 Check the completiondir from bash-completion package config file.
With bash completion version lesser than 2.10, only prefix is defined
while for greater version it is datadir.

Closes #1054

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-01-29 18:10:52 +01:00
Philip Withnall
9a34c35c2b Merge branch 'wip/smcv/gdbus-test-leak' into 'master'
gdbus-serialization: Don't leak string containing first serialization

See merge request GNOME/glib!1906
2021-01-29 16:31:42 +00:00
Simon McVittie
de87bcf7ff gdbus-serialization: Don't leak string containing first serialization
We format the message into a string twice, once for each byte-order,
but only return the one corresponding to the last byte-order to the
caller. This means we need to free the first one.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-28 21:39:23 +00:00
Simon McVittie
82adfd7e3a Add test coverage for G_SPAWN_SEARCH_PATH
For manual test coverage that would reproduce the bug fixed in !1902,
copy /bin/true (or any other harmless executable) to
/usr/bin/spawn-test-helper.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-28 18:37:45 +00:00
Philip Withnall
628435eb16 Merge branch 'wip/autoconf-serial' into 'master'
m4macros: Increment serial number of glib-2.0.m4

See merge request GNOME/glib!1903
2021-01-28 17:39:09 +00:00
Philip Withnall
13839f75d3 Merge branch 'ci-check-remote-exist' into 'master'
Check if the remote already exists before adding it.

See merge request GNOME/glib!1901
2021-01-28 17:24:06 +00:00
Philip Withnall
9ea75d10d4 Merge branch '344-gdbus-completion' into 'master'
[gdbus-tool] Check object path validity during completion inside print_paths

Closes #344

See merge request GNOME/glib!1897
2021-01-28 17:02:15 +00:00
Simon McVittie
7ff0fb3af5 spawn: Don't set a search path if we don't want to search PATH
do_exec() and g_execute() rely on being passed a NULL search path
if we intend to avoid searching the PATH, but since the refactoring
in commit 62ce66d4, this was never done. This resulted in some spawn
calls searching the PATH when it was not intended.

Spawn calls that go through the posix_spawn fast-path were unaffected.

The deprecated gtester utility, as used in GTK 3, relies on the
ability to run an executable from the current working directory by
omitting the G_SPAWN_SEARCH_PATH flag. This *mostly* worked, because
our fallback PATH ends with ".". However, if an executable of the
same name existed in /usr/bin or /bin, it would run that instead of the
intended test: in particular, GTK 3's build-time tests failed if
ImageMagick happens to be installed, because gtester would accidentally
run display(1) instead of testsuite/gdk/display.

Fixes: 62ce66d4 "gspawn: Don’t use getenv() in async-signal-safe context"
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=977961
2021-01-28 16:49:06 +00:00
Xavier Claessens
4273c43902 glib_typeof: It is an API break that should be opt-in
That changes the return type of functions like g_object_ref() that can
break C++ applications like Webkit. Note that it is not an ABI break.

It must thus be opt-in the same way we did when adding this to
g_object_ref() for GNU C compilers in the first place. Unfortunately it
cannot be done directly in gmacros.h because GLIB_VERSION_2_68 is not
defined there, and gversionmacros.h cannot be included there because
there is some strict ordering in which those headers must be included.

This means that applications that does not define
GLIB_VERSION_MIN_REQUIRED will still get an API break, so we encourage
them to declare their minimum requirement to avoir such issues in the
future too.
2021-01-27 09:26:39 -05:00
Xavier Claessens
d95885d91e atomic: Fix type error with clang++
clang++ checks the 2nd args of __atomic_compare_exchange_n() has the
same type as the first, which fails when 2nd arg is nullptr which is of
type nullptr_t.

Ideally it should do `glib_typeof (*(atomic)) gapcae_oldval = (oldval);`
to ensure oldval and atomic have compatible types but unfortunately that
does not work neither.

Since that function never has been typesafe, and it is not even
attempting to use glib_typeof in case __ATOMIC_SEQ_CST is not defined,
drop it in __atomic_ case too.

Fixes issue #2226.
2021-01-27 09:23:48 -05:00
Xavier Claessens
51003d409b Use C++11 decltype where possible
There are various places glib uses __typeof__ for type safety, but
that's a GNUC extension. C++11 has standard decltype() that does a
similar job, at least for cases we care about.

This avoids C++ code to always have to cast return value of
g_object_ref() which was causing type kind of error:

error: invalid conversion from ‘gpointer’ {aka ‘void*’} to
‘GstElementFactory*’ {aka ‘_GstElementFactory*’} [-fpermissive]
2021-01-27 09:23:48 -05:00
Simon McVittie
25f297111e m4macros: Increment serial number of glib-2.0.m4
aclocal's ability to compare the version of macros and use the latest
version relies on the serial number being incremented on every change,
or at least on every functional change.

Fixes: 6f26637e "m4macros: replace obsolete macros AC_TRY_RUN and AC_TRY_LINK in glib-2.0.m4"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-27 11:55:37 +00:00
Frederic Martinsons
81e2fff49c Check if the remote already exists before adding it.
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-01-27 09:13:11 +01:00
Sebastian Dröge
fdc192f460 Merge branch 'fix/darwin-nosigpipe-regression' into 'master'
gsocket: Fix SO_NOSIGPIPE regression on Darwin

See merge request GNOME/glib!1894
2021-01-27 07:35:04 +00:00
Frederic Martinsons
1c7c849d34 Correct memory leaks of error in completion case.
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-01-26 19:42:21 +00:00
Frederic Martinsons
43c2d747a3 Check object path validity during completion inside print_paths.
Closes #344

Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
2021-01-26 19:42:21 +00:00
Philip Withnall
742e55b754 Merge branch 'fix/gwin32appinfo-printf-length-sub-specifier' into 'master'
gwin32appinfo: Fix printf length sub-specifier

See merge request GNOME/glib!1893
2021-01-26 17:52:10 +00:00
Philip Withnall
4dc7603b3e Merge branch 'autoconf-obsolete-macros' into 'master'
m4macros: replace obsolete macros AC_TRY_RUN and AC_TRY_LINK in glib-2.0.m4

See merge request GNOME/glib!1899
2021-01-26 13:16:42 +00:00
Philip Withnall
9e5b9a8f70 Merge branch 'wip/g-test-path' into 'master'
gtestutils: Add g_test_get_path() API

See merge request GNOME/glib!1898
2021-01-26 11:05:31 +00:00
Simon Marchi
6f26637e83 m4macros: replace obsolete macros AC_TRY_RUN and AC_TRY_LINK in glib-2.0.m4
Running autoconf 2.70 with -Wall,error on a configure.ac that uses
AM_PATH_GLIB_2_0 gives:

    configure.ac:261: warning: The macro `AC_TRY_RUN' is obsolete.
    configure.ac:261: You should run autoupdate.
    ./lib/autoconf/general.m4:2996: AC_TRY_RUN is expanded from...
    /usr/share/aclocal/glib-2.0.m4:11: AM_PATH_GLIB_2_0 is expanded from...
    configure.ac:261: the top level
    configure.ac:261: warning: The macro `AC_TRY_LINK' is obsolete.
    configure.ac:261: You should run autoupdate.
    ./lib/autoconf/general.m4:2919: AC_TRY_LINK is expanded from...
    /usr/share/aclocal/glib-2.0.m4:11: AM_PATH_GLIB_2_0 is expanded from...
    configure.ac:261: the top level

Run autoupdate on glib-2.0.m4 to change AC_TRY_RUN and AC_TRY_LINK into
the suggested alternative, and adjust the formatting a little bit.

The macros used in the alternative existed for long enough that there
shouldn't be a problem with backwards compatibility.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
2021-01-25 16:13:08 -05:00
Fran Dieguez
7be2e6bd80 Update Galician translation 2021-01-25 18:59:49 +00:00