4614 Commits

Author SHA1 Message Date
Azat Khuzhin
6349e94a0a Do not install RPATH for install tree by default
In ce8be2385b5fee16859a630fca0c98ad290c8e21 ("cmake: set rpath for
libraries on linux") RPATH was first instroduced.

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.

Fixes: #920
2022-03-10 23:54:58 +03:00
Jay Freeman (saurik)
3da71856a7 Fix build w/o OpenSSL by w/ MbedTLS
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.

  [1]: https://www.gnu.org/software/automake/manual/html_node/Usage-of-Conditionals.html

Fixes: #1251
Fixes: google/oss-fuzz#7149
2022-02-12 22:57:30 +03:00
Azat Khuzhin
6d09efe868 Set RPATH only if installation is done into non system directory
v2: use CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES

Fixes: #1245
2022-01-15 22:10:36 +03:00
Dmitry Ilyin
78fa3971be Fix make install failed when Automake used and both OpenSSL and MbedTLS are activated
Issue:
https://github.com/libevent/libevent/pull/1241#commitcomment-63865496
2022-01-15 08:30:26 +03:00
Jessica Clarke
a9595ccd7d 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.
2021-12-21 13:15:58 +00:00
Azat Khuzhin
09e9fed2bd test: fix leak in http/cancel_*server_timeout tests
Fixes: #1242
2021-12-21 08:47:00 +03:00
Dmitry Ilyin
2db55e43cf Install bufferevent_ssl.h with MbedTLS support also 2021-12-15 21:27:21 +03:00
Yongsheng Xu
cd6a41ecdd feat: add evdns_base_get_nameserver_fd method
To get underlying udp socket fd.
2021-12-10 11:05:13 +08:00
moonlightsh
12cedc8a4f 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
2021-12-07 09:41:00 +03:00
Azat Khuzhin
e1ecc6fa0d Switch coverage to ubuntu 18.04
It seems that there is no 16.04 image anymore, since github actions was
not able to find it for 24 hours [1].

  [1]: https://github.com/libevent/libevent/actions/runs/1522612189
2021-12-02 10:27:16 +03:00
fanquake
9aa4eb0991
build: use modern ax_pthread macro
acx_pthread became ax_pthread in 2009 and the macro has seen lots of updates
since then. This change switches to using the latest version.
2021-12-01 12:38:55 +08:00
Azat Khuzhin
d076d2df84 Revert "evdns: do not check server_req twice"
That was wrong assumption.

This reverts commit 991f0ed3d86ffca0c017ab83cd239289912bdaad.

Fixes: #1231
2021-11-30 22:41:05 +03:00
Azat Khuzhin
3b9c7dd6d6 ci: remove deprecated windows-2016 image
Refs: https://github.blog/changelog/2021-10-19-github-actions-the-windows-2016-runner-image-will-be-removed-from-github-hosted-runners-on-march-15-2022
2021-11-30 22:37:32 +03:00
Theo Buehler
883630f76c Don't define BIO_get_init() for LibreSSL 3.5+
BIO_get_init() is available in LibreSSL 3.5 and later. The BIO type
will become opaque, so the existing macro will break the build.
2021-11-30 22:32:18 +03:00
Azat Khuzhin
f64f60a223 Merge #1230 -- build: remove inconsistently used x-prefix comparisons
* upstream/pr/1230:
  build: fix typos in ax_check_funcs_ex.m4
  build: remove inconsistently used x-prefix comparisons
2021-11-30 22:22:49 +03:00
fanquake
80f3ab014e
build: fix typos in ax_check_funcs_ex.m4 2021-11-24 14:44:48 +08:00
fanquake
082941edf2
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
2021-11-24 14:41:33 +08:00
Azat Khuzhin
0c217f4fe1 Fix comment for evdns_base_new() 2021-11-22 00:05:27 +03:00
Christopher Chavez
89505f8513 CheckWorkingKqueue.cmake: fix missing headers
Avoid implicitly declaring functions memset() and exit()
as it is considered an error by some compilers
(e.g. Xcode clang 12 and later)
2021-11-11 21:28:10 -06:00
Tomas Gonzalez
9a38bc5f73 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.
2021-11-04 15:46:59 -07:00
Thomas Perrot
3daebf308a test: retriable tests are marked failed only when all attempts have failed
Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
2021-10-02 10:40:26 +03:00
Azat Khuzhin
048907a501 github/workflows/macos.yml: fix test step name 2021-09-19 16:00:35 +03:00
Azat Khuzhin
357dca4f70 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
2021-09-19 15:59:57 +03:00
Azat Khuzhin
90846c30ff test: add --retries-delay (and set to 1 second by default)
In attemp to address failures of dns/tcp_* tests under windows [1].

  [1]: https://github.com/azat/libevent/runs/3644218468?check_suite_focus=true
2021-09-19 13:49:18 +03:00
Azat Khuzhin
d7d6af7578 test: add --retries argument 2021-09-19 13:47:32 +03:00
Azat Khuzhin
7179ceddf0 Add -Wno-void-pointer-to-enum-cast (we use this hack in tests)
Refs: https://reviews.llvm.org/D75758
2021-09-19 13:47:32 +03:00
Azat Khuzhin
29492364a2 test/regress_http: mark data_length_constraints as retriable
CI: https://github.com/libevent/libevent/runs/3643914024?check_suite_focus=true
2021-09-19 12:56:24 +03:00
Azat Khuzhin
12e6d6ebaf github/workflows/mingw: use ctest --output-on-failure
Otherwise it is hard to understand the problem [1].

  [1]: https://github.com/azat/libevent/runs/3643912284
2021-09-19 12:33:59 +03:00
Azat Khuzhin
7855900c01 test/dns: mark TCP tests as retriable
CI: https://github.com/azat/libevent/runs/3643912296 # tcp_resolve_many_clients
CI: https://github.com/azat/libevent/runs/3643912192 # tcp_timeout
CI: https://github.com/azat/libevent/runs/3643912336 # tcp_resolve
CI: https://github.com/azat/libevent/runs/3643912174 # tcp_resolve_pipeline
2021-09-19 12:29:02 +03:00
Azat Khuzhin
6ad6afb646 test/regress: retry some signal rlated tests in darwin
CI: https://github.com/azat/libevent/runs/3643912290 # simplestsignal
CI: https://github.com/azat/libevent/runs/3643912296 # simplesignal
CI: https://github.com/azat/libevent/runs/3643912228 # multiplesignal
2021-09-19 12:26:14 +03:00
Azat Khuzhin
58606a62e2 test/regress_util: mark monotonic_prc as retriable
CI: https://github.com/azat/libevent/runs/3643966877
2021-09-19 12:21:39 +03:00
Azat Khuzhin
de53da2e3c test/regress_http: fix unix_socket test 2021-09-19 11:13:30 +03:00
Azat Khuzhin
95eadf0426 test/regress_http: disable max_connections/data_length_constraints under windows
CI: https://github.com/libevent/libevent/runs/3643554394
2021-09-19 10:56:52 +03:00
Azat Khuzhin
a35d2d01ff Add EV_WINDOWS macro 2021-09-19 10:54:08 +03:00
Azat Khuzhin
39dcd52b94 ci: split build and test into separate jobs 2021-09-19 09:21:43 +03:00
Azat Khuzhin
f1e9e4dad3 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"'.
2021-09-19 01:47:42 +03:00
Azat Khuzhin
f89e86123c 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));
2021-09-19 01:24:20 +03:00
Azat Khuzhin
04fcd7c6df test: mark util/monotonic_prc_fallback as retriable
Refs: #1193
2021-09-19 00:57:31 +03:00
Azat Khuzhin
41b5ab0f49 bufferevent_ssl: check return value of the evbuffer_drain()
Refs: #1163
2021-09-19 00:39:54 +03:00
Azat Khuzhin
b926af2625 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
2021-09-19 00:27:53 +03:00
Azat Khuzhin
74af13d5eb Merge !1204 -- tests: fix macOS CI runs
* upstream/pr/1204:
  test: http_unix_socket_test: fix url could be freed uninitialized
  test: regress_http: skip unix socket parsing tests in windows
  test: fix regress_http evhttp_bind_unixsocket() on macOS
  ci: fix macOS mbedtls version/search
