redis/src
antirez 48cde3fe47 dict.c iterator API misuse protection.
dict.c allows the user to create unsafe iterators, that are iterators
that will not touch the dictionary data structure in any way, preventing
copy on write, but at the same time are limited in their usage.

The limitation is that when itearting with an unsafe iterator, no call
to other dictionary functions must be done inside the iteration loop,
otherwise the dictionary may be incrementally rehashed resulting into
missing elements in the set of the elements returned by the iterator.

However after introducing this kind of iterators a number of bugs were
found due to misuses of the API, and we are still finding
bugs about this issue. The bugs are not trivial to track because the
effect is just missing elements during the iteartion.

This commit introduces auto-detection of the API misuse. The idea is
that an unsafe iterator has a contract: from initialization to the
release of the iterator the dictionary should not change.

So we take a fingerprint of the dictionary state, xoring a few important
dict properties when the unsafe iteartor is initialized. We later check
when the iterator is released if the fingerprint is still the same. If it
is not, we found a misuse of the iterator, as not allowed API calls
changed the internal state of the dictionary.

This code was checked against a real bug, issue #1240.

This is what Redis prints (aborting) when a misuse is detected:

Assertion failed: (iter->fingerprint == dictFingerprint(iter->d)),
function dictReleaseIterator, file dict.c, line 587.
2013-08-19 15:00:57 +02:00
..
.gitignore Ignore gcov/lcov artifacts 2012-04-13 17:52:33 -07:00
Makefile use `install` as default installer (except on SunOS) 2013-03-21 13:32:08 +11:00
Makefile.dep Set process name in ps output to make operations safer. 2013-02-26 11:52:12 +01:00
adlist.c Fixed many typos. 2013-01-19 10:59:44 +01:00
adlist.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
ae.c ae.c event loop: API to resize the fd set size on the run. 2013-06-28 16:39:49 +02:00
ae.h ae.c event loop: API to resize the fd set size on the run. 2013-06-28 16:39:49 +02:00
ae_epoll.c ae.c event loop: API to resize the fd set size on the run. 2013-06-28 16:39:49 +02:00
ae_evport.c ae.c event loop: API to resize the fd set size on the run. 2013-06-28 16:39:49 +02:00
ae_kqueue.c ae.c event loop: API to resize the fd set size on the run. 2013-06-28 16:39:49 +02:00
ae_select.c ae.c event loop: API to resize the fd set size on the run. 2013-06-28 16:39:49 +02:00
anet.c anet.c: save some vertical space. 2013-07-10 14:37:13 +02:00
anet.h Add IPv6 support to sentinel.c. 2013-07-08 16:08:36 +02:00
aof.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
asciilogo.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
bio.c Fixed many typos. 2013-01-19 10:59:44 +01:00
bio.h Make bio.c threads killable ASAP if needed. 2012-11-22 10:12:11 +01:00
bitops.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
cluster.c sdsrange() does not need to return a value. 2013-07-24 11:21:39 +02:00
config.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
config.h Set proctitle: avoid the use of __attribute__((constructor)). 2013-02-27 11:50:35 +01:00
crc16.c Fixed many typos. 2013-01-19 10:59:44 +01:00
crc64.c crc64.c modified for incremental computation. 2012-04-09 12:20:47 +02:00
crc64.h Introduced the Build ID in INFO and --version output. 2012-11-29 14:20:08 +01:00
db.c Allow SHUTDOWN in loading state. 2013-06-27 12:18:29 +02:00
debug.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
dict.c dict.c iterator API misuse protection. 2013-08-19 15:00:57 +02:00
dict.h dict.c iterator API misuse protection. 2013-08-19 15:00:57 +02:00
endianconv.c endian.c/h -> endianconv.c/h to avoid issues with broken libraries search paths. 2012-02-14 16:11:46 +01:00
endianconv.h Fix config.h endianess detection to work on Linux / PPC64. 2012-12-11 17:01:00 +01:00
fmacros.h don't define _XOPEN_SOURCE for NetBSD 2013-05-17 17:19:02 +09:00
help.h redis-cli: help.h updated. 2013-05-14 11:23:16 +02:00
intset.c BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
intset.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
lzf.h redis.c split into many different C files. 2010-07-01 14:38:51 +02:00
lzfP.h Fixed many typos. 2013-01-19 10:59:44 +01:00
lzf_c.c redis.c split into many different C files. 2010-07-01 14:38:51 +02:00
lzf_d.c redis.c split into many different C files. 2010-07-01 14:38:51 +02:00
memtest.c Fixed a bug in memtest progress bar, that had no actual effects. 2013-01-21 12:34:22 +01:00
mkreleasehdr.sh suppress external diff program when using git diff. 2013-02-24 18:17:46 +01:00
multi.c Transactions: propagate MULTI/EXEC only when needed. 2013-03-26 10:58:10 +01:00
networking.c Use precomptued objects for bulk and mbulk prefixes. 2013-08-12 12:50:49 +02:00
notify.c Keyspace notifications: fixed a leak and a bug introduced in the latest commit. 2013-01-28 13:15:16 +01:00
object.c Remove dead variable bothsds from object.c. 2013-07-28 11:00:09 +02:00
pqsort.c pqsort.c: remove the "switch to insertion sort" optimization. 2013-07-02 17:47:32 +02:00
pqsort.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
pubsub.c New API to force propagation. 2013-06-21 12:07:53 +02:00
rand.c BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
rand.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
rdb.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
rdb.h Fixed many typos. 2013-01-19 10:59:44 +01:00
redis-benchmark.c redis-benchmark: changes to random arguments substitution. 2013-08-08 16:42:08 +02:00
redis-check-aof.c BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
redis-check-dump.c Fixed many typos. 2013-01-19 10:59:44 +01:00
redis-cli.c Wrap IPv6 in brackets in the prompt. 2013-07-11 17:47:55 +02:00
redis-trib.rb redis-trib: ClusterNode #info_string output modified. 2013-03-26 18:16:03 +01:00
redis.c Add per-db average TTL information in INFO output. 2013-08-06 15:00:43 +02:00
redis.h Replication: better way to send a preamble before RDB payload. 2013-08-12 10:29:14 +02:00
release.c Fixed many typos. 2013-01-19 10:59:44 +01:00
replication.c replicationFeedSlaves() func name typo: feedReplicationBacklogWithObject -> feedReplicationBacklog. 2013-08-12 12:50:45 +02:00
rio.c Chunked loading of RDB to prevent redis from stalling reading very large keys. 2013-07-16 15:41:24 +02:00
rio.h Fixed typo in rio.h, simgle -> single. 2013-07-16 15:43:36 +02:00
scripting.c Flush the replication script cache after SCRIPT FLUSH. 2013-06-25 15:36:48 +02:00
sds.c sdsrange() does not need to return a value. 2013-07-24 11:21:39 +02:00
sds.h Fix sdsempty() prototype in sds.h. 2013-08-12 11:38:21 +02:00
sentinel.c sdsrange() does not need to return a value. 2013-07-24 11:21:39 +02:00
setproctitle.c Set proctitle: avoid the use of __attribute__((constructor)). 2013-02-27 11:50:35 +01:00
sha1.c Fixed many typos. 2013-01-19 10:59:44 +01:00
sha1.h redis.c split into many different C files. 2010-07-01 14:38:51 +02:00
slowlog.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
slowlog.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
solarisfixes.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
sort.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
syncio.c syncio.c read / write functions reworked for correctness and performance. 2012-05-02 22:41:50 +02:00
t_hash.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
t_list.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
t_set.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
t_string.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
t_zset.c Introduction of a new string encoding: EMBSTR 2013-07-22 10:31:38 +02:00
testhelp.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
util.c Ignore sdsrange return value. 2013-07-24 18:59:54 +02:00
util.h pathIsBaseName() added to utils.c 2013-07-02 12:08:07 +02:00
valgrind.sup more valgrind friendly test 2011-07-06 15:22:00 +02:00
version.h Version bumped to 2.9.11 2013-05-27 11:44:04 +02:00
ziplist.c Merge pull request #776 from charsyam/ziplist-bug 2013-07-02 03:18:18 -07:00
ziplist.h BSD license added to every C source and header file. 2012-11-08 18:31:32 +01:00
zipmap.c Fixed some spelling errors in the comments 2012-04-07 14:40:29 +02:00
zipmap.h save zipmap encoded hashes as blobs. Work in progress. 2011-02-28 09:56:48 +01:00
zmalloc.c Fixed many typos. 2013-01-19 10:59:44 +01:00
zmalloc.h zmalloc_get_private_dirty() function added (Linux only). 2012-11-19 11:47:35 +01:00