A context iteration we're doing lots of lock/unlocks and that's fine to give
other threads contexts a chance to run, but we're doing it also just to call
other functions that require locking, and this can be avoided.
Other threads can still have a chance to run while releasing the ownership
of the context.
In practice, this will never happen.
If `getcwd()` returns `ERANGE` whenever the working directory is ≥
`PATH_MAX`, though, the previous implementation of the loop would run
until `max_len == G_MAXULONG`, and would then overflow when adding `1`
to it for a nul terminator in the allocation.
Avoid that problem by always keeping `buffer_len` as a power of two, and
relying on `getcwd()` to write a nul terminator within the buffer space
it’s given. It seems to do this on all platforms we care about, because
the previous version of the code never explicitly wrote a nul terminator
anywhere.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Fixes: #98
Various projects are running tests under valgrind, and they are using
the GLib suppresions to avoid false-positive results.
While this is stored in a well-known path for some years, and easy to
figure out from the GLib prefix, it's better to expose it through a
proper pkgconfig variable so that it's easy to get it from any build
system.
We were working around that with a call to chdir("."). Internally chdir()
sets up cmd shell-related environment variables, but only if the current
working directory belongs to a volume with a drive letter. For example,
if the current working directory is on a UNC volume like a network share,
the call to chdir() won't help.
Reference:
https://developercommunity.visualstudio.com/t/UCRT-Crash-in-_wspawne-functions/10262748
Add three classes of test case for which g_utf8_normalize() should
safely return NULL:
- Strings ending with a truncated multibyte character which would
extend past the NUL terminator
- Strings ending with a multibyte character which extends past the
length limit provided by the max_len argument
- Strings containing an invalid multibyte character in any position
_g_utf8_normalize_wc() could read past the end of the provided buffer if
it ends with a truncated multibyte character. If max_len is -1, it can
continue reading until it encounters either a NUL or unreadable
memory. Avoid this with extra bounds checks prior to g_utf8_get_char()
to ensure that it does not read past either max_len or a NUL
terminator.
See issue GNOME/glib#2861. Even though (hopefully!) few people are
actually running kernels this old, some build frameworks use very old
kernel headers to try to maximize the portability of their binary
artifacts.
clang++ says it supports _Static_assert but then will
complain that it's a C11 extension and that you should not use
it in C++ code (which imho is fair enough)
So try to detect a C++ compiler first and then the C compiler,
similarly to what is done for the G_NORETURN case
Create the wakeup pipe using the `O_NONBLOCK` flag for `pipe2()`, where
possible.
This saves a couple of `fcntl()` syscalls every time a wakeup pipe is
created, which is at least once per `GMainContext`.
This uses the `O_NONBLOCK` support added to `g_unix_open_pipe()` in the
previous commit.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Add support for it, but don’t use it anywhere yet — this is an API
addition, but currently doesn’t cause any functional changes. It’ll be
used in the next commit.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
They just listed built files. Since the move to Meson, these are all
kept in a separate build directory, not the source tree, so don’t need
to be ignored.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This is a partial revert of commit f378352051.
The leak of a `GMainLoop` which prompted it has been fixed by commit
4f5da8338127e25e5ebb54f5a4a95ffc2e40adcc in merge request !2535.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
See: #2598Fixes: #2307
Unless `-m thorough` is passed to the tests, reduce the number of
iterations in the random test.
This one test case takes the bulk of the time to run the `queue` test
suite, and is sometimes causing timeouts when running on CI
(particularly under valgrind). Reduce it to a fifth.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This is put together through git archaeology:
```
git log glib/tests/queue.c
git log -- tests/queue-test.c
```
The following commits were too trivial to have meaningful copyright:
- 8f02fac4ad1e846f3075ae8b057b387e6365c0ca
- d81ac5339fcf9537a3731ebb5770238f4fa69d59
- 29f2ced8eb32d9001da8082c4530f017decb8267
- 1a2c5e155deacb7ebeb8d0ca2c800a97a90a7ab9
- 8a90f5e9f6da778743aaec365ee4ceb62b717130
- 45dae4b5063f9af7de8211ced95dd73cc770a86e
- 2aa71ab63b4457324c53700ab38ed83c3ccf7d5e
- 3a74ad128eb9a3431c54a88fa36269cb41e11c3e
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Helps: #1415