18072 Commits

Author SHA1 Message Date
Marco Trevisan (Treviño)
80a2648953 subprocess: Fix communicate_cancelled signature
The source callback for a GCancellable should have the cancellable itself
as first argument.
This was not the case, and when this code was hit, we were instead trying
to treat the pointer as a CommunicateState reference and thus wrongly
deferencing it, causing a memory error and a crash.
2018-08-30 13:25:35 +01:00
Simon McVittie
8ca9c2e350 Merge branch '1465-g-gnuc-malloc-on-glib-2-56' into 'glib-2-56'
Backport G_GNUC_MALLOC fixes from #1465 to glib-2-56

See merge request GNOME/glib!261
2018-08-23 09:21:10 +00:00
Philip Withnall
c582b947cb Merge branch 'test-ip_mreq_source-android-only-2-56' into 'glib-2-56'
build: only test for broken ip_mreq_source on Android. Fixes #1472

See merge request GNOME/glib!249
2018-08-22 16:22:43 +00:00
Christoph Reiter
966b3d80e9 build: only test for broken ip_mreq_source on Android. Fixes #1472
7efd76dd6796f8 added these configure time tests to work around a bug
with older Android. Since the test didn't take Windows into account it
wrongfully applied the workaround on Windows too, breaking the build.
With meson this wasn't an issue since the check is skipped on Windows there
and our CI didn't catch this issue.

Change the test to run on Android only for meson and autotools.
This also makes it clear that the test+code can be dropped again if we stop
supporting older Android versions at some point.
2018-08-22 18:08:46 +02:00
Philip Withnall
0e10479f85 glib: Drop G_GNUC_MALLOC usage from various other allocation functions
These functions may be OK to leave the G_GNUC_MALLOC attribute on,
because the only valid pointers in the storage areas they return are,
themselves, new pointers.

However, it’s a lot easier to remove the attributes now than to try and
diagnose miscompilations in future. The performance impact of this is
likely to be unmeasurable. If there are performance problems caused by
this, then they can be profiled and fixed case-by-case in future,
bearing in mind the possibility for miscompilation if G_GNUC_MALLOC is
readded.

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

https://gitlab.gnome.org/GNOME/glib/issues/1465
2018-08-22 14:12:18 +01:00
Philip Withnall
41f23a2c44 glib: Drop G_GNUC_MALLOC usage from various allocation functions
These are our most critically incorrect uses of G_GNUC_MALLOC. See the
previous commit for details.

(Backport to 2.56: Drop the grcbox.h changes.)

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

https://gitlab.gnome.org/GNOME/glib/issues/1465
2018-08-22 14:12:18 +01:00
Philip Withnall
3d6c8e037d docs: Update the documentation for G_GNUC_MALLOC to reflect recent GCC
Thanks to some great investigation by Benjamin Moody, it’s clear that
our documentation and usage of G_GNUC_MALLOC has fallen behind GCC’s
interpretation of the malloc attribute, meaning that recent versions of
GCC could miscompile code which uses G_GNUC_MALLOC incorrectly.

Update the documentation of G_GNUC_MALLOC to match the current GCC
documentation (for GCC 8.2). Following commits will drop our use of
G_GNUC_MALLOC from inappropriate functions.

Specifically, the change in GCC’s interpretation of the malloc attribute
which could cause miscompilation is that returned storage areas are now
assumed to not contain valid pointers — so realloc() cannot have the
malloc attribute, and neither can a function which returns a newly
allocated structure with fields initialised to other pointers.

(Backport to 2.56: Change the documentation to mention GLib 2.56.3
rather than GLib 2.58.)

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

https://gitlab.gnome.org/GNOME/glib/issues/1465
2018-08-22 14:12:02 +01:00
Emmanuele Bassi
d8a496bdb4 Merge branch 'glib-2-56-ci-failure' into 'glib-2-56'
Fix persistent CI failure on glib-2-56

See merge request GNOME/glib!259
2018-08-22 11:11:05 +00:00
Philip Withnall
1eb52b6ea1 tests: Increase timeout for network-monitor-race test
It’s consistently timing out on the CI, which makes sense since it does
333 iterations of spawning a subprocess. Give it a bit more breathing
room.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-22 11:22:02 +01:00
Matthias Clasen
d4b60396c7 2.56.2 2.56.2 2018-08-16 20:24:55 -04:00
Matthias Clasen
d0f6a59fb0 network monitor portal: update properties initially
With version 2, we need to query the values explicitly.
The properties made this automatic.
2018-08-17 00:03:32 +00:00
Matthias Clasen
7ddd1de0dd network monitor: Update portal implementation
The network monitor portal interface is changing.
Version 2 is no longer using properties, but getters
instead (this lets the portal apply access control
and avoid sending information to non-networked
sandboxes).

