Azat Khuzhin [Wed, 14 Sep 2022 20:14:28 +0000 (22:14 +0200)]
ci: disable freebsd 13.0 builds (due to issues in the image)
Before it fails with:
exec ssh: pkg install -y mbedtls cmake python3
/bin/bash /Users/runner/work/_actions/vmactions/freebsd-vm/v0/run.sh execSSH
Config file: freebsd-13.0.conf
Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: no access to tty (Bad file descriptor).
Thus no job control in this shell.
Installing pkg-1.18.3...
Newer FreeBSD version for package pkg:
To ignore this error set IGNORE_OSVERSION=yes
- package: 1301000
- running kernel: 1300139
Ignore the mismatch and continue? [y/N]:
Failed to install the following 1 package(s): /tmp//pkg.txz.18yvwm
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
Error: The process '/bin/bash' failed with exit code 1
And now with:
ld-elf.so.1: /lib/libc.so.7: version FBSD_1.7 required by /usr/local/lib/libpython3.9.so.1.0 not found
Commenting for now, anyway we do not need such huge CI matrix, because
we have only public workers, and they are pretty busy.
Add minimal WebSocket server implementation for evhttp (#1322)
This adds few functions to use evhttp-based webserver to handle incoming
WebSockets connections. We've tried to use both libevent and libwebsockets in
our application, but found that we need to have different ports at the same
time to handle standard HTTP and WebSockets traffic. This change can help to
stick only with libevent library.
Implementation was inspired by modified Libevent source code in ipush project
[1].
Azat Khuzhin [Sat, 13 Aug 2022 22:46:48 +0000 (00:46 +0200)]
Merge pull request #1315 from yogo1212/http_per_socket_bebcb
In it's current form, libevent requires multiple struct evhttp objects to be created in order to enable listening on sockets with more than one type of encryption.
This change allows specifying per-socket how the associated bufferevents should be created.
Thus, it becomes possible to have multiple listening sockets with different encryption parameters using only one evttp.
Borys Smejda [Sat, 13 Aug 2022 17:10:10 +0000 (19:10 +0200)]
Fixed CMake configuration failure (libevent#1321)
Deleted usage of CMake feature 'file(REAL_PATH'
which is available from version 3.19
with an old 'get_filename_component' so that
older version of CMake can still be used
to configure the project.
Dmitry Ilyin [Sun, 7 Aug 2022 10:51:48 +0000 (13:51 +0300)]
Add check of mmap64 function and use it when available rather that mmap
There can be issues on 32-bit architectures to mmap 2+GiB file, and to
make this portable between different version of glibc, mmap64 was
prefered over _FILE_OFFSET_BITS
Azat Khuzhin [Sun, 10 Jul 2022 13:49:53 +0000 (16:49 +0300)]
Rework CI to keep everything in one workflow (by using reusable workflow)
Right now because we have separate workflows there is no one page with
all the jobs, instead we have separate page for each workflow (linux,
windows, ...)
This is pretty inconvenient, so let's make it cleaner, and now we will
have only two:
Azat Khuzhin [Sun, 10 Jul 2022 10:55:32 +0000 (13:55 +0300)]
Initial OpenSSL 3.0 support (#1288)
* openssl-3:
ci: use ubuntu 22.04 with OpenSSl 3.0 instead of building OpenSSL from sources
ci: set LD_LIBRARY_PATH for openssl 3.0 build
test: suppress warning for already defined SSL_get_peer_certificate
autotools: print $OPENSSL_LIBS/$OPENSSL_INCS
Suppress -Wunused-value for BIO_set_close()
Use OPENSSL_VERSION_NUMBER over OPENSSL_VERSION_MAJOR (for compatibility)
Attempt to add OpenSSL 3 to the Linux build matrix
Initial OpenSSL 3.0 support
Azat Khuzhin [Sun, 10 Jul 2022 09:24:42 +0000 (12:24 +0300)]
ci: set LD_LIBRARY_PATH for openssl 3.0 build
Fixes:
/home/runner/work/libevent/libevent/build/test/.libs/regress: error while loading shared libraries: libssl.so.3: cannot open shared object file: No such file or directory
Azat Khuzhin [Sun, 10 Jul 2022 06:59:14 +0000 (09:59 +0300)]
test: suppress warning for already defined SSL_get_peer_certificate
build report:
[1/2] Building C object CMakeFiles/regress.dir/test/regress_mbedtls.c.o
/src/le/libevent/test/regress_mbedtls.c:50: warning: "SSL_get_peer_certificate" redefined
50 | #define SSL_get_peer_certificate mbedtls_ssl_get_peer_cert
|
In file included from /src/le/libevent/test/regress.h:139,
from /src/le/libevent/test/regress_mbedtls.c:35:
/src/oss/openssl/include/openssl/ssl.h:1799: note: this is the location of the previous definition
1799 | # define SSL_get_peer_certificate SSL_get1_peer_certificate
|
[2/2] Linking C executable bin/regress
William Marlow [Sat, 18 Jun 2022 20:43:31 +0000 (21:43 +0100)]
Initial OpenSSL 3.0 support
* Don't use deprecated functions when building against OpenSSL 3.0.
* Recognise that OpenSSL 3.0 can signal a dirty shutdown as a protocol.
error in addition to the expected IO error produced by OpenSSL 1.1.1
* Update regress_mbedtls.c for compatibility with OpenSSL 3
Azat Khuzhin [Sat, 9 Jul 2022 20:22:00 +0000 (23:22 +0300)]
Merge branch 'mbedtls-3'
* mbedtls-3:
sample/ssl-client-mbedtls.c: fix for MbedTLS 3
sample/ssl-client-mbedtls.c: break the loop on EOF
sample/ssl-client-mbedtls.c: fix printing response in readcb
Initial Mbed-TLS 3 support to get the GitHub Actions working again
Support build dir of the MbedTLS
Azat Khuzhin [Sat, 9 Jul 2022 18:14:16 +0000 (21:14 +0300)]
Merge branch 'fix-brew-autodetection'
* fix-brew-autodetection:
ci: fix cmake build w/o OPENSSL_ROOT_DIR
ci: remove separate build for BREW_AUTODETECT_OPENSSL (use it by default)
autotools: fix autodetection of openssl location via brew
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