0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 15:41:05 +08:00

3140 Commits

Author SHA1 Message Date
Min RK
bf906ee346
AF_UNIX support may fail on bind 2022-09-08 15:10:04 +02:00
Min RK
b2921d7183
check rc in make_fdpair
since it can fail, e.g. Windows + AF_UNIX
2022-09-08 11:17:51 +02:00
Abael He
4e193f36fc Problem: some tools misdetect null access or broken libsodium implementation
Build all projects

** BUILD SUCCEEDED **

bash-3.2# cd  bin/Debug/
bash-3.2# for x in ./* ; do ./$x 1> /dev/null 2>/dev/null  || echo $x ; done
./test_bind_curve_fuzzer
./test_bind_fuzzer
./test_bind_null_fuzzer
./test_connect_curve_fuzzer
./test_connect_fuzzer
./test_connect_null_fuzzer
Segmentation fault: 11
./test_security_curve
./test_z85_decode_fuzzer
bash-3.2# ./test_bind_curve_fuzzer
bash-3.2# ./test_bind_curve_fuzzer
bash-3.2# ./test_bind_fuzzer
bash-3.2# ./test_bind_null_fuzzer
bash-3.2# ./test_connect_curve_fuzzer
bash-3.2# ./test_connect_fuzzer
bash-3.2# ./test_security_curve
Segmentation fault: 11
bash-3.2# lldb ./test_security_curve
(lldb) target create "./test_security_curve"
Current executable set to '/Users/abaelhe/Downloads/libzmq-master/build/bin/Debug/test_security_curve' (x86_64).
(lldb) r
Process 39009 launched: '/Users/abaelhe/Downloads/libzmq-master/build/bin/Debug/test_security_curve' (x86_64)
Process 39009 stopped
* thread #3, name = 'ZMQbg/IO/0', stop reason = signal SIGSEGV
    frame #0: 0x00007ff80f64f192 libsystem_kernel.dylib`__pthread_sigmask + 10
libsystem_kernel.dylib`__pthread_sigmask:
->  0x7ff80f64f192 <+10>: jae    0x7ff80f64f19c            ; <+20>
    0x7ff80f64f194 <+12>: movq   %rax, %rdi
    0x7ff80f64f197 <+15>: jmp    0x7ff80f64a1c5            ; cerror_nocancel
    0x7ff80f64f19c <+20>: retq
Target 0: (test_security_curve) stopped.
(lldb) bt
warning: could not find Objective-C class data in the process. This may reduce the quality of type information available.
* thread #3, name = 'ZMQbg/IO/0', stop reason = signal SIGSEGV
  * frame #0: 0x00007ff80f64f192 libsystem_kernel.dylib`__pthread_sigmask + 10
    frame #1: 0x00007ff80f685acb libsystem_pthread.dylib`pthread_sigmask + 9
    frame #2: 0x00007ff80f5d1d19 libsystem_c.dylib`abort + 112
    frame #3: 0x0000000100333551 libsodium.23.dylib`_out_of_bounds.cold.1 + 17
    frame #4: 0x0000000100316229 libsodium.23.dylib`_out_of_bounds + 9
    frame #5: 0x0000000100316218 libsodium.23.dylib`sodium_free + 408
    frame #6: 0x00000001005a6d0d libzmq.5.dylib`zmq::secure_allocator_t<unsigned char>::deallocate(this=0x00007000014c6ce0, p="", (null)=96) at secure_allocator.hpp:63:56
    frame #7: 0x00000001005a6c25 libzmq.5.dylib`std::__1::allocator_traits<zmq::secure_allocator_t<unsigned char> >::deallocate(__a=0x00007000014c6ce0, __p="", __n=96) at allocator_traits.h:282:13
    frame #8: 0x00000001005a6484 libzmq.5.dylib`std::__1::__vector_base<unsigned char, zmq::secure_allocator_t<unsigned char> >::~__vector_base(this=0x00007000014c6cd0) at vector:488:9
    frame #9: 0x00000001005acae2 libzmq.5.dylib`std::__1::vector<unsigned char, zmq::secure_allocator_t<unsigned char> >::~vector(this=0x00007000014c6cd0 size=0) at vector:579:5
    frame #10: 0x00000001005ac165 libzmq.5.dylib`std::__1::vector<unsigned char, zmq::secure_allocator_t<unsigned char> >::~vector(this=0x00007000014c6cd0 size=0) at vector:574:5
    frame #11: 0x00000001005ab2e7 libzmq.5.dylib`zmq::curve_server_t::process_hello(this=0x000000010182c600, msg_=0x00006000037001e8) at curve_server.cpp:208:1
    frame #12: 0x00000001005aad30 libzmq.5.dylib`zmq::curve_server_t::process_handshake_command(this=0x000000010182c600, msg_=0x00006000037001e8) at curve_server.cpp:104:18
    frame #13: 0x000000010062ccd7 libzmq.5.dylib`zmq::stream_engine_base_t::process_handshake_command(this=0x000000010182d400, msg_=0x00006000037001e8) at stream_engine_base.cpp:491:32
    frame #14: 0x000000010062ba21 libzmq.5.dylib`zmq::stream_engine_base_t::in_event_internal(this=0x000000010182d400) at stream_engine_base.cpp:309:14
    frame #15: 0x000000010062b665 libzmq.5.dylib`zmq::stream_engine_base_t::in_event(this=0x000000010182d400) at stream_engine_base.cpp:243:22
    frame #16: 0x00000001005c0889 libzmq.5.dylib`zmq::kqueue_t::loop(this=0x00006000037000c0) at kqueue.cpp:218:30
    frame #17: 0x00000001005eefa9 libzmq.5.dylib`zmq::worker_poller_base_t::worker_routine(arg_=0x00006000037000c0) at poller_base.cpp:146:51
    frame #18: 0x0000000100637e66 libzmq.5.dylib`thread_routine(arg_=0x0000600003700100) at thread.cpp:256:5
    frame #19: 0x00007ff80f6864e1 libsystem_pthread.dylib`_pthread_start + 125
    frame #20: 0x00007ff80f681f6b libsystem_pthread.dylib`thread_start + 15