To support both version 1 and 2 of the interface,
we stop using generated code and instead deal with
the api differences in our own code, which is not
too difficult.

Support version 1 as well
2018-08-16 16:54:14 -04:00
Milan Crha
edcce31f8e gnetworkmonitor: Fix use-after-free when using from another thread
When using g_network_monitor_get_default() from another thread, it’s
possible for network-changed events to be processed after an instance of
GNetworkMonitor has been disposed, causing use-after-free problems.

Fix that by moving some of the initialisation into the GInitable.init()
chain, rather than in a main context idle callback.

This includes a unit test which probabilistically reproduces the bug
(but can’t do so deterministically due to it being a race condition).

Commit amended by Philip Withnall <withnall@endlessm.com> before
pushing.

https://bugzilla.gnome.org/show_bug.cgi?id=793727
2018-08-16 16:53:53 -04:00
Ondrej Holy
0b4e821763 Merge branch 'cherry-pick-volume-mount-2-56' into 'glib-2-56'
Cherry pick GVolumeMonitor mount changes to glib-2-56 from issue #1458

See merge request GNOME/glib!224
2018-08-09 14:50:51 +00:00
Philip Withnall
d338fdaf75 Merge branch '1452-backport-glib-2-56' into 'glib-2-56'
Backport GFileInfo win32 fixes to glib-2-56

See merge request GNOME/glib!237
2018-08-09 10:12:46 +00:00
Руслан Ижбулатов
7fa2ad51a8 W32: consider NTFS mounpoints to be symlinks
While mountpoints are *not* symlinks, strictly speaking,
they works in a similar enough way, so consider them to be
symlinks for the purpose of querying local file info.
2018-08-09 10:30:37 +01:00
Руслан Ижбулатов
9f56652cea W32: correctly use st_ctime
On Windows st_ctime field is the file creation time.
POSIX mandates that field to be the file state change time.
Naturally, glib code interpreted st_ctime as POSIX suggested,
and the result was bad.
Fix this by introducing special W32-only logic for setting
attributes from st_ctime field.

Fixes issue #1452.
2018-08-09 10:30:37 +01:00
Ondrej Holy
2c1aee1963 gio-tool: Hold GVolumeMonitor reference during operations
Releasing GVolumeMonitor before g_volume_mount finish cause that
g_volume_get_mount returns NULL, because the mount is not correctly
propagated to the volume.

(Backported from commit 88b8ebb5dde0512fd1e098efe4c217111876d252 with
minor merge conflicts.)

https://gitlab.gnome.org/GNOME/glib/issues/1458
2018-08-03 11:53:09 +01:00
Ondrej Holy
f9ab355896 gio: Update mounts after g_volume_mount
The documentation claims that g_volume_get_mount should	succeed	after
g_volume_mount. Let's update mounts before releasing g_volume_mount to
be sure that the mount is added to the corresponding volume. The same
is done in GVfsUDisks2VolumeMonitor.

(Backported from commit 9b6b282e0a9d3f37865aa36e21ea57bd2a326e20 with no
merge conflicts.)

https://gitlab.gnome.org/GNOME/glib/issues/1458
2018-08-03 11:53:09 +01:00
Ondrej Holy
86b5b440a8 Merge branch 'cifs-is-not-a-system-fs' into 'master'
gunixmounts: Stop considering cifs/nfs as system file systems

See merge request GNOME/glib!125

(cherry picked from commit 51132b1d49c184f49baafa81ce7fac02b1458643)

a3a6c516 gunixmounts: Stop considering cifs/nfs as system file systems
2018-06-29 07:11:54 +00:00
Philip Withnall
baeaca4f31 Merge branch '1280-fdo-notification-glib-2-56' into 'glib-2-56'
Backport "fdo notification backend: Crashes when dbus call fails" to glib-2-56

