24915 Commits

Author SHA1 Message Date
Michael Catanzaro
f8b7a0e802 Merge branch 'backport-2808-socket-cancellable-glib-2-72' into 'glib-2-72'
Backport !2808 “gsocketclient: Fix passing NULL to g_task_get_cancellable()” to glib-2-72

See merge request GNOME/glib!2810
2022-07-12 16:10:00 +00:00
Philip Withnall
99783e0408 gsocketclient: Fix passing NULL to g_task_get_cancellable()
Fix a regression from commit abddb42d14, where it could pass `NULL` to
`g_task_get_cancellable()`, triggering a critical warning. This could
happen because the lifetime of `data->task` is not as long as the
lifetime of the `ConnectionAttempt`, but the code assumed it was.

Fix the problem by keeping a strong ref to that `GCancellable` around
until the `ConnectionAttempt` is finished being destroyed.

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

Fixes: #2687
2022-07-12 16:43:48 +01:00
Мирослав Николић
776719234a Update Serbian translation 2022-07-03 01:58:23 +00:00
Philip Withnall
dce30492f6 2.72.3
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2.72.3
2022-06-30 15:15:17 +01:00
Michael Catanzaro
436e5a6041 Merge branch 'backport-2742-proxy-fix-glib-2-72' into 'glib-2-72'
Backport !2742 “proxyaddressenumerator: set error parameter more thoughtfully” to glib-2-72

See merge request GNOME/glib!2787
2022-06-28 15:35:42 +00:00
Michael Catanzaro
dbe5359084 proxyaddressenumerator: set error parameter more thoughtfully
It doesn't make sense for a proxy resolver to return NULL without an
error on the first call. Whereas a DNS resolver would do this to
indicate that a query completed successfully but found no results, a
proxy resolver should return "direct://" instead. Therefore, if we are
going to return NULL, we ought to have an error as well. Let's make sure
this actually happens by adding some fallback errors just in case
GProxyResolver feeds us weird results.

Additionally, we should not return any errors except
G_IO_ERROR_CANCELLED after the very first iteration. This is an API
contract of GSocketAddressEnumerator. Let's add some checks to ensure
this.

Note that we have inadequate test coverage for GProxyAddressEnumerator.
It's tested here only via GSocketClient. We could do a bit better by
testing it directly as well. For example, I've added tests to see what
happens when GProxyResolver returns both a valid and an invalid URI, but
it's not so interesting here because GSocketClient always uses the valid
result and ignores the error from GProxyAddressEnumerator.

(Backport to 2.72: Dropped new translatable strings in error messages to
avoid additional translation work on a stable branch. The error messages
are unlikely to be seen by users.)

Fixes #2597
2022-06-28 11:38:29 +01:00
Michael Catanzaro
e80a5a75e2 Merge branch 'backport-2745-socketclient-cancellable-glib-2-72' into 'glib-2-72'
Backport !2745 “gsocketclient: Fix still-reachable references to cancellables” to glib-2-72

See merge request GNOME/glib!2750
2022-06-14 19:24:56 +00:00
Philip Withnall
abddb42d14 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 18:48:48 +01:00
Michael Catanzaro
55828ce5bf Merge branch 'backport-2708-xdgmime-fix-glib-2-72' into 'glib-2-72'
Backport !2708 “xdgmime: Fix broken file:// content type lookups for webkitgtk” to glib-2-72

See merge request GNOME/glib!2720
2022-06-06 14:34:00 +00:00
Philip Withnall
3c946645ff xdgmime: Fix broken file:// content type lookups for webkitgtk
This re-applies a chunk from commit e63262d49d40a36060 which was
accidentally lost when upstreaming the commit to xdgmime (as
https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/10).

The upstreamed commit was then re-backported to GLib as a1bfe899abe,
without the missing chunk.

The missing chunk is potentially causing incorrect content type results
for `file://` URIs when used from webkitgtk.

Thanks to Stephen Jung and Michael Catanzaro for investigating.

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

Fixes: #2639
2022-06-06 14:56:48 +01:00
Simon McVittie
7b9f6755b9 Merge branch 'backport-2561-file-monitor-deadlock-glib-2-72' into 'glib-2-72'
glocalfilemonitor: Avoid file monitor destruction from event thread

See merge request GNOME/glib!2703
2022-06-01 17:33:10 +00:00
Simon McVittie
cc2dc12d0e Merge branch 'wip/pwithnall/backport-2707-macos-local-peerpid-fix-glib-2-72' into 'glib-2-72'
Backport !2707 “credentials: macos: check for existence of LOCAL_PEERPID” to glib-2-72