2021-09-19 00:23:10 +03:00
Pierce Lopez
5303feff99 test: http_unix_socket_test: fix url could be freed uninitialized
> regress_http.c:2279:2: warning: variable 'uri' is used uninitialized
>     whenever 'if' condition is true
2021-09-17 10:33:55 -04:00
Pierce Lopez
4f73bf3a46 test: regress_http: skip unix socket parsing tests in windows
windows doesn't do unix sockets
2021-09-17 10:33:55 -04:00
Pierce Lopez
58d4e50d3c test: fix regress_http evhttp_bind_unixsocket() on macOS
needs to use evutil socket helper for SOCK_NONBLOCK / SOCK_CLOEXEC
2021-09-17 10:33:55 -04:00
Pierce Lopez
bceab045ea ci: fix macOS mbedtls version/search
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

also gitignore mbedtls sample program binaries
2021-09-17 10:33:37 -04:00
Pierce Lopez
fd0ce993e9 buffer: do not round up allocation for reference-type chain objects
Skip rounding up memory allocations for:
  * evbuffer_add_reference()
  * evbuffer_add_buffer_reference()
  * evbuffer_add_file_segment()

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.
2021-09-16 23:21:26 -04:00
Pierce Lopez
fabbf3b310 test: skip dns_initialize_nameservers if missing /etc/resolv.conf
some build systems run tests in minimal containers with no resolv.conf,
and the primary thing this test does is load the default /etc/resolv.conf
2021-09-14 01:19:36 -04:00
Yong Wu
68675d5f67
doc: adjust flags notice on event_base_loop() 2021-09-12 18:03:03 +08:00
Yong Wu
990bcfc28e ev_io_timeout consistency 2021-09-12 00:39:46 +03:00
Yong Wu
7459407701
modify typo - timeeouts 2021-09-05 22:42:04 +08:00