See merge request GNOME/glib!102
2018-06-13 14:28:15 +00:00
Arnaud Rebillout
d26b66e225 gfdonotificationbackend: Fix possible invalid pointer in dbus callback
The way things were before: a FreedesktopNotification struct is
allocated before the dbus call, and this same struct is possibly re-used
for other dbus calls. If the server becomes unavailable, the callback
will be invoked after the call times out, which leaves a long time where
other dbus calls can happen, re-using the same FreedesktopNotification
as user data. When the first call times out, the callback is invoked,
and the user data is freed. Subsequent calls that used the same user
data will time out later on, and try to free a pointer that was already
freed, hence segfaults.

This bug can be reproduced in Cinnamon 3.6.7, as mentioned in:
<https://github.com/linuxmint/Cinnamon/issues/7491>

This commit fixes that by always allocating a new
FreedesktopNotification before invoking dbus_call(), ensuring that the
callback always have a valid user data.

Signed-off-by: Arnaud Rebillout <elboulangero@gmail.com>
2018-06-13 14:08:50 +01:00
Philip Withnall
4a27a88d29 ci: Use v3 of the Docker image for CI builds
Don’t update to the full CI setup from master, since its success depends
on other fixes which are only present in master. However, using v1 of
the Docker image is no longer possible since it’s been removed from the
registry. Using v3 should enable CI builds for glib-2-56 to succeed.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-06-13 14:07:18 +01:00
Philip Withnall
826676e826 Merge branch '101-dbus-is-supported-glib-2-56' into 'glib-2-56'
Backport "g_dbus_is_supported_address(): set error if returning FALSE" to glib-2-56

See merge request GNOME/glib!103
2018-06-13 12:38:05 +00:00
Will Thompson
aaa00b5c98 g_dbus_is_supported_address(): set error if returning FALSE
Previously, calling:

    g_dbus_is_supported_address ("some-imaginary-transport:", NULL)

correctly returned FALSE; but calling:

    g_dbus_is_supported_address ("some-imaginary-transport:", &error)

crashed with:

    GLib-GIO:ERROR:../gio/gdbusaddress.c:434:g_dbus_is_supported_address:
    assertion failed: (ret || (!ret && (error == NULL || *error != NULL)))

This was because, if the address component did not start with a known
transport, no error was set. Fix this, reusing an error string used by
the corresponding else branch in g_dbus_address_connect(), and adjust
the test to pass both NULL and non-NULL GError **s to this function in
every test case. This case:

    g_assert (!g_dbus_is_supported_address ("some-imaginary-transport:foo=bar;unix:path=/this/is/valid", NULL));

would have caught this bug with a non-NULL GError **.
2018-06-13 13:35:35 +01:00
Xavier Claessens
c0e6cc3a40 Merge branch 'cherry-pick-95ebaa26' into 'glib-2-56'
Merge branch '1401-g_clear_handle_id-clear_func-not-nullable' into 'master'

See merge request GNOME/glib!56
2018-06-05 14:43:36 +00:00
Philip Withnall
cfa28e152b Merge branch '1401-g_clear_handle_id-clear_func-not-nullable' into 'master'
g_clear_handle_id: don't accept NULL clear_func

Closes #1401

See merge request GNOME/glib!55

(cherry picked from commit 95ebaa26aa5b2a5f6e5ee554a6d185d296f6dc08)

0f7c196c g_clear_handle_id: don't accept NULL clear_func
2018-06-04 13:43:21 +00:00
Philip Withnall
69dec2db49 Merge branch 'lrn/issue-1240_glib-2-56' into 'glib-2-56'
W32: Make _g_win32_get_system_data_dirs() inline available in C++ (glib-2-56 backport)

See merge request GNOME/glib!29
2018-05-28 08:58:46 +00:00
Руслан Ижбулатов
d5f1da8c39 W32: Make _g_win32_get_system_data_dirs() inline available in C++
This way g_get_system_data_dirs() works the same way in C and C++.

https://bugzilla.gnome.org/show_bug.cgi?id=777501

Closes #1240
2018-05-28 08:48:06 +00:00
Руслан Ижбулатов
0bc1e98af6 W32: check filename for being NULL in g_stat()
Previous version of this function started with a call to g_utf8_to_utf16(),
which also served as a NULL check, since g_utf8_to_utf16() just returns NULL
on NULL strings. Current version of this function does some filename string
checks first and converts it to utf16 only after these checks are done, and
these checks do not take into account the possibility of filename being NULL.

