redis/src
meiravgri fe47c2027b
Signal handler attributes (#12426)
This PR purpose is to make the crash report process thread safe.
main changes include:

1. `setupSigSegvHandler()` is introduced to initialize the signal handler.
This function first initializes the signal handler mutex (if not initialized yet)
and then registers the process to the signal handler. 

2. **sigsegvHandler** flags :
SA_NODEFER - don't add the signal to the process signal mask. We use this
flag because we want to be able to handle a second call to the signal manually.
removed SA_RESETHAND: this flag resets the signal handler function upon the first
entrance to the registered function. The reason to use this flag is to protect from
recursively entering the signal handler by the same thread. But, it also means
that if a second thread crashes while handling a signal, the process will be
terminated immediately and we won't get the crash report.
In this PR we discard this flag. The signal handler guard described below purpose
is to solve the above issues.

3. Add a **signal handler lock** with ERRORCHECK attributes. 
The lock's purpose is to ensure that only one thread generates a crash report.
Once a second thread enters the signal handler it will be blocked.
We use the ERRORCHECK lock in order to protect from possible deadlock in
case the thread handling the crash gets a signal. In the latest scenario, we log
what we have collected until the handler crashed.

At the end of the crash report we reset the signal handler SIG_DFL, with no flags, and
rethrow the signal to generate a core dump (if enabled) and exit the process.

During the work on this PR we wanted to understand the historical reasons for
how crash is handled.
With respect to the choice of the flag, we believe the **SA_RESETHAND** was not
added for any specific purpose.
**SA_ONSTACK** which is removed here from bugReportEnd(), was originally also
set in the initial registration to signal handler, but removed in 3ada43e73. In addition,
it was removed from another location in deee2c1ef with the following description,
which is also relevant to why it should be removed from bugReportEnd:

> it seems to be some valgrind bug with SA_ONSTACK.
> SA_ONSTACK seems unneeded since WD is not recursive (SA_NODEFER was removed),
> also, not sure if it's even valid without a call to sigaltstack()
2023-08-20 19:16:45 +03:00
..
commands Fix CLUSTER REPLICAS time complexity, should be O(N) (#12477) 2023-08-14 20:57:55 -07:00
modules use $^ instead of $< for linker in module makefile (#10530) 2022-04-05 17:08:27 +03:00
.gitignore
Makefile Adding of O3 on linking stage for OPTIMIZATION=-O3 cases (#12339) 2023-06-27 11:54:17 +03:00
acl.c Fixed a bug where sequential matching ACL rules weren't compressed (#12472) 2023-08-10 09:58:53 +03:00
adlist.c Remove duplicate code in listAddNodeTail (#11733) 2023-01-20 13:18:52 -08:00
adlist.h optimize unwatchAllKeys() (#11511) 2022-11-23 17:39:08 +02:00
ae.c after calling aeSetDontWait from beforesleep, aeProcessEvent may be still wait once (#12068) 2023-04-23 17:02:09 +03:00
ae.h Add event loop support to the module API (#10001) 2022-01-18 13:10:07 +02:00
ae_epoll.c Fail fast when systemic error occurs in poll (#8749) 2021-04-26 15:52:06 +03:00
ae_evport.c Fix cluster bus extensions backwards compatibility (#10206) 2022-01-30 19:43:37 +02:00
ae_kqueue.c Fix the timing of read and write events under kqueue (#9416) 2021-09-02 11:07:51 +03:00
ae_select.c fix unused argument warning in ae_select.c (#10824) 2022-06-07 14:47:09 +03:00
anet.c Fix RDB check regression caused by PR 12022 (#12051) 2023-04-17 21:05:36 +03:00
anet.h Fix RDB check regression caused by PR 12022 (#12051) 2023-04-17 21:05:36 +03:00
aof.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
asciilogo.h Changes http to https in texts (#8495) 2021-03-10 19:11:16 +02:00
atomicvar.h Adding parentheses and do-while(0) to macros (#11080) 2022-08-03 19:38:08 +03:00
bio.c Print strerror when bio initialization fails (#12333) 2023-06-21 17:57:11 +03:00
bio.h Implementing the WAITAOF command (issue #10505) (#11713) 2023-03-14 20:26:21 +02:00
bitops.c Change compiler optimizations to -O3 -flto (#11207) 2022-10-02 15:15:14 +03:00
blocked.c Modules: Unblock from within a timer coverage (#12337) 2023-06-22 23:15:16 +03:00
call_reply.c Support for RM_Call on blocking commands (#11568) 2023-03-16 14:04:31 +02:00
call_reply.h Support for RM_Call on blocking commands (#11568) 2023-03-16 14:04:31 +02:00
childinfo.c fixes for fork child exit and test: #11463 (#11499) 2022-11-12 20:35:34 +02:00
cli_commands.c Reimplement cli hints based on command arg docs (#10515) 2023-03-30 19:03:56 +03:00
cli_commands.h Reimplement cli hints based on command arg docs (#10515) 2023-03-30 19:03:56 +03:00
cli_common.c redis-cli: Support URIs with IPv6 (#11834) 2023-06-29 19:32:01 +03:00
cli_common.h Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
cluster.c Fix CLUSTER REPLICAS time complexity, should be O(N) (#12477) 2023-08-14 20:57:55 -07:00
cluster.h Process loss of slot ownership in cluster bus (#12344) 2023-07-05 17:46:23 -07:00
commands.c Reimplement cli hints based on command arg docs (#10515) 2023-03-30 19:03:56 +03:00
commands.def Fix CLUSTER REPLICAS time complexity, should be O(N) (#12477) 2023-08-14 20:57:55 -07:00
commands.h Replaced comment with excessive warning. 2023-07-16 17:04:15 -05:00
config.c Signal handler attributes (#12426) 2023-08-20 19:16:45 +03:00
config.h Fix some compile warnings and errors when building with gcc-12 or clang (#12035) 2023-04-18 09:53:51 +03:00
connection.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
connection.h Support TLS service when "tls-cluster" is not enabled and persist both plain and TLS port in nodes.conf (#12233) 2023-06-26 07:43:38 -07:00
connhelpers.h Fixed some typos, add a spell check ci and others minor fix (#8890) 2021-06-10 15:39:33 +03:00
crc16.c RDMF (Redis/Disque merge friendlyness) refactoring WIP 1. 2015-07-26 15:17:18 +02:00
crc16_slottable.h Added basic support for clusters to redis-benchmark. 2019-03-01 17:53:14 +01:00
crc64.c Add --large-memory flag for REDIS_TEST to enable tests that consume more than 100mb (#9784) 2021-11-16 08:55:10 +02:00
crc64.h Add --large-memory flag for REDIS_TEST to enable tests that consume more than 100mb (#9784) 2021-11-16 08:55:10 +02:00
crcspeed.c Fixed some typos, add a spell check ci and others minor fix (#8890) 2021-06-10 15:39:33 +03:00
crcspeed.h Added crcspeed library 2020-04-24 17:11:21 -07:00
db.c add an assertion to make sure numkeys is 0 in getKeysUsingKeySpecs (#12389) 2023-07-06 08:17:25 +03:00
debug.c Signal handler attributes (#12426) 2023-08-20 19:16:45 +03:00
debugmacro.h Supplement define guards to prevent multiple inclusion (#10246) 2022-02-06 20:13:34 -08:00
defrag.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
dict.c skip the rehashed entries in dictNext (#12386) 2023-08-16 10:45:26 +03:00
dict.h Make a light weight version (default) of DEBUG HTSTATS (#12212) 2023-05-24 16:27:44 +03:00
endianconv.c Avoid using unsafe C functions (#10932) 2022-07-18 10:56:26 +03:00
endianconv.h Add --large-memory flag for REDIS_TEST to enable tests that consume more than 100mb (#9784) 2021-11-16 08:55:10 +02:00
eval.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
evict.c postpone the initialization of oject's lru&lfu until it is added to the db as a value object (#11626) 2023-05-24 09:40:11 +03:00
expire.c add test case and comments for active expiry in the writeable replica (#11789) 2023-02-20 10:23:25 +02:00
fmacros.h Fix some compile warnings and errors when building with gcc-12 or clang (#12035) 2023-04-18 09:53:51 +03:00
function_lua.c Ensure that the function load timeout is disabled during loading from RDB/AOF and on replicas. (#12451) 2023-08-02 11:43:31 +03:00
functions.c Ensure that the function load timeout is disabled during loading from RDB/AOF and on replicas. (#12451) 2023-08-02 11:43:31 +03:00
functions.h Ensure that the function load timeout is disabled during loading from RDB/AOF and on replicas. (#12451) 2023-08-02 11:43:31 +03:00
geo.c use embedded string object and more efficient ll2string for long long value convert to string (#12250) 2023-06-20 15:14:44 +03:00
geo.h RDMF (Redis/Disque merge friendlyness) refactoring WIP 1. 2015-07-26 15:17:18 +02:00
geohash.c Fix mistake / outdated doc comment (#10521) 2022-04-04 15:35:49 +03:00
geohash.h Remove duplicate header file include (#10264) 2022-02-08 16:49:47 +02:00
geohash_helper.c GEOSEARCH BYBOX: Simplified haversine distance formula when longitude diff is 0 (#11579) 2022-12-05 15:45:04 +02:00
geohash_helper.h Delete some unimplemented prototype. (#8882) 2021-04-29 08:25:10 +03:00
hyperloglog.c Bump codespell to 2.2.4, fix typos and outupdated comments (#11911) 2023-03-16 08:50:32 +02:00
intset.c Listpack encoding for sets (#11290) 2022-11-09 19:50:07 +02:00
intset.h Listpack encoding for sets (#11290) 2022-11-09 19:50:07 +02:00
latency.c Add basic eventloop latency measurement. (#11963) 2023-05-12 20:13:15 +03:00
latency.h Add basic eventloop latency measurement. (#11963) 2023-05-12 20:13:15 +03:00
lazyfree.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
listpack.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
listpack.h When converting a set to dict, presize for one more element to be added (#11559) 2022-12-06 11:25:51 +02:00
listpack_malloc.h Use dummy allocator to make accesses defined as per standard (#11982) 2023-04-10 20:38:40 +03:00
localtime.c fix typos (#10402) 2022-03-09 13:58:23 +02:00
logreqres.c Minor change around the req-res validator, skip sentinel commands (#12083) 2023-04-20 23:28:44 +03:00
lolwut.c Fixed some typos, add a spell check ci and others minor fix (#8890) 2021-06-10 15:39:33 +03:00
lolwut.h add include guard for lolwut.h 2020-05-05 23:35:08 -04:00
lolwut5.c Fixed some typos, add a spell check ci and others minor fix (#8890) 2021-06-10 15:39:33 +03:00
lolwut6.c Fixed some typos, add a spell check ci and others minor fix (#8890) 2021-06-10 15:39:33 +03:00
lzf.h Change lzf to handle values larger than UINT32_MAX (#9776) 2021-11-16 13:12:25 +02:00
lzfP.h Change lzf to handle values larger than UINT32_MAX (#9776) 2021-11-16 13:12:25 +02:00
lzf_c.c Change lzf to handle values larger than UINT32_MAX (#9776) 2021-11-16 13:12:25 +02:00
lzf_d.c Change lzf to handle values larger than UINT32_MAX (#9776) 2021-11-16 13:12:25 +02:00
memtest.c Add sanitizer support and clean up sanitizer findings (#9601) 2021-11-11 13:51:33 +02:00
mkreleasehdr.sh Build TLS as a loadable module 2022-08-23 12:37:56 +03:00
module.c improve performance for scan command when matching pattern or data type (#12209) 2023-06-27 16:43:46 +03:00
monotonic.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
monotonic.h Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
mt19937-64.c Fix random element selection for large hash tables. (#8133) 2020-12-23 15:52:07 +02:00
mt19937-64.h Fix random element selection for large hash tables. (#8133) 2020-12-23 15:52:07 +02:00
multi.c Fix possible memory corruption in FLUSHALL when a client watches more than one key (#11854) 2023-02-28 12:02:55 +02:00
networking.c update monitor client's memory and evict correctly (#12420) 2023-07-25 16:10:38 +03:00
notify.c Add RM_PublishMessageShard (#10543) 2022-04-17 15:43:22 +03:00
object.c use embedded string object and more efficient ll2string for long long value convert to string (#12250) 2023-06-20 15:14:44 +03:00
pqsort.c Fix null pointer subtraction warning (#10498) 2022-04-04 18:38:18 +03:00
pqsort.h
pubsub.c Optimize PSUBSCRIBE and PUNSUBSCRIBE from O(N*M) to O(N) (#12298) 2023-06-19 16:31:18 +03:00
quicklist.c Add listpack encoding for list (#11303) 2022-11-16 20:29:46 +02:00
quicklist.h Add listpack encoding for list (#11303) 2022-11-16 20:29:46 +02:00
rand.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
rand.h Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
rax.c code, typo and comment cleanups (#11280) 2022-10-02 13:56:45 +03:00
rax.h Squash merging 125 typo/grammar/comment/doc PRs (#7773) 2020-09-10 13:43:38 +03:00
rax_malloc.h Cluster: hash slots tracking using a radix tree. 2017-03-27 16:37:22 +02:00
rdb.c change return type to be consistant (#12479) 2023-08-16 10:38:59 +03:00
rdb.h change return type to be consistant (#12479) 2023-08-16 10:38:59 +03:00
redis-benchmark.c redis-benchmark: add documentation for the amount of clients needed (#12372) 2023-07-05 10:27:14 +03:00
redis-check-aof.c Fix RDB check regression caused by PR 12022 (#12051) 2023-04-17 21:05:36 +03:00
redis-check-rdb.c Fix RDB check regression caused by PR 12022 (#12051) 2023-04-17 21:05:36 +03:00
redis-cli.c redis-cli --stat take dbnum value from CONFIG GET to output total keys (#12279) 2023-08-16 10:54:37 +03:00
redis-trib.rb Redis-trib deprecated: it no longer works and it 2018-07-13 10:51:58 +02:00
redisassert.c Add sanitizer support and clean up sanitizer findings (#9601) 2021-11-11 13:51:33 +02:00
redisassert.h Fix a prototype inconsitency of `_serverAssert` between redisassert.h and redis.h (#10872) 2022-06-19 08:42:12 +03:00
redismodule.h Add ability for modules to know which client is being cmd filtered (#12219) 2023-06-20 09:03:52 +03:00
release.c Build TLS as a loadable module 2022-08-23 12:37:56 +03:00
replication.c update monitor client's memory and evict correctly (#12420) 2023-07-25 16:10:38 +03:00
resp_parser.c cleanup NBSP characters in comments (#10555) 2023-03-15 11:05:42 +02:00
resp_parser.h Fix an mistake in comment (#10560) 2022-04-10 09:29:50 +03:00
rio.c Reclaim page cache of RDB file (#11248) 2023-02-12 09:23:29 +02:00
rio.h Reclaim page cache of RDB file (#11248) 2023-02-12 09:23:29 +02:00
script.c Add missing return on -UNKILLABLE sent by master case (#12277) 2023-06-08 15:13:53 +03:00
script.h Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
script_lua.c cleanup NBSP characters in comments (#10555) 2023-03-15 11:05:42 +02:00
script_lua.h Protect any table which is reachable from globals and added globals white list. 2022-04-27 00:37:40 +03:00
sds.c use embedded string object and more efficient ll2string for long long value convert to string (#12250) 2023-06-20 15:14:44 +03:00
sds.h Optimization: sdsRemoveFreeSpace to avoid realloc on noop (#11766) 2023-01-31 17:26:35 +02:00
sdsalloc.h Sanitize dump payload: fail RESTORE if memory allocation fails 2020-12-06 14:54:34 +02:00
sentinel.c Sync the new loglevel nothing to sentinel (#12223) 2023-05-24 09:32:39 +03:00
server.c Signal handler attributes (#12426) 2023-08-20 19:16:45 +03:00
server.h Signal handler attributes (#12426) 2023-08-20 19:16:45 +03:00
setcpuaffinity.c cpu affinity: DragonFlyBSD support (#7956) 2020-10-25 14:14:05 +02:00
setproctitle.c Fix failed tests on Linux Alpine and add a CI job. (#8532) 2021-02-23 12:57:45 +02:00
sha1.c Ignore -Wstringop-overread warning for SHA1Transform() on GCC 12 (#11538) 2022-11-24 15:27:16 +02:00
sha1.h Fix some compile warnings and errors when building with gcc-12 or clang (#12035) 2023-04-18 09:53:51 +03:00
sha256.c Add sanitizer support and clean up sanitizer findings (#9601) 2021-11-11 13:51:33 +02:00
sha256.h fix explanation of sha256 (#9220) 2021-07-10 10:04:54 -05:00
siphash.c Add sanitizer support and clean up sanitizer findings (#9601) 2021-11-11 13:51:33 +02:00
slowlog.c minor optimization for slowlog get (#12103) 2023-04-25 10:17:21 +03:00
slowlog.h Auto-generate the command table from JSON files (#9656) 2021-12-15 21:23:15 +02:00
socket.c Support maxiov per connection type (#12234) 2023-05-28 08:35:27 +03:00
solarisfixes.h Check for __sun macro in solarisfixes.h, not in includers. 2015-01-09 11:23:22 +01:00
sort.c Avoid integer overflows in SETRANGE and SORT (CVE-2022-35977) (#11720) 2023-01-16 13:49:30 +02:00
sparkline.c Fix Uninitialised value error in createSparklineSequence (LATENCY GRAPH) (#11892) 2023-03-09 12:05:50 +02:00
sparkline.h
stream.h Stream consumers: Re-purpose seen-time, add active-time (#11099) 2022-11-30 14:21:31 +02:00
strl.c Avoid using unsafe C functions (#10932) 2022-07-18 10:56:26 +03:00
syncio.c syncWithMaster(): non blocking state machine. 2015-08-06 18:12:20 +02:00
syscheck.c fix typos in syscheck (#11710) 2023-01-22 16:32:20 +02:00
syscheck.h Add warning for suspected slow system clocksource setting (#10636) 2022-05-22 17:10:31 +03:00
t_hash.c Optimize HRANDFIELD and ZRANDMEMBER case 3 when listpack encoded (#12205) 2023-05-22 15:48:32 +03:00
t_list.c Fix typos in comments (#12338) 2023-06-22 08:10:42 -07:00
t_set.c Fix SPOP/RESTORE propagation when doing lazy free (#12320) 2023-06-16 08:14:11 -07:00
t_stream.c Fix typos in comments (#12338) 2023-06-22 08:10:42 -07:00
t_string.c Optimize SET PXAT to reduce calls of rewriteClientCommandVector (#12316) 2023-06-15 10:07:47 +03:00
t_zset.c Revert zrangeGenericCommand negative offset check (#12377) 2023-07-02 20:38:30 +03:00
testhelp.h skip new page cache reclame unit test when running in valgrind (#11808) 2023-02-16 10:50:58 +02:00
timeout.c Blocking command with a 0.001 seconds timeout blocks indefinitely (#11688) 2023-01-08 01:02:48 -08:00
tls.c Support maxiov per connection type (#12234) 2023-05-28 08:35:27 +03:00
tracking.c Fix the bug that CLIENT REPLY OFF|SKIP cannot receive push notifications (#11875) 2023-03-12 17:50:44 +02:00
unix.c Support maxiov per connection type (#12234) 2023-05-28 08:35:27 +03:00
util.c String pattern matching had exponential time complexity on pathological patterns (CVE-2022-36021) (#11858) 2023-02-28 15:15:26 +02:00
util.h Reclaim page cache of RDB file (#11248) 2023-02-12 09:23:29 +02:00
valgrind.sup Sanitize dump payload: fuzz tester and fixes for segfaults and leaks it exposed 2020-12-06 14:54:34 +02:00
version.h Add Module API for version and compatibility checks (#7865) 2020-10-11 17:21:58 +03:00
ziplist.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
ziplist.h Add --large-memory flag for REDIS_TEST to enable tests that consume more than 100mb (#9784) 2021-11-16 08:55:10 +02:00
zipmap.c Add --large-memory flag for REDIS_TEST to enable tests that consume more than 100mb (#9784) 2021-11-16 08:55:10 +02:00
zipmap.h Add --large-memory flag for REDIS_TEST to enable tests that consume more than 100mb (#9784) 2021-11-16 08:55:10 +02:00
zmalloc.c Remove prototypes with empty declarations (#12020) 2023-05-02 17:31:32 -07:00
zmalloc.h enable malloc_usable_size on haiku and dragonflybsd. (#12237) 2023-05-28 08:44:28 +03:00