Azat Khuzhin [Sat, 9 Jul 2022 17:28:18 +0000 (20:28 +0300)]
configure: fix AC_CHECK_FUNCS should use literals
Error
configure.ac:291: warning: AC_CHECK_FUNCS(getnameinfo
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
configure.ac:291: warning: AC_CHECK_FUNCS(getprotobynumber
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
configure.ac:291: warning: AC_CHECK_FUNCS(getservbyname
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
configure.ac:291: warning: AC_CHECK_FUNCS(inet_ntop
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
configure.ac:291: warning: AC_CHECK_FUNCS(inet_pton
): you should use literals
../autoconf-2.71/lib/autoconf/functions.m4:117: AC_CHECK_FUNCS is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:692: _AS_IF_ELSE is expanded from...
../autoconf-2.71/lib/m4sugar/m4sh.m4:699: AS_IF is expanded from...
configure.ac:291: the top level
listener: Preserve last error in evconnlistener_new_bind() before close
In function evconnlistener_new_bind() after go to "err:", The
evutil_closesocket() would clear the error code( I found this under
Windows ). User can not use EVUTIL_SOCKET_ERROR() to get the
evconnlistener_new_bind()'s failing error.
I add a err_code variable to store and restore the last error code.
Azat Khuzhin [Sat, 9 Jul 2022 15:12:07 +0000 (18:12 +0300)]
Merge branch 'Werror'
* Werror:
test: ignore -Walloc-size-larger-than error for calloc() returns ENOMEM
Fix EVBASE_ACQUIRE_LOCK/EVBASE_RELEASE_LOCK for EVENT__DISABLE_THREAD_SUPPORT
http: suppress "flags may be used uninitialized in this function" error
Detech -Wno-unused-functions for GCC too
cmake: add compiler version to the status message
Fix BEV_LOCK/BEV_UNLOCK macros for EVENT__DISABLE_THREAD_SUPPORT
Run builds with -Werror on CI for linux
Fix -Werror for autotools
Add -Wundef for cmake and fix EVENT__SIZEOF_TIME_T usage
Azat Khuzhin [Sat, 9 Jul 2022 14:14:12 +0000 (17:14 +0300)]
test: ignore -Walloc-size-larger-than error for calloc() returns ENOMEM
Compiler report:
/home/runner/work/libevent/libevent/test/regress_util.c: In function ‘test_event_calloc’:
/home/runner/work/libevent/libevent/test/regress_util.c:1318:4: error: argument 2 value ‘9223372036854775815’ exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
p = mm_calloc(EV_SIZE_MAX/2, EV_SIZE_MAX/2 + 8);
In file included from /home/runner/work/libevent/libevent/test/../util-internal.h:37:0,
from /home/runner/work/libevent/libevent/test/regress_util.c:30:
/usr/include/stdlib.h:541:14: note: in a call to allocation function ‘calloc’ declared here
extern void *calloc (size_t __nmemb, size_t __size)
Azat Khuzhin [Sat, 9 Jul 2022 14:17:38 +0000 (17:17 +0300)]
http: suppress "flags may be used uninitialized in this function" error
Some GCC reports [1]:
/home/runner/work/libevent/libevent/http.c: In function ‘evhttp_make_header’:
/home/runner/work/libevent/libevent/http.c:503:14: error: ‘flags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
ev_uint16_t flags;
^~~~~
/home/runner/work/libevent/libevent/http.c: In function ‘evhttp_get_body’:
/home/runner/work/libevent/libevent/http.c:2354:14: error: ‘flags’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
ev_uint16_t flags;
^~~~~
[1]: https://github.com/libevent/libevent/runs/7263518338?check_suite_focus=true#logs
Azat Khuzhin [Sat, 9 Jul 2022 14:08:21 +0000 (17:08 +0300)]
Detech -Wno-unused-functions for GCC too
Otherwise build fails [1]:
/home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/minheap-internal.h:64:6: error: ‘min_heap_ctor_’ defined but not used [-Werror=unused-function]
void min_heap_ctor_(min_heap_t* s) { s->p = 0; s->n = 0; s->a = 0; }
^~~~~~~~~~~~~~
In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:91:0:
/home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/bufferevent-internal.h:414:1: error: ‘bufferevent_trigger_nolock_’ defined but not used [-Werror=unused-function]
bufferevent_trigger_nolock_(struct bufferevent *bufev, short iotype, int options)
^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/buffer.c:89:0:
/home/runner/work/libevent/libevent/dist/libevent-2.2.0-alpha-dev/evthread-internal.h:140:1: error: ‘EVLOCK_TRY_LOCK_’ defined but not used [-Werror=unused-function]
EVLOCK_TRY_LOCK_(void *lock)
Azat Khuzhin [Sat, 9 Jul 2022 10:35:54 +0000 (13:35 +0300)]
Fix some OpenSSL 3 test issues (#1291)
These are updates to help with OpenSSL 3 compilation. I found
https://github.com/libevent/libevent/pull/1288 after I started this, but
these seem independent, and fix a different set of problems:
- First off, OpenSSL 3 does not by default allow signing with SHA1
digests - moving this to SHA256 universally at this point seems a
better idea than continuing to use the insecure SHA1 for older OpenSSL
versions. This fixes X509_sign failing in regress_openssl for a number
of tests, eg:
- Secondly, when using TLS 1.3, there's no support for renegotiation, so
for the renegotiation tests, we need to disable TLS v1.3, and expect
to negotiate TLS 1.1 or 1.2
Fixes: #661
* upstream/pr/1291:
OpenSSL 3 fixes: Disable TLS 1.3 when testing renegotiation support
OpenSSL 3 fixes: use SHA256 instead of SHA1
fanquake [Thu, 23 Jun 2022 12:38:14 +0000 (13:38 +0100)]
build: only try silence options if they exist
Otherwise GCC will warn. i.e:
```bash
CCLD libevent_openssl.la
cc1: note: unrecognized command-line option ‘-Wno-void-pointer-to-enum-cast’
may have been intended to silence earlier diagnostics
CCLD libevent_mbedtls.la
```
Peter Edwards [Mon, 27 Jun 2022 21:41:47 +0000 (22:41 +0100)]
OpenSSL 3 fixes: Disable TLS 1.3 when testing renegotiation support
TLS 1.3 does not support renegotation - it has been removed from the
protocol. Disable TLS 1.3 when testing this, so we negotiate an older
protocol version
Igor Klemenski [Wed, 6 Apr 2022 21:35:00 +0000 (14:35 -0700)]
Fix mingw pipeline (by using correct PATH to msys64)
I found the correct path by looking at the _Disable Key Refresh_ step in
_mingw::autotools::set up msys2_ task
(https://github.com/rectified95/libevent/runs/5858227589?check_suite_focus=true)
Igor Klemenski [Wed, 6 Apr 2022 20:44:27 +0000 (13:44 -0700)]
Fix windows pipeline (by updating vcpkg version to latest)
The Windows CI is failing at the prepare vcpkg step while installing zlib
Changing the vcpkg commit hash to point to latest release
https://github.com/microsoft/vcpkg/releases/tag/2022.03.10 as opposed to
sometime in 2019 to see if that fixes it.
Later in 6d09efe8686de824adf3d8810bbe0d5c386643e4 ("Set RPATH only if
installation is done into non system directory") it was set only if it
was installed to non system directory.
But absolute RPATH not a good default, let's change this.
In 78fa3971be892194aa168c04fc34bf5f2cd99b99 from
https://github.com/libevent/libevent/pull/1241#commitcomment-63865496 a
new "if MBEDTLS" block was added to include/include.am. This is not
parsed by automake as it isn't on the first column, resulting in a
subsequent error in the build.
From [1]:
> The if, else, and endif statements should not be indented, i.e., start on column one.
Jessica Clarke [Tue, 21 Dec 2021 13:15:58 +0000 (13:15 +0000)]
regress_ssl: Use intptr_t when shoving an int into a void *
Currently the code uses long, but long does not always have the same
representation as a pointer, such as on 64-bit Windows where long is
only 32-bit due to its unususal LLP64 ABI, but also on CHERI, and thus
Arm's prototype Morello architecture, where C language pointers are
represented as hardware capabilities, which have bounds, permissions and
other metadata to enforce spatial memory safety. Both of these cases
warn when casting a long to a pointer (Windows due to long being shorter
and thus it being likely you've truncated the address, and CHERI due to
long not having any capability metadata like pointers and thus it being
likely you've stripped the metadata, with the resulting "null-derived"
capability destined to trap if dereferenced), and in both cases casting
to intptr_t as the intermediate type instead will get rid of those
warnings.
moonlightsh [Wed, 17 Nov 2021 00:40:40 +0000 (08:40 +0800)]
Fix deadlock in case of evconnlistener_disable() in parallel with callback
I've got an issue when stop evconnlistener not in the event_base_loop()
thread. evconnlistener_disable() acquired lev->lock, if the same time,
user callbacks is runing, the event thread released lock, after callback
finished, it try to aquire the lock again, I think this makes conflict:
Here is backtraces:
thread 1:
0 __lll_lock_wait (futex=futex@entry=0x555555559a60, private=0) at lowlevellock.c:52
1 0x00007ffff7f2a131 in __GI___pthread_mutex_lock (mutex=0x555555559a60) at ../nptl/pthread_mutex_lock.c:115
2 0x00007ffff7f424c9 in evthread_posix_lock (mode=0, lock_=0x555555559a60) at evthread_pthread.c:79
3 0x00007ffff7f7dc12 in listener_read_cb (fd=7, what=2, p=0x5555555599a0) at listener.c:439
4 0x00007ffff7f6d758 in event_persist_closure (base=0x555555559370, ev=0x5555555599d8) at event.c:1645
5 0x00007ffff7f6da60 in event_process_active_single_queue (base=0x555555559370, activeq=0x5555555597e0,
max_to_process=2147483647, endtime=0x0) at event.c:1704
6 0x00007ffff7f6e018 in event_process_active (base=0x555555559370) at event.c:1805
7 0x00007ffff7f6e92a in event_base_loop (base=0x555555559370, flags=0) at event.c:2047
8 0x0000555555555449 in main () at test_listen.c:67
thread 2:
0 futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x555555559858) at ../sysdeps/nptl/futex-internal.h:183
1 __pthread_cond_wait_common (abstime=0x0, clockid=0, mutex=0x555555559800, cond=0x555555559830) at pthread_cond_wait.c:508
2 __pthread_cond_wait (cond=0x555555559830, mutex=0x555555559800) at pthread_cond_wait.c:638
3 0x00007ffff7f426f3 in evthread_posix_cond_wait (cond_=0x555555559830, lock_=0x555555559800, tv=0x0) at evthread_pthread.c:162
4 0x00007ffff7f70bc5 in event_del_nolock_ (ev=0x5555555599d8, blocking=2) at event.c:2934
5 0x00007ffff7f70748 in event_del_ (ev=0x5555555599d8, blocking=2) at event.c:2821
6 0x00007ffff7f707a1 in event_del (ev=0x5555555599d8) at event.c:2830
7 0x00007ffff7f7d76e in event_listener_disable (lev=0x5555555599a0) at listener.c:343
8 0x00007ffff7f7d6e5 in evconnlistener_disable (lev=0x5555555599a0) at listener.c:325
9 0x00005555555552c3 in disable_thread (arg=0x5555555599a0) at test_listen.c:27
10 0x00007ffff7f27609 in start_thread (arg=<optimized out>) at pthread_create.c:477
11 0x00007ffff7e4e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
fanquake [Wed, 24 Nov 2021 06:41:33 +0000 (14:41 +0800)]
build: remove inconsistently used x-prefix comparisons
Given that these are already used inconsistently with `test` checks, it
makes sense to consolidate to not use the x-prefix comparisons at all.
In any case, it would be nice to think we no longer have to work around
a problem that existed in shells many, many years ago.
More info:
https://github.com/koalaman/shellcheck/wiki/SC2268
https://www.vidarholen.net/contents/blog/?p=1035
Tomas Gonzalez [Mon, 1 Nov 2021 17:01:06 +0000 (10:01 -0700)]
evutil: Fix evutil_freeaddrinfo
During testing on win32, util/getaddrinfo failed with NULL hint info
r = evutil_getaddrinfo("www.google.com", NULL, NULL, &ai);
throwing a critical heap exception when evutil_freeaddrinfo is called.
This is because of improper use of freeaddrinfo when nodes within the
ai structure are allocated using mm_malloc or mm_calloc
(EVUTIL_AI_LIBEVENT_ALLOCATED)
This adds the flag in apply_socktype_protocol_hack and walks the linked
list in evutil_freeaddrinfo removing linked list nodes that are custom
allocated before calling freeaddrinfo.
Azat Khuzhin [Sun, 19 Sep 2021 12:59:57 +0000 (15:59 +0300)]
Merge branch 'skip-tests' -- fix/skip some tests to avoid complete check failures
* skip-tests:
test: add --retries-delay (and set to 1 second by default)
test: add --retries argument
Add -Wno-void-pointer-to-enum-cast (we use this hack in tests)
test/regress_http: mark data_length_constraints as retriable
github/workflows/mingw: use ctest --output-on-failure
test/dns: mark TCP tests as retriable
test/regress: retry some signal rlated tests in darwin
test/regress_util: mark monotonic_prc as retriable
test/regress_http: fix unix_socket test
test/regress_http: disable max_connections/data_length_constraints under windows
Add EV_WINDOWS macro
Azat Khuzhin [Sat, 18 Sep 2021 22:47:42 +0000 (01:47 +0300)]
test: cleanup stalled socket after running http/unix_sock
Otherwise it breaks upload-artifacts:
Run actions/upload-artifact@v1
Uploading artifact 'ubuntu-18.04-cmake-NONE-build' from '/home/runner/work/libevent/libevent/build' for run #346
Uploading 1095 files
File error 'No such device or address' when uploading file '/home/runner/work/libevent/libevent/build/foo'.
...
Error: No such device or address
Error: Exit code 1 returned from process: file name '/home/runner/runners/2.282.1/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Artifact.PublishArtifact, Runner.Plugins"'.
Azat Khuzhin [Sat, 18 Sep 2021 22:23:07 +0000 (01:23 +0300)]
test: check return value of write()/send() in bufferevent_read_failed
This will also suppress:
../test/regress_bufferevent.c: In function ‘test_bufferevent_read_failed’: 1102
../test/regress_bufferevent.c:1395:2: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] 1103
write(data->pair[0], buf, strlen(buf));
Azat Khuzhin [Sat, 18 Sep 2021 21:27:53 +0000 (00:27 +0300)]
Merge remote-tracking branch 'upstream/pr/1203'
@ploxiln:
"It seems like a bit of refactoring might be able to clean this code
up a bit, but it's a bit tricky because of the varied tricky usage of
chain structs, so this initial version has minimal changes ... "
* upstream/pr/1203:
buffer: do not round up allocation for reference-type chain objects
mbedtls just updated to version 3.0, install mbedtls@2 variant,
which needs more help being located since it's no longer the
default and no longer linked into the typical /usr/local dirs
These chain objects only store small structs with references to
other things, and these small structs do not themselves grow, so
bumping up the allocation to MIN_BUFFER_SIZE (512 bytes) is wasteful.
Azat Khuzhin [Fri, 9 Jul 2021 21:12:21 +0000 (00:12 +0300)]
Merge remote-tracking branch 'upstream/pr/1171'
* upstream/pr/1171:
ci: install pkg-config in mingw-w64 CI
build: test ac_cv_header_sys_time_h once, reformat timer* macro checks
build: remove call to AC_C_CONST()
build: replace ntp_pkg_config macro with a call to PKG_PROG_PKG_CONFIG()
build: remove NTP_PKG_CONFIG call from libevent_mbedtls.m4
build: stop using the deprecated form of AC_OUTPUT()
build: quote args in AC_ARG_ENABLE & AS_HELP_STRING
build: remove call to AC_HEADER_TIME
build: call AC_PREREQ() first & quote argument
build: remove call to AC_PREFIX_DEFAULT
build: remove call to AC_PROG_GCC_TRADITIONAL
fanquake [Tue, 15 Jun 2021 05:35:58 +0000 (13:35 +0800)]
build: remove call to AC_PREFIX_DEFAULT
> By default, configure sets the prefix for files it installs to /usr/local.
A call to AC_PREFIX_DEFAULT, just to set the value the same as the
default, would seem unnecessary. Note that the "initialize prefix"
comment dates back to aa6567fe6475d3230c7c745a7ca208735af0c331, prior to
when an autoconf macro was actually being used.
Azat Khuzhin [Tue, 23 Mar 2021 06:50:03 +0000 (09:50 +0300)]
Switch to lukka/run-vcpkg@v7 and update vcpkgGitCommitId
Let's see if it uses set-env or not [1]:
Run lukka/run-vcpkg@v2
Restore vcpkg and its artifacts from cache
Set output env vars
Error: Unable to process command '::set-env name=RUNVCPKG_VCPKG_ROOT::D:\a\libevent\vcpkg' successfully.
Error: The `set-env` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
error: could not open file /var/cache/pacman/pkg/libzstd-1.5.0-1-x86_64.pkg.tar.zst: Child process exited with status 127
error: could not open file /var/cache/pacman/pkg/zstd-1.5.0-1-x86_64.pkg.tar.zst: Child process exited with status 127
error: could not open file /var/cache/pacman/pkg/pacman-5.2.2-23-x86_64.pkg.tar.zst: Child process exited with status 127
error: failed to commit transaction (cannot open package file)