See merge request GNOME/glib!2709
2022-06-01 17:25:06 +00:00
Christopher Nielsen
e4271674cc credentials: macos: check for existence of LOCAL_PEERPID
- Fixes build errors for macOS 10.7 and earlier, where this is not supported
2022-06-01 14:12:17 +01:00
Philip Withnall
1fc6a5c9b6 tests: Add a test for GFileMonitor deadlocks
This test is opportunistic in that it’s not possible to detect whether
the race condition has been hit (other than by hitting a deadlock).

So the only approach we can take for testing is to loop over the code
which has previously been known to cause a deadlock a number of times.

The number of repetitions is chosen from running the test with the
deadlock fix reverted.

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

Helps: #1941
2022-05-31 13:22:02 +01:00
Philip Withnall
57bde3c9bd glocalfilemonitor: Skip event handling if the source has been destroyed
This should prevent unbounded growth of the `event_queue` in the
unlikely case that the `GSource` is removed from its `GMainContext` and
destroyed separately from the `GFileMonitor`.

I’m not sure if that can currently happen, but it could with future
refactoring, so it’s best to address the possibility now while we’re
thinking about this bit of code.

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

Helps: #1941
2022-05-31 13:22:02 +01:00
Benjamin Berg
222f6ceada glocalfilemonitor: Avoid file monitor destruction from event thread
Taking a reference to the GFileMonitor when handling events may cause
object destruction from th worker thread that calls the function. This
condition happens if the surrounding code drops the otherwise last
reference ot the GFileMonitor. The series of events causes destruction
from an unrelated worker thread and also triggers g_file_monitor_cancel
to be called from g_file_monitor_source_handle_event.

For the inotify backend, this results in a deadlock as cancellation
needs to take a lock that protects data structures from being modified
while events are dispatched.

One alternative to this approach might be to add an RCU (release, copy,
update) approach to the lists contained in the wd_dir_hash and
wd_file_hash hash tables.

Fixes: #1941

An example stack trace of this happening is:

Thread 2 (Thread 0x7fea68b1d640 (LWP 260961) "gmain"):
 #0  syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
 #1  0x00007fea692215dc in g_mutex_lock_slowpath (mutex=mutex@entry=0x7fea6911e148 <g.inotify_lock_lock>) at ../glib/gthread-posix.c:1493
 #2  0x00007fea69222062 in g_mutex_lock (mutex=mutex@entry=0x7fea6911e148 <g.inotify_lock_lock>) at ../glib/gthread-posix.c:1517
 #3  0x00007fea6908025a in _ih_sub_cancel (sub=0x1492620) at ../gio/inotify/inotify-helper.c:131
 #4  0x00007fea6907f9da in g_inotify_file_monitor_cancel (monitor=0x14a3550) at ../gio/inotify/ginotifyfilemonitor.c:75
 #5  0x00007fea68fae959 in g_file_monitor_cancel (monitor=0x14a3550) at ../gio/gfilemonitor.c:241
 #6  0x00007fea68fae9dc in g_file_monitor_dispose (object=0x14a3550) at ../gio/gfilemonitor.c:123
 #7  0x00007fea69139341 in g_object_unref (_object=<optimized out>) at ../gobject/gobject.c:3636
 #8  g_object_unref (_object=0x14a3550) at ../gobject/gobject.c:3553
 #9  0x00007fea6907507a in g_file_monitor_source_handle_event (fms=0x14c3560, event_type=<optimized out>, child=0x7fea64001460 "spawned-1", rename_to=rename_to@entry=0x0, other=other@entry=0x0, event_time=<optimized out>) at ../gio/glocalfilemonitor.c:457
 #10 0x00007fea6907fe0e in ih_event_callback (event=0x7fea64001420, sub=0x1492620, file_event=<optimized out>) at ../gio/inotify/inotify-helper.c:218
 #11 0x00007fea6908075c in ip_event_dispatch (dir_list=dir_list@entry=0x14c14c0, file_list=0x0, event=event@entry=0x7fea64001420) at ../gio/inotify/inotify-path.c:493
 #12 0x00007fea6908094e in ip_event_dispatch (event=0x7fea64001420, file_list=<optimized out>, dir_list=0x14c14c0) at ../gio/inotify/inotify-path.c:448
 #13 ip_event_callback (event=0x7fea64001420) at ../gio/inotify/inotify-path.c:548
 #14 ip_event_callback (event=0x7fea64001420) at ../gio/inotify/inotify-path.c:530
 #15 0x00007fea69081391 in ik_source_dispatch (source=0x14a2bf0, func=0x7fea69080890 <ip_event_callback>, user_data=<optimized out>) at ../gio/inotify/inotify-kernel.c:327
 #16 0x00007fea691d0824 in g_main_dispatch (context=0x14a2cc0) at ../glib/gmain.c:3417
 #17 g_main_context_dispatch (context=0x14a2cc0) at ../glib/gmain.c:4135
 #18 0x00007fea691d0b88 in g_main_context_iterate (context=context@entry=0x14a2cc0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4211
 #19 0x00007fea691d0c2f in g_main_context_iteration (context=0x14a2cc0, may_block=may_block@entry=1) at ../glib/gmain.c:4276
 #20 0x00007fea691d0c81 in glib_worker_main (data=<optimized out>) at ../glib/gmain.c:6176
 #21 0x00007fea691f9c2d in g_thread_proxy (data=0x1487cc0) at ../glib/gthread.c:827
 #22 0x00007fea68d93b1a in start_thread (arg=<optimized out>) at pthread_create.c:443
 #23 0x00007fea68e18650 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