Fix this by explicitly checking for NULL.
2018-05-22 16:47:34 +00:00
Nirbheek Chauhan
4c364635ed meson: Update glib version 2018-05-05 03:19:54 +05:30
Philip Withnall
0489f609ca gobject: Reimplement g_param_values_cmp() for GParamSpecVariant
The existing implementation was completely incorrect (despite the fix in
commit 566e64a66) — it always compared GVariants by pointer, rather than
by value.

Reimplement it to compare them by value where possible, depending on
their type. The core of this implementation is g_variant_compare(). See
the documentation and tests for further details of the new sort order.

This adds documentation and tests.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795735
2018-05-04 18:20:22 +01:00
Philip Withnall
69924c45b9 Revert "Fix the cmp implementation for variant values"
This reverts commit 623f92ed2df41265c11c3ca1e03176033045d4de.

This fix went from one broken state to another. The real fix is to use
g_variant_compare(), which is pending review. See bug #795735.

https://bugzilla.gnome.org/show_bug.cgi?id=795735
2018-05-04 17:24:31 +01:00
Iñigo Martínez
cd1f82d8fc gdbus-codegen: Fix header include in the body file
When body file is generated, the header name to be included is
built by using the path passed by `--output` directory. However,
this might not be correct because, if the path includes a
subdirectory, the whole path will be used instead of only the
base name.

Please see:
  https://github.com/mesonbuild/meson/issues/3488
  https://github.com/gnome-mpv/gnome-mpv/issues/305#issuecomment-385056156

https://bugzilla.gnome.org/show_bug.cgi?id=795802
2018-05-04 17:17:38 +01:00
Matthias Clasen
623f92ed2d Fix the cmp implementation for variant values
This was causing g_param_value_defaults to return 1
for GVariant values even when the value is clearly
different from the default.

This was showing up as gtk-builder-tool stripping
non-default values for GtkActionable::action-target
from ui files.
2018-05-02 08:29:31 -04:00
Christoph Reiter
7132abe1e6 ci: update meson
Rebuild the fedora docker image to get the newest meson release.

(Backport 2.56: Tweaked by Philip Withnall <withnall@endlessm.com> to
drop MSYS2 changes.)

https://bugzilla.gnome.org/show_bug.cgi?id=795711
2018-05-02 11:11:45 +01:00
Philip Withnall
c96e45496c gutils: Fix deadlock if g_get_home_dir() fails when called twice
If g_get_home_dir() calculated a NULL home directory (due to $HOME being
unset and /etc/passwd being inaccessible, for example due to an
overly-zealous LSM), it would call g_once_init_leave (&home_dir, NULL),
which would emit a critical and fail to leave the GOnce critical
section. That meant that the following call to g_get_home_dir() would
deadlock in g_once_init_enter().

Fix that by setting the home directory to a made-up value in such cases
(which the documentation handily already explicitly allows).

Thanks to Simon McVittie for the analysis leading to an easy patch.

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

https://bugzilla.gnome.org/show_bug.cgi?id=773435
2018-04-26 15:24:26 +01:00
Philip Withnall
fea050d9d5 tests: Drop a slightly suspect GResolver test
This test will only work on machines which have IPv6 enabled and have a
local IPv6 interface with ID 1. On machines which don’t (such as AWS
servers, which we run CI tests on), the GResolver tests will fail with
G_RESOLVER_ERROR_INVALID. We can’t differentiate this kind of failure
(where we’d want to skip the test) from an actual failure (where we’d
want to fail the test), so the only other option is to drop this
particular test vector. I don’t think it’s a significant loss.

This is the last fix needed to get our CI tests working reliably on
jenkins.gnome.org.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795234
2018-04-26 09:55:14 +01:00
Philip Withnall
89463e0c53 tests: Skip GSocket tests if setting up a server fails
There are various reasons why setting up a server might fail; it
reliably fails on AWS with IPv6 addresses (are we binding to the right
address?). Since we’re trying to test GSocket as a client, skip tests
where that happens.

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

https://bugzilla.gnome.org/show_bug.cgi?id=795234
2018-04-26 09:55:06 +01:00
Xavier Claessens
51792786e6 Fix build when pthread_getname_np is not available
On Android _setname_ is always available but _getname_ is available only
with API level >= 26.

https://bugzilla.gnome.org/show_bug.cgi?id=795406
2018-04-25 13:58:23 -04:00
Xavier Claessens
297e9debe3 Meson: Add missing link on libintl in tests
This fix undefined symbol link error when building for non-glibc
platform. Applications must link on libintl, it is not a public
dependency of libglib.