(lldb)
2022-08-10 22:21:00 +01:00
Abama cai
717d1980ee Problem: get_opt function read the options value maybe not thread safe
Solution: use scoped lock to prevent them from being modified during reading
2022-08-10 22:35:14 +08:00
Dimitris Apostolou
6b8dd84a63
Fix typos 2022-02-11 00:45:06 +02:00
Jasper Bekkers
aea0665eec
Fix minor casing issue in include files
This fails when compiling x86_64-pc-windows-msvc targets on a case sensitive file system.
2022-02-06 22:12:19 +01:00
fanquake
6473bf4166 problem: kevent udata is now void* on NetBSD Current (10)
solution: check for the intptr_t variant in configure.
2022-01-03 18:03:14 +00:00
Tarmo Tänav
74529d97b2 Problem: ROUTER loses first frame metadata on message prefetch
Solution: copy metadata on prefetch to the first frame
2021-12-16 10:17:44 +02:00
patrick-volante
2c415b6f68 Problem: inside the event array, epoll return an event with invalid data pointer which create a segmentation fault
Tests to prevent segmentation fault due to null pointer are added.
2021-12-03 11:58:20 +01:00
myd7349
471ea68caf Problem: struct sockaddr_un redefinition
The definition of sockaddr_un should be protected by the include guard.
2021-11-25 08:35:58 +08:00
myd7349
5eb0b00c87
Problem: In rare cases, afunix.h doesn't contain a definition for struct sockaddr_un (#4310)
* Problem: In rare cases, afunix.h doesn't contain a definition for struct sockaddr_un

According to https://github.com/microsoft/vcpkg/issues/21623,
struct sockaddr_un might be unavailable on some machines even afunix.h exists.

For example, on some machines, the content of afunix.h looks like this:
typedef struct _SOCKADDR_UN
{
     ADDRESS_FAMILY Family;
     wchar_t Path[63];
} SOCKADDR_UN, *PSOCKADDR_UN;

but on other machines, it may looks like this:
#define UNIX_PATH_MAX 108

typedef struct sockaddr_un
{
    ADDRESS_FAMILY sun_family;
    char sun_path[UNIX_PATH_MAX];
} SOCKADDR_UN, *PSOCKADDR_UN;

Fixes #3949