2022-05-31 13:22:02 +01:00
Philip Withnall
a2e950a021 2.72.2
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2.72.2
2022-05-30 14:26:47 +01:00
Philip Withnall
60bd2510f2 Merge branch 'backport-2661-uwp-warnings-glib-2-72' into 'glib-2-72'
Backport !2661 “win32appinfo: change log level from warning to debug” to glib-2-72

See merge request GNOME/glib!2691
2022-05-30 12:52:54 +00:00
Ignacio Casal Quinteiro
57739ebd5f win32appinfo: change log level from warning to debug
There is nothing that the user can do anyway and this dumps
lots of warnings without real need.

Closes #2640
2022-05-26 15:30:41 +01:00
Christian Kirbach
92177755ed Update German translation 2022-05-22 21:49:55 +00:00
Charles Monzat
4d6e03745e Update French translation 2022-05-22 08:33:07 +00:00
Philip Withnall
7aef380e6f Merge branch 'backport-2654-task-alloc-performance-glib-2-72' into 'glib-2-72'
Backport !2654 “gtask: use g_strconcat() in g_task_return() only if needed” to glib-2-72

See merge request GNOME/glib!2662
2022-05-18 14:09:00 +00:00
Ignacio Casal Quinteiro
7b140e1909 gtask: use g_strconcat() in g_task_return() only if needed
If the task name is NULL there is no need to allocate the string
since this can be expensive if called very often
2022-05-17 14:18:46 +01:00
Pawan Chitrakar
f48e0a91a5 Update Nepali translation 2022-05-11 07:32:36 +00:00
Pawan Chitrakar
37f6bc6114 Update Nepali translation 2022-05-10 09:37:56 +00:00
Sebastian Dröge
3d7d06a4a8 Merge branch 'backport-2642-meson-undefined-glib-2-72' into 'glib-2-72'
Backport !2642 “meson: Check rres.compiled() before calling rres.returncode()” to glib-2-72

See merge request GNOME/glib!2643
2022-05-10 09:00:34 +00:00
Sebastian Dröge
3370232419 Merge branch 'backport-2631-ptrdiff-glib-2-72' into 'glib-2-72'
Backport !2631 “Cast to guintptr instead of subtracting by null” to glib-2-72

See merge request GNOME/glib!2644
2022-05-10 09:00:31 +00:00
TestingPlant
c1683b0468 Cast to guintptr instead of subtracting by null
Subtraction by a null pointer is undefined behavior, so it's been
replaced with a cast to guintptr.
2022-05-09 13:22:28 +01:00
illiliti
e1f5b86fc2 meson: Check rres.compiled() before calling rres.returncode()
As per meson spec, returncode() produces unspecified data if
compiled() == false. Check compiled() first to avoid relying
upon unspecified data.

In addition, muon -- an implemetation of meson written in C goes
further and forbids returning unspecified data. This is a good
decision, but also makes it harder to support applications which
wrongly use meson API. Therefore, application needs to be fixed.
2022-05-09 13:16:29 +01:00
Sebastian Dröge
41594e97c5 Merge branch 'backport-2615-gio-pkgconfig-fix-glib-2-72' into 'glib-2-72'
Backport !2615 “Meson: Fix gio-windows-2.0 override name” to glib-2-72

See merge request GNOME/glib!2616
2022-04-29 08:02:37 +00:00
Sebastian Dröge
748090b0d9 Merge branch 'backport-2449-2600-mingw-test-fixes-glib-2-72' into 'glib-2-72'
Backport !2449 and !2600 mingw test fixes to glib-2-72

See merge request GNOME/glib!2605
2022-04-29 07:59:40 +00:00
Sebastian Dröge
210416bbc0 Merge branch 'backport-2626-2627-leak-fixes-glib-2-72' into 'glib-2-72'
Backport !2626, !2627 minor leak fixes to glib-2-72