On glibc platforms libintl is a not found dependency and is just ignored
by meson, so it doesn't hurt to always have it.

https://bugzilla.gnome.org/show_bug.cgi?id=795406
2018-04-25 13:58:23 -04:00
Xavier Claessens
7ca9a04e82 struct ip_mreq_source definition is broken on Android NDK <= r16
This fix the build on Android r16 and older, see:
https://issuetracker.google.com/issues/36987220

https://bugzilla.gnome.org/show_bug.cgi?id=740791
2018-04-24 15:49:29 -04:00
Xavier Claessens
b757036b3f Tests: gsubprocess: Do not use stdin/stdout variables
https://bugzilla.gnome.org/show_bug.cgi?id=795406
2018-04-24 15:48:40 -04:00
Kentaro Hayashi
926a5c5e53 gobject: Fix redundant warning message in glib-genmarshal
glib-genmarshal shows redundant "time" warning message against combination with --header and --body option.

Before:

  WARNING: Using --header and --body at the same time time is deprecated; use --body --prototypes instead

After:

  WARNING: Using --header and --body at the same time is deprecated; use --body --prototypes instead

https://bugzilla.gnome.org/show_bug.cgi?id=795429
Signed-off-by: Kentaro Hayashi <hayashi@clear-code.com>
2018-04-23 16:26:00 +01:00
Stas Solovey
3975d54bca Update Russian translation 2018-04-20 20:48:36 +00:00
Fabrice Fontaine
8de72c56a0 gobject: fix compilation with gcc <= 4.7
On gcc 4.7, we got the following error:

i686-nptl-linux-gnu-gcc --version
> i686-nptl-linux-gnu-gcc (crosstool-NG 1.20.0) 4.7.4
> $ echo '#include <glib-object.h>' | i686-nptl-linux-gnu-gcc -x c -I
staging/usr/include/glib-2.0 -I staging/usr/lib/glib-2.0/include -Wall
-Werror -c - -o /tmp/foo.o
> In file included from
staging/usr/include/glib-2.0/gobject/gbinding.h:29:0,
>                  from staging/usr/include/glib-2.0/glib-object.h:23,
>                  from <stdin>:1:
> staging/usr/include/glib-2.0/gobject/gobject.h: In function
'g_set_object':
> staging/usr/include/glib-2.0/gobject/gobject.h:725:5: error: value
computed is not used [-Werror=unused-value]
> cc1: all warnings being treated as errors

This error has been added by commit 3fae39a5d742afe73741f5fd7aa24e3ae8182f06
So enable the new g_set_object definition only if gcc >= 4.8

Fixes:
 - http://autobuild.buildroot.net/results/b29a2f868438a2210873ea72f491db63175848be

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=795138
2018-04-20 11:32:37 +01:00
Philip Withnall
d060ab922e tests: Fix a minor memory leak in the GFileMonitor tests
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=755721
2018-04-18 15:37:33 +01:00
Philip Withnall
21d761b4e2 tests: Add a GFileMonitor test for G_FILE_MONITOR_WATCH_HARD_LINKS
Add a test for monitoring an existing local file, with the
WATCH_HARD_LINKS flag specified. This would previously cause a crash;
now it doesn’t.

This test contains a FIXME where I suspect we should be getting some
additional file change notifications from changes made through the hard
link; this requires further follow up and probably further fixes to our
inotify backend.

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

https://bugzilla.gnome.org/show_bug.cgi?id=755721
2018-04-18 15:37:33 +01:00
Philip Withnall
b326c23d63 inotify: Further fixes for hard link monitoring support
This gets the G_FILE_MONITOR_WATCH_HARD_LINKS flag to the state where it
doesn’t cause crashes, and essentially acts as a no-op. It will not yet
actually monitor for changes made via hard links.

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

https://bugzilla.gnome.org/show_bug.cgi?id=755721
2018-04-18 15:37:33 +01:00
Ryan Lortie
3f66ab2ede inotify: fix segfault on watching hard links
The call to _start() fills in the dirname, basename, and filename
arguments according to the following rules:

  dir watches: dirname filled

  file watches: dirname and basename filled

  hardlink: filename filled

This doesn't map to how the current inotify backend works very nicely,
so we need to adjust things a bit when creating our "sub" objects.

https://bugzilla.gnome.org/show_bug.cgi?id=755721
2018-04-18 15:37:33 +01:00