Commit Graph

31085 Commits

Author SHA1 Message Date
Philip Withnall
7dacfa7799 Merge branch 'wip/hadess/test-warning-fix' into 'main'
appmonitor: Fix warning building test

See merge request GNOME/glib!4395
2024-11-13 13:40:45 +00:00
Philip Withnall
91b2b659d3 Merge branch 'procfs' into 'main'
Replace procfs linuxism with kinfo freebsdism

See merge request GNOME/glib!4393
2024-11-13 13:29:01 +00:00
Gleb Popov
6d67568da3 Replace procfs linuxism with kinfo freebsdism 2024-11-13 13:29:01 +00:00
Bastien Nocera
48b980ca7d appmonitor: Fix warning building test
gio/tests/appmonitor.c: In function ‘timeout_cb’:
gio/tests/appmonitor.c:95:14: warning: null pointer dereference [-Wnull-dereference]
   95 |   *timed_out = TRUE;
2024-11-13 14:24:50 +01:00
Philip Withnall
6faed43505 Merge branch 'amolenaar/content-type-works' into 'main'
macos: content-type tests do succeed

Closes #1251

See merge request GNOME/glib!4390
2024-11-10 15:29:22 +00:00
Arjan Molenaar
6e4b70e062 macos: content-type tests should succeed 2024-11-09 13:42:47 +01:00
Philip Withnall
558cb16f19 Merge branch 'amolenaar/content-type' into 'main'
macos: Add extra content type tests

See merge request GNOME/glib!4389
2024-11-08 22:34:38 +00:00
Arjan Molenaar
bc8b7041a9 macos: Add extra content type tests 2024-11-08 22:34:38 +00:00
Philip Withnall
a162d7a9e9 Merge branch 'non-fatal-assertions-option' into 'main'
test utils: Make nonfatal assertions an option

See merge request GNOME/glib!4384
2024-11-08 15:26:48 +00:00
Matthias Clasen
2a15b2cc61 Add a test for nonfatal assertions
Testing this in a normal testcaes is a bit tricky, since
triggering a non-fatal assertion has the side-effect of
marking the test as failed.

So just don't run any testcases here, but check the side-effect
manually. Since we don't produce TAP output when not using
g_test_run(), tell meson that we're using the exitcode protocol.
2024-11-08 14:38:22 +00:00
Matthias Clasen
b161cb9252 Add macros for all g_test_init options
Add macros, and use them.
2024-11-08 14:38:22 +00:00
Philip Withnall
2ecb445537 Merge branch 'refstring-intern-release-race' into 'main'
refstring: Fix race between releasing and re-acquiring an interned GRefString

See merge request GNOME/glib!4232
2024-11-08 12:31:40 +00:00
Sebastian Dröge
1c78ed95d4 refstring: Fix race between releasing and re-acquiring an interned GRefString
There is a race between releasing and re-acquiring an interned
GRefString if this happens on two threads at the same time. This can
result in already freed memory to be returned from
g_ref_string_new_intern().

| Thread 1                       | Thread 2                      |
| ------------------------------ | ----------------------------- |
| g_ref_string_release()         | g_ref_string_new_intern()     |
| g_atomic_rc_box_release_full() | g_mutex_lock()                |
|                                | g_hash_table_lookup()         |
| remove_if_interned()           | g_ref_string_acquire()        |
| g_mutex_lock()                 | g_mutex_unlock()              |
| g_hash_table_remove()          |                               |
| g_mutex_unlock()               |                               |
| g_free()                       |                               |
|                                | return res; // this is freed  |

This use-after-free usually also gives a critical warning because
g_atomic_ref_count_inc() checks for the refcount having been 0
before incrementing.

It is not possible to safely implement weak references via garcbox.

To avoid this race do not implement weak references via garcbox but
instead implement the allocation of the string manually with a manually
managed reference count. This allows to safely resurrect the interned
string if the above race happens, and also avoids other races.

As a side-effect this also

  * reduces the allocation size in addition to the actual string length
    from 32 bytes to 16 bytes on 64 bit platforms and keeps it at 16 bytes
    on 32 bit platforms,

  * doesn't lock a mutex when freeing non-interned GRefStrings.
2024-11-08 13:44:41 +02:00
Sebastian Dröge
dc197cd7f3 arcbox: Document that implementing weak references via the clear_func is not safe 2024-11-08 10:28:07 +02:00
Matthias Clasen
90f4e562be test utils: Make nonfatal assertions an option
We have a mechanism for turning on optional features of the GLib
test harness by passing options to g_test_init(). Use it for the
non-fatal assertions as well.
2024-11-07 11:10:40 -05:00
Philip Withnall
536dfca9be Merge branch '3524-missing-annotations' into 'main'
Add missing `(array zero-terminated=1)` annotations

Closes #3524