References:
- [Enable Unix-domain sockets support on Windows](8f3ec75de4)
- [AF_UNIX equivalent for Windows](https://stackoverflow.com/questions/9029174/af-unix-equivalent-for-windows)
- https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
2021-11-24 14:55:45 +00:00
Niyas Sait
0d86aa517f Fix linting error reported by clang-format 2021-11-15 10:31:21 +00:00
Niyas Sait
e9f86fee61 Get cycle count from ARM64 PMCCNTR_EL0 register 2021-11-15 09:12:11 +00:00
Paul Thiele
6737d50933 Problem: if ZMQ_XPUB_VERBOSER is used with proxies unsubscribe messages are lost
Solution: add socket option ZMQ_XSUB_VERBOSE_UNSUBSCRIBE to forward all unsubscribe messages
2021-11-05 15:12:31 +01:00
Luca Boccassi
d62fd1ac7a Problem: formatting broken
Solution: run make clang-format-diff
2021-11-03 19:39:50 +00:00
Qqzk
bb7a1cc018 Update decoder_allocators.cpp
zmq::shared_message_memory_allocator::deallocate () need to descontruct the object created by new operator.
2021-11-03 19:37:41 +00:00
mjvankampen
36d6b5d923
Problem: polling_util.hpp missing sys/select.h include (#4283)
* Problem: polling_util.hpp missing sys/select.h include

Solution: include sys/select.h
2021-10-21 20:56:32 +01:00
E. G. Patrick Bos
36e4c9b474
add zmq_ppoll
zmq_ppoll mostly mimics zmq_poll behavior, except for the added feature of being able to specify a signal mask. Signals in this mask will be blocked during execution of zmq_ppoll. Switching of the process' active signal mask happens atomically with the actual poll call, so that no race conditions can occur. This behavior is useful when one wants to gracefully handle POSIX signals without race conditions. See e.g. the discussion below https://250bpm.com/blog:12/ for an explanation.

Also includes two new tests:
1. test_zmq_ppoll_fd does the same thing as test_zmq_poll_fd, demonstrating backwards compatibility with zmq_poll when used with a default signal mask.
2. test_zmq_ppoll_signals demonstrates the use of zmq_ppoll with a signal mask, blocking out SIGTERM everywhere except in zmq_ppoll, allowing to handle the signal in one place without having to worry about race conditions.
2021-09-24 11:04:20 +02:00
Luca Boccassi
0f706bdd97 Problem: formatting errors
Solution: run make clang-format-diff
2021-09-22 16:40:17 +01:00
Tim Blechmann
2bfef9aff3 epoll: add missing override statement 2021-09-22 10:11:03 +01:00
Tim Blechmann
51e97c5480 add missing override statements 2021-09-21 20:13:41 +08:00
Gudmundur Adalsteinsson
056f37f352 Problem: fast vector resize bug
Solution: init correct vector size and copy previous data into it
2021-09-01 09:58:34 +01:00
Yunye Pu
0e3073f402 Problem: WSS broken under contention
Solution: Make wss_engine_t's read and write consistent with stream_engine_base_t
2021-08-31 13:29:41 +08:00
Min RK
bcb659e00e
Problem: calling randombytes_close with libsodium can crash Contexts in other threads (#4242)
* add opt-out for randombytes_close

Problem: randombytes_close is either a no-op or unsafe when a Context is running.

Unfortunately, there does not appear to be a single always correct choice,
so let builders pick between two not-great options.

Opting out can leak an FD on /dev/urandom which may need to be closed explicitly.
However, with the default behavior,
using multiple contexts with CURVE can crash with no application-level workaround available.

randombytes_close is not threadsafe and calling it while still in use by a Context can cause a crash.

For implementations using /dev/[u]random, this can leave up to one leftover FD per process.

The libsodium docs suggest that this function rarely needs to be called explicitly.
2021-08-13 15:11:29 +01:00
Luca Boccassi
c45750a29f Problem: formatting broken
Solution: run make clang-format-diff
2021-07-30 14:40:47 +01:00
Sascha van Vliet
720ad05529 Fix crash in context with wide characters in path
The create_ipc_wildcard_address doesn't takes wide characters
into account while building a string from a temporary path.
The tmpnam_s can return a path in the user temp folder which
can contain special characters.
The string that is returned from the create_ipc_wildcard_address
will be used in the bind routine which will return an error code.
2021-07-30 10:47:08 +02:00
sabotagebeats
06aba27b04 fix: building libzmq fails with error src/clock.cpp:131:16: error: unused variable 'nsecs_per_usec' 2021-07-22 21:53:19 -07:00
Bill Torpey
ca8e30ed48
fixes for UBSAN warnings (#4223)
Problem: UBSAN shows warnings

Solution: fix alignment issues and signed to unsigned conversion
2021-06-29 13:02:35 +01:00
Luca Boccassi
fb9fb00eda Problem: formatting is broken
Solution: run clang-format-diff
2021-06-15 19:22:19 +01:00
Luca Boccassi
9b2e1fa26c
Merge pull request #4211 from egpbos/patch-1
fix unused parameter warning when POLL_BASED_ON_SELECT
2021-06-15 19:21:01 +01:00
Luca Boccassi
92b2c38a2c Problem: build with curve fails on GCC 11
Solution: ignore false positives due to compiler bug:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578

Fixes https://github.com/zeromq/libzmq/issues/4206
2021-06-13 16:21:55 +01:00
Patrick Bos
ece244dd3c
fix unused parameter warning when POLL_BASED_ON_SELECT
When the build is performed with cmake option `-DPOLLER=select`, the following warning is triggered from 4 locations that import `polling_util.hpp`:

```
[...]/src/polling_util.hpp:115:50: warning: unused parameter 'pollset_' [-Wunused-parameter]
inline size_t valid_pollset_bytes (const fd_set &pollset_)
                                                 ^
1 warning generated.
```

This is fixed here.
2021-06-10 12:23:22 +02:00
Doron Somech
1c6c5514ed problem: no way to know when connection is temporarly dropped
This is important in order to send the login sequence of a client to the server.

Solution: add ZMQ_HICCUP_MSG to a socket, socket would send that message whenever a connection get temporarly disconnected
2021-06-06 17:14:22 +03:00
Doron Somech
30a0c590d8 problem: outpipe can be null when sending disconnect msg 2021-05-19 14:41:27 +03:00
Chengye Ke
04c37982b1
Support so_busy_poll (#4188)
* Support so_busy_poll.
2021-05-14 23:05:56 +01:00
Rosen Penev
a02cbd0646
fix unused variables under windows
Fixes compilation as -Werror is passed.
2021-05-02 16:49:27 -07:00
Bill Torpey
6bf7728e6e ZMQ_RECONNECT_STOP options are intended to be inclusive (i.e., can be OR'ed together), and so values must be powers of two 2021-04-28 10:30:35 -04:00
Jose Santiago
e6e683731d Fix MINGW with pthread cv
ZeroMQ works and MINGW and pthread conditional variables if pthread
mutexes are used. POSIX conditional variables require POSIX mutexes, but
ZeroMQ unconditionally uses WIN32 critital sections even when configured
with pthread conditional variables. This of course does not work. This
patch fixes the build so that MINGW builds do not use WIN32 critical
sections and instead use POSIX mutexes when configured with pthread
conditional variables.

Tested with:

```
 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ ../libzmq/configure --host=x86_64-w64-mingw32 --prefix=`pwd`/stage --enable-debug --disable-Werror --enable-libunwind=no   --with-cv-impl=pthread --enable-libbsd=no
```

```
x86_64-w64-mingw32-gcc --version

   x86_64-w64-mingw32-gcc (GCC) 10.2.0.....
```
2021-04-15 13:43:55 -05:00
Luca Boccassi
b82777bfb6 Problem: compiler error with GCC 11
Solution: downcast size to uint32_t to match vector size
range
2021-03-20 19:22:46 +00:00
Luca Boccassi
bd5f5a1093
Merge pull request #4148 from bluca/vmci
Problem: VMCI build broken
2021-02-23 11:57:18 +00:00
Luca Boccassi
8fe5b54b8a Problem: VMCI build broken
Solution: refactor it
2021-02-21 11:50:38 +00:00
Gudmundur Adalsteinsson
c325ed127e Problem: strtok is not thread safe
Solution: use strtok_r
2021-02-20 20:29:17 +00:00
Luca Boccassi
c515671bc8
Merge pull request #4145 from gummif/gfa/malloc-vec
Problem: C style malloc and free
2021-02-19 14:06:20 +00:00
Gudmundur Adalsteinsson
10078a9225 Problem: Unused member variables _last_in
Solution: Remove them
2021-02-18 20:38:42 +00:00
Gudmundur Adalsteinsson
4b61c67ef0 Problem: C style malloc and free
Solution: use new and delete
2021-02-18 20:31:55 +00:00
Luca Boccassi
54c7f7969b Problem: formatting errors
Solution: run make clang-format-diff
2021-02-08 11:39:09 +00:00
Tarmo Tänav
2df7ab6aee Problem: XPUB socket allows manual subscription on terminated pipe
Solution: Avoid setting pipe as _last_pipe if it has been terminated
2021-02-08 06:02:10 +02:00
sab24
133f0d00b6 Fixes indentation 2021-01-30 16:40:26 +01:00
sab24
15408f5609 Fixes Firefox WebSocket upgrade request in WebSocket engine 2021-01-30 16:23:48 +01:00
Lingqiao Zhao
cc65a9ec93
Problem: exception thrown when debugging cl.exe x64 build with LLDB (#4129)
* Problem: exception thrown when debugging
cl.exe x64 build with LLDB

Solution: Use __try __except with cl.exe and
use pthread_setname_np with MinGW.
Remove usage of pushing exception handler
to TIB->ExceptionList.
2021-01-27 10:39:48 +00:00