See merge request GNOME/glib!2629
2022-04-29 07:58:19 +00:00
Philip Withnall
a31474e41d gopenuriportal: Fix a use-after-free on an error path
`path` was used in building the error message after it had been freed.
Spotted by scan-build.

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

Helps: #1767
2022-04-28 11:47:30 +01:00
Philip Withnall
d5386a5493 gio-tool: Fix a minor memory leak when using gio-set with bytestrings
Tested using:
```sh
touch ~/foo
gio set ~/foo -t bytestring user::test "\x00\x00"
```
(it doesn’t matter that this fails; the bytestring is still decoded)

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

Coverity CID: #1474407
2022-04-28 11:47:30 +01:00
Marc-André Lureau
25616eb7ee gio/tests: fix socket /socket/credentials/unix_socketpair on win32
When I enabled unix socketpair test on win32, I left the existing
g_close(fds[1]), but _g_win32_socketpair() returns native sockets
descriptors that must be closed with closesocket() on win32.

Let GSocket handle the socket pair cleanup.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-25 14:29:52 +01:00
Marc-André Lureau
1e5faeedd8 gio/tests: GStatBuf.st_size is 64 bits on win64
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-25 14:29:52 +01:00
Xavier Claessens
e7a6e91e02 Meson: Fix gio-windows-2.0 override name
The override name must match the pkgconfig name.
2022-04-25 11:33:45 +01:00
Bruce Cowan
82feda1ccf Update British English translation 2022-04-24 10:30:51 +00:00
Goran Vidović
c80dec72c0 Update Croatian translation 2022-04-20 17:44:55 +00:00
Fran Dieguez
77bf623bee Update Galician translation 2022-04-19 06:04:40 +00:00
Ask Hjorth Larsen
d57e17ce9d Updated Danish translation 2022-04-18 19:22:58 +02:00
Enrico Nicoletto
e8cd7d1918 Update Brazilian Portuguese translation 2022-04-15 16:56:16 +00:00
Marc-André Lureau
bda6992fb6 tests: fix protocol test on win32
The pipe must be closed, or the child PID watch doesn't get triggered.

We should remove the message callback source on EOF, as EOF during main
loop run will reach a bad assert in the callback.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2022-04-14 13:19:17 +01:00
Chun-wei Fan
ccc2a73e86 glib/tests/date.c: Fix 2-digit year test
...for certain Windows locales, since the formats accepted for
g_date_set_parse() will vary depending on the current system locale.  For
instance, g_date_set_parse(gdate, "dd/mm/yy") is accepted on locales such
as zh-HK (Chinese (Hong Kong SAR)) but is rejected on zh-TW (Chinese
(Taiwan)).

One can tell from the "date format" settings in the Windows system
control panel whether there is a "dd/MM/YYYY" or "dd/MM/YY" option from the
drop-down list of date formats to display for the locale, which will indicate
whether g_date_set_parse(gdate, "dd/mm/yy") is accepted, which is true for
zh-HK but is not true for zh-TW.

If g_date_set_parse(gdate, "dd/mm/yy") is not accepted, try again with
g_date_set_parse(gdate, "yy/mm/dd") thereafter for the 2-digit-year tests.
2022-04-14 13:18:36 +01:00
Chun-wei Fan
b47e7b3503 gdate.c: Use standard name if no daylight saving exists
We should normally have a standard name for the time zone even if we don't
have daylight saving in the time zone, so use the standard name also when
GetTimeZoneInformation() returns TIME_ZONE_ID_UNKNOWN[1][2].

[1]: https://docs.microsoft.com/en-us/windows/win32/api/timezoneapi/nf-timezoneapi-gettimezoneinformation
[2]: https://docs.microsoft.com/zh-tw/windows/win32/api/timezoneapi/nf-timezoneapi-settimezoneinformation
2022-04-14 13:18:36 +01:00
Philip Withnall
38d076a5fd 2.72.1
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2.72.1
2022-04-14 12:15:25 +01:00
Kukuh Syafaat
0587ef97fc Update Indonesian translation 2022-04-11 09:08:49 +00:00
Aleksandr Melman
4efe65117d Update Russian translation 2022-04-09 15:35:33 +00:00
Alexander Shopov
06a0c8abd9 Update Bulgarian translation 2022-04-09 07:56:28 +00:00
Sebastian Dröge
d30a726069 Merge branch 'wip/pwithnall/backport-2578-clang-cxx-glib-2-72' into 'glib-2-72'
Backport !2578 “gatomic: Add a C++ variant of g_atomic_int_compare_and_exchange()” to glib-2-72

See merge request GNOME/glib!2593
2022-04-06 13:29:21 +00:00