See merge request GNOME/glib!4386
2024-11-07 11:38:58 +00:00
Philip Withnall
04f6d555b0 Merge branch 'cm/no-sanitize-load-word' into 'main'
gutf8: Skip ASan instrumentation for load_word

See merge request GNOME/glib!4385
2024-11-07 11:38:25 +00:00
Jan-Willem Harmannij
80ba36e095 Add missing (array zero-terminated=1) annotations
Array annotations were missing on `g_enum_register_static` and
`g_flags_register_static`.

Fixes #3524
2024-11-06 22:26:06 +01:00
correctmost
5641770743 gutf8: Skip ASan instrumentation for load_word
load_word has a known out-of-bounds read that is explained in
commit ec7cf334db.

Helps: #3493
2024-11-06 12:13:06 -05:00
Philip Withnall
a429e56523
2.83.0
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-11-06 14:20:19 +00:00
Philip Withnall
dbb42933f8 Merge branch 'faccessat-bsd' into 'main'
glocalfile: Disable faccessat()-based query_exists on FreeBSD

See merge request GNOME/glib!4366
2024-11-06 13:13:01 +00:00
Philip Withnall
7868e6dd33 Merge branch 'on-error-stack' into 'main'
Small improvements to g_on_error_stack_trace and g_on_error_query

See merge request GNOME/glib!4375
2024-11-06 12:30:09 +00:00
Philip Withnall
8e46f31a23 Merge branch 'thread-name-length' into 'main'
thread: Force-limit thread name length

See merge request GNOME/glib!4374
2024-11-06 12:15:56 +00:00
Matthias Clasen
904be498c5 Small improvements to g_on_error_query
We can do the [S] option even if g_prgname isn't set, now that
g_on_error_stack_trace(NULL) works.
2024-11-06 11:46:53 +00:00
Matthias Clasen
f6e71c25ed Small improvements to g_on_error_stack_trace
Make the gdb commands match what /usr/bin/gstack uses,
and produce a stacktrace including all threads.
2024-11-06 11:46:53 +00:00
Matthias Clasen
95cdd0f06f Small improvements to g_on_error_stack_trace
Make g_on_error_stack_trace (NULL) work by using /proc/$PID/exe.

This matches what /usr/bin/gstack does.
2024-11-06 11:46:53 +00:00
Matthias Clasen
5b84636e62 thread: Force-limit thread name length
The documentation for glibc's pthread_setname_np states:

    The thread name is a meaningful C language string,
    whose length is restricted to 16 characters,
    including the  terminating  null  byte  ('\0').

The documentation for Solaris' pthread_setname_np states:

    The thread name is a string of length 31 bytes or less,
    UTF-8 encoded.

Failing to respect this length limitation may lead to no name being
set, which is confusing, since the thread then shows up under the
binary name in gdb. This was happening for the pango worker thread
with the name "[pango] fontconfig".
2024-11-06 11:44:49 +00:00
Philip Withnall
9949067a69 Merge branch 'fix-gtask-auto-set-name-doc' into 'main'
gtask: Fix comment for auto task naming via 'g_task_set_source_tag()'

See merge request GNOME/glib!4383
2024-11-06 11:34:09 +00:00
Sid
9e29968183 gtask: Fix comment for auto task naming via 'g_task_set_source_tag()' 2024-11-06 11:34:09 +00:00
Philip Withnall
705832f269 Merge branch 'amolenaar/fix-content-typo' into 'main'
macos: Remove extraneous space from type identifier

See merge request GNOME/glib!4373
2024-11-04 17:02:22 +00:00
Arjan Molenaar
6cb13b153c macos: Remove extraous space from type identifier 2024-11-04 16:31:36 +00:00
Emmanuele Bassi
7abfef8e06 Merge branch 'wip/pwithnall/fix-unix-mounts-tests-deprecations' into 'main'
tests: Fix calls to deprecated API in unix-mounts tests

See merge request GNOME/glib!4367
2024-11-04 16:27:12 +00:00
Philip Withnall
a33f26ff58 Merge branch 'wip/gvariant-builder-init-unset' into 'main'
gvariant: Introduce G_VARIANT_BUILDER_INIT_UNSET

See merge request GNOME/glib!4377
2024-11-04 16:11:52 +00:00
Sebastian Wick
3f71e403ed gvariant: Introduce G_VARIANT_BUILDER_INIT_UNSET
For g_auto(GVariantBuilder) one needs to initialize it before the
function returns, so it's best to do it when the variable is declared.
G_VARIANT_BUILDER_INIT exists but requires specifying a GVariantType in
the declaration which moves the type away from the usage of the builder
which often results in less readable code. G_VARIANT_BUILDER_INIT also
mentions that it's possible to explicitly zero the variable but this is
hard to find and writing `g_auto(GVariantBuilder) builder = {0,};` is
kind of ugly.

This introduces G_VARIANT_BUILDER_INIT_UNSET which zero initializes the
variable being declared. This gives us documentation and hides the
explicitly zeroing detail:

  auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT_UNSET ();
2024-11-04 16:43:42 +01:00
Sebastian Wick
b10a4507a5 gvariant: Use gi-docgen for the G_VARIANT_BUILDER_INIT documentation 2024-11-04 16:38:05 +01:00
Michael Catanzaro
155810edd9 Merge branch 'cm/fix-gio-tools-leaks' into 'main'
gio: Fix GFileEnumerator leaks in gio tools

See merge request GNOME/glib!4378
2024-11-04 15:29:34 +00:00
correctmost
5b2da7ecb3 gio: Fix GFileEnumerator leaks in gio tools 2024-11-03 12:22:01 -05:00
Michael Catanzaro
3dcf1ea13d Merge branch 'nm-nl' into 'main'
Enable GNetworkMonitorNetlink on FreeBSD

See merge request GNOME/glib!4376
2024-10-29 19:26:59 +00:00
Gleb Popov
02172bda73 Enable GNetworkMonitorNetlink on FreeBSD 2024-10-29 21:18:36 +03:00
Philip Withnall
0828714bd4 Merge branch 'structured-logging-domain-check-without-nul' into 'main'
glib: Don't require GLIB_DOMAIN to be a NUL-terminated string

See merge request GNOME/glib!4350
2024-10-24 20:41:32 +00:00
Philip Withnall
b0943a70e7 Merge branch 'issue_3512' into 'main'
glib/glib-private: Build glib without ASAN sanitizer on AIX.

Closes #3512

See merge request GNOME/glib!4368
2024-10-24 20:21:45 +00:00
Parth Patel
929114fad2 glib/glib-private: Build glib without ASAN sanitizer on AIX.
In AIX, we doesn't have lsan sysmbols related to sanitizer.
So, skipping this check in AIX to build glib without ASAN sanitizer.

Issue: https://gitlab.gnome.org/GNOME/glib/-/issues/3512
2024-10-23 11:10:32 -05:00
Philip Withnall
4c3f06acbf Merge branch 'str-is-ascii-ifunc' into 'main'
gutf8: Add ifunc resolver for g_str_is_ascii() too

Closes #3511

See merge request GNOME/glib!4364
2024-10-22 17:37:32 +00:00
Sebastian Dröge
99bf0c966a glib: Add test for handling of non-NUL terminated strings in default log handler 2024-10-22 19:08:25 +03:00
Sebastian Dröge
9719853507 glib: Make sure GLIB_OLD_LOG_API is a NUL-terminated string
Every usage in GLib ensures this but theoretically external code might
pass something else. As this is only meant to be used internally from
GLib, don't support the other case but at least avoid potential out of
bound reads.
2024-10-22 19:08:25 +03:00
Sebastian Dröge
f221864d6e glib: Don't require GLIB_DOMAIN to be a NUL-terminated string
The length might be passed explicitly in the field instead, and the
string might not have a NUL-terminator as happens for example when
passed from the Rust bindings.

This might lead to out of bounds reads.

Thanks to Sebastian Wiesner for noticing this.
2024-10-22 19:08:25 +03:00
Michael Catanzaro
2c345bd8e2 Merge branch 'fuzz-fix' into 'main'
fuzzing: Fix buffer overread error in the fuzz test itself

See merge request GNOME/glib!4365
2024-10-22 16:00:36 +00:00
Michael Catanzaro
155d00a61e Merge branch '3470-unicode-16' into 'main'
Update to Unicode 16.0.0 and fix Unicode composition for its new codepoints

Closes #3470

See merge request GNOME/glib!4362
2024-10-22 15:29:42 +00:00
Philip Withnall
c14810e08f
tests: Fix calls to deprecated API in unix-mounts tests
This fixes commit aac56f1618 — I missed
this while reviewing it, but the unit tests were partially changed to
call the new APIs, without being fully changed. This caused the build to
succeed on Linux, but fail on macOS due to using a deprecated API.

Actually, a better approach for the unit tests would be to consistently
call the *old* APIs, as they all immediately call the new APIs. Then we
get coverage of both old and new for free, at the cost of putting
`G_GNUC_BEGIN_IGNORE_DEPRECATIONS` at the top of the test file.

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

Helps: #3492
2024-10-22 16:15:18 +01:00
Philip Withnall
e795c715b5 Merge branch 'fix-namespace-UnixMountEntry' into 'main'
UnixMountEntry: Deprecate g_unix_mount_* API in favor of g_unix_mount_entry_* API for GUnixMountEntry methods

Closes #3492

See merge request GNOME/glib!4337
2024-10-22 14:48:12 +00:00