Skip to content

Conversation

vhbit
Copy link

@vhbit vhbit commented Jan 14, 2015

Example:

let mut doc: *mut ffi::fdb_doc = ptr::null_mut();
ffi::fdb_doc_create(&mut doc,
                    ptr::null_mut(), 0,
                    ptr::null_mut(), 0,
                    ptr::null_mut(), 0);
(*doc).offset = doc1.offset(); // actual offset
// if this line is missing - result is key not found error
(*doc).seqnum = 0xffffffffffffffff;
// (*doc).seqnum = doc1.seq_num(); // this works too

let res = ffi::fdb_get_byoffset(store.get_raw(), doc);
assert_eq!(res, 0);

Happened because fdb_doc_create sets seqnum to 0 and later on
equal_doc returns false as considers 0 to be a correct value to check
against found document.

Example:

```rust
let mut doc: *mut ffi::fdb_doc = ptr::null_mut();
ffi::fdb_doc_create(&mut doc,
                    ptr::null_mut(), 0,
                    ptr::null_mut(), 0,
                    ptr::null_mut(), 0);
(*doc).offset = doc1.offset(); // actual offset
// if this line is missing - result is key not found error
(*doc).seqnum = 0xffffffffffffffff;
// (*doc).seqnum = doc1.seq_num(); // this works too

let res = ffi::fdb_get_byoffset(store.get_raw(), doc);
assert_eq!(res, 0);
```

Happened because `fdb_doc_create` sets `seqnum` to 0 and later on
`equal_doc` returns false as considers 0 to be a correct value to check
against found document.
@chiyoung
Copy link
Contributor

Thanks for reporting this bug and uploading the fix.

We use Gerrit to review a fix and push it into the github master branch. I made a fix and pushed it into our Gerrit branch:

http://review.couchbase.org/#/c/45327/

@chiyoung chiyoung closed this Jan 14, 2015
ns-codereview pushed a commit that referenced this pull request Oct 28, 2015
This change makes sure that the background flusher shouldn't access
log_callback field in openfiles_elem direclty without grabbing the
lock.

18:25:18 WARNING: ThreadSanitizer: data race (pid=55378)
18:25:18   Write of size 8 at 0x7d6400016cc0 by main thread (mutexes: write M234):
18:25:18     #0 bgflusher_register_file crtstuff.c (libforestdb.so+0x0000000180c4)
18:25:18     #1 _fdb_open /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:1918 (libforestdb.so+0x000000029d76)
18:25:18     #2 _fdb_kvs_open crtstuff.c (libforestdb.so+0x000000053ad1)
18:25:18     #3 fdb_kvs_open <null> (libforestdb.so+0x000000054820)
18:25:18     #4 ForestKVStore::getKvsHandle(unsigned short, handleType) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:618 (ep-engine_kvstore_test+0x0000004f74bd)
18:25:18     #5 ForestKVStore::readVBState(unsigned short) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:224 (ep-engine_kvstore_test+0x0000004f49d9)
18:25:18     #6 ForestKVStore::ForestKVStore(KVStoreConfig&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:135 (ep-engine_kvstore_test+0x0000004f40c4)
18:25:18     #7 KVStoreFactory::create(KVStoreConfig&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/kvstore.cc:54 (ep-engine_kvstore_test+0x0000004cb480)
18:25:18     #8 basic_kvstore_test(std::string&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:114 (ep-engine_kvstore_test+0x0000004c679a)
18:25:18     #9 main /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:183 (ep-engine_kvstore_test+0x0000004c8634)
18:25:18
18:25:18   Previous read of size 8 at 0x7d6400016cc0 by thread T5:
18:25:18     #0 bgflusher_thread(void*) /home/couchbase/.ccache/tmp/bgflusher.tmp.8b44f18711b3.238821.ii (libforestdb.so+0x000000017d26)
18:25:18
18:25:18   Location is heap block of size 1248 at 0x7d6400016800 allocated by main thread:
18:25:18     #0 calloc <null> (ep-engine_kvstore_test+0x00000046079c)
18:25:18     #1 bgflusher_register_file crtstuff.c (libforestdb.so+0x0000000180dc)
18:25:18     #2 _fdb_open /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:1918 (libforestdb.so+0x000000029d76)
18:25:18     #3 fdb_open /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:642 (libforestdb.so+0x0000000279c6)
18:25:18     #4 ForestKVStore::ForestKVStore(KVStoreConfig&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:105 (ep-engine_kvstore_test+0x0000004f3599)
18:25:18     #5 KVStoreFactory::create(KVStoreConfig&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/kvstore.cc:54 (ep-engine_kvstore_test+0x0000004cb480)
18:25:18     #6 basic_kvstore_test(std::string&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:114 (ep-engine_kvstore_test+0x0000004c679a)
18:25:18     #7 main /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:183 (ep-engine_kvstore_test+0x0000004c8634)
18:25:18
18:25:18   Mutex M234 (0x7fee334665e8) created at:
18:25:18     #0 pthread_mutex_init <null> (ep-engine_kvstore_test+0x000000465770)
18:25:18     #1 bgflusher_init crtstuff.c (libforestdb.so+0x000000017a51)
18:25:18     #2 fdb_init /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:576 (libforestdb.so+0x0000000277c1)
18:25:18     #3 ForestKVStore::initForestDb() /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:34 (ep-engine_kvstore_test+0x0000004f2ae6)
18:25:18     #4 ForestKVStore::ForestKVStore(KVStoreConfig&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:103 (ep-engine_kvstore_test+0x0000004f355b)
18:25:18     #5 KVStoreFactory::create(KVStoreConfig&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/kvstore.cc:54 (ep-engine_kvstore_test+0x0000004cb480)
18:25:18     #6 basic_kvstore_test(std::string&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:114 (ep-engine_kvstore_test+0x0000004c679a)
18:25:18     #7 main /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:183 (ep-engine_kvstore_test+0x0000004c8634)
18:25:18
18:25:18   Thread T5 (tid=55391, running) created by main thread at:
18:25:18     #0 pthread_create <null> (ep-engine_kvstore_test+0x000000464341)
18:25:18     #1 bgflusher_init crtstuff.c (libforestdb.so+0x000000017b47)
18:25:18     #2 fdb_init /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:576 (libforestdb.so+0x0000000277c1)
18:25:18     #3 ForestKVStore::initForestDb() /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:34 (ep-engine_kvstore_test+0x0000004f2ae6)
18:25:18     #4 ForestKVStore::ForestKVStore(KVStoreConfig&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:103 (ep-engine_kvstore_test+0x0000004f355b)
18:25:18     #5 KVStoreFactory::create(KVStoreConfig&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/kvstore.cc:54 (ep-engine_kvstore_test+0x0000004cb480)
18:25:18     #6 basic_kvstore_test(std::string&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:114 (ep-engine_kvstore_test+0x0000004c679a)
18:25:18     #7 main /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:183 (ep-engine_kvstore_test+0x0000004c8634)

Change-Id: I34c97f3ea6c6e728847fa4e4919b6e0069c2ec4f
ns-codereview pushed a commit that referenced this pull request Apr 5, 2016
11:02:03 WARNING: ThreadSanitizer: data race (pid=108225)
11:02:03   Write of size 8 at 0x000001571768 by thread T14 (mutexes: write M57456, write M57552, write M14):
11:02:03     #0 _bcache_alloc_freeblock() /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:293 (fdb_functional_test+0x0000004e5a89)
11:02:03     #1 filemgr_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1989 (fdb_functional_test+0x000000501a8b)
11:02:03     #2 _docio_read_through_buffer(docio_handle*, unsigned long, err_log_callback*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:691 (fdb_functional_test+0x0000004faa70)
11:02:03     #3 docio_read_doc /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:1212 (fdb_functional_test+0x0000004fbb6f)
11:02:03     #4 fdb_kvs_header_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1123 (fdb_functional_test+0x00000053261c)
11:02:03     #5 _fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:1954 (fdb_functional_test+0x00000050ac08)
11:02:03     #6 fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:782 (fdb_functional_test+0x0000005090ba)
11:02:03     #7 _worker_thread(void*) crtstuff.c (fdb_functional_test+0x0000004d184b)
11:02:03
11:02:03   Previous read of size 8 at 0x000001571768 by thread T19:
11:02:03     #0 bcache_get_num_free_blocks /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:1410 (fdb_functional_test+0x0000004e7d64)
11:02:03     #1 _filemgr_prefetch_thread(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:612 (fdb_functional_test+0x0000004fe4da)

Change-Id: Id7344ae6a13f97fb3bc6f8ed9140d1788e78fe72
Reviewed-on: http://review.couchbase.org/62377
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: buildbot <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Apr 6, 2016
In compaction scenario, before a file is freed, the
pointer to it held by a previous file and the pointer
to it held by a new file will need to be updated.

10:59:36 WARNING: ThreadSanitizer: heap-use-after-free (pid=108627)
10:59:36   Read of size 1 at 0x7d640001f558 by main thread (mutexes: write M14, write M7597):
10:59:36     #0 filemgr_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1451 (iterator_functional_test+0x000000504b5f)
10:59:36     couchbase#1 _fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7203 (iterator_functional_test+0x0000005123bb)
10:59:36     couchbase#2 _fdb_close_root /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7174 (iterator_functional_test+0x000000511854)
10:59:36     couchbase#3 fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7135 (iterator_functional_test+0x00000051ee5a)
10:59:36     couchbase#4 iterator_concurrent_compaction() crtstuff.c (iterator_functional_test+0x0000004e2078)
10:59:36     couchbase#5 main crtstuff.c (iterator_functional_test+0x0000004e4e1d)
10:59:36
10:59:36   Previous write of size 8 at 0x7d640001f558 by main thread:
10:59:36     #0 free <null> (iterator_functional_test+0x00000046136b)
10:59:36     couchbase#1 filemgr_free_func /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1657 (iterator_functional_test+0x000000502a9f)
10:59:36     couchbase#2 filemgr_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1479 (iterator_functional_test+0x000000504ea4)
10:59:36     couchbase#3 _fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7203 (iterator_functional_test+0x0000005123bb)
10:59:36     couchbase#4 fdb_kvs_close_all /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1789 (iterator_functional_test+0x000000537922)
10:59:36     couchbase#5 _fdb_close_root /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7157 (iterator_functional_test+0x0000005117d3)
10:59:36     couchbase#6 fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7135 (iterator_functional_test+0x00000051ee5a)
10:59:36     couchbase#7 iterator_concurrent_compaction() crtstuff.c (iterator_functional_test+0x0000004e2078)
10:59:36     couchbase#8 main crtstuff.c (iterator_functional_test+0x0000004e4e1d)

Change-Id: Iacf78604494026b33085663146d2adfda319fff9
ns-codereview pushed a commit that referenced this pull request Apr 7, 2016
In compaction scenario, before a file is freed, the
pointer to it held by a previous file and the pointer
to it held by a new file will need to be updated.

In the case of multiple files being present, and more than one
file has been redirected to the current file, the new_file pointers
of all those files will need to be updated in case the current file
is deleted.

10:59:36 WARNING: ThreadSanitizer: heap-use-after-free (pid=108627)
10:59:36   Read of size 1 at 0x7d640001f558 by main thread (mutexes: write M14, write M7597):
10:59:36     #0 filemgr_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1451 (iterator_functional_test+0x000000504b5f)
10:59:36     #1 _fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7203 (iterator_functional_test+0x0000005123bb)
10:59:36     #2 _fdb_close_root /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7174 (iterator_functional_test+0x000000511854)
10:59:36     #3 fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7135 (iterator_functional_test+0x00000051ee5a)
10:59:36     #4 iterator_concurrent_compaction() crtstuff.c (iterator_functional_test+0x0000004e2078)
10:59:36     #5 main crtstuff.c (iterator_functional_test+0x0000004e4e1d)
10:59:36
10:59:36   Previous write of size 8 at 0x7d640001f558 by main thread:
10:59:36     #0 free <null> (iterator_functional_test+0x00000046136b)
10:59:36     #1 filemgr_free_func /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1657 (iterator_functional_test+0x000000502a9f)
10:59:36     #2 filemgr_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1479 (iterator_functional_test+0x000000504ea4)
10:59:36     #3 _fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7203 (iterator_functional_test+0x0000005123bb)
10:59:36     #4 fdb_kvs_close_all /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1789 (iterator_functional_test+0x000000537922)
10:59:36     #5 _fdb_close_root /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7157 (iterator_functional_test+0x0000005117d3)
10:59:36     #6 fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7135 (iterator_functional_test+0x00000051ee5a)
10:59:36     #7 iterator_concurrent_compaction() crtstuff.c (iterator_functional_test+0x0000004e2078)
10:59:36     #8 main crtstuff.c (iterator_functional_test+0x0000004e4e1d)

Change-Id: Iacf78604494026b33085663146d2adfda319fff9
Reviewed-on: http://review.couchbase.org/62449
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Apr 13, 2016
11:38:53 WARNING: ThreadSanitizer: data race (pid=116143)
11:38:53   Write of size 1 at 0x7d2000217641 by thread T27 (mutexes: write M702774, write M703325, write M702832):
11:38:53     #0 _wal_flush(filemgr*, void*, fdb_status (*)(void*, wal_item*, avl_tree*, avl_tree*), unsigned long (*)(void*, wal_item*), void (*)(void*, avl_tree*, avl_tree*), void (*)(filemgr*, avl_tree*), wal_flush_items*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:1628 (mvcc_functional_test+0x000000546a9d)
11:38:53     couchbase#1 wal_flush /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:1724 (mvcc_functional_test+0x0000005466a1)
11:38:53     couchbase#2 _fdb_compact_file(_fdb_kvs_handle*, filemgr*, btreeblk_handle*, docio_handle*, hbtrie*, hbtrie*, btree*, btree*, unsigned long, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:6691 (mvcc_functional_test+0x00000051a281)
11:38:53     couchbase#3 fdb_compact_file /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:6644 (mvcc_functional_test+0x00000051a05f)
11:38:53     couchbase#4 compactor_thread(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/compactor.cc:396 (mvcc_functional_test+0x0000004fb8a2)
11:38:53
11:38:53   Previous read of size 1 at 0x7d2000217641 by main thread (mutexes: write M702835):
11:38:53     #0 __wal_cmp_byseq(wal_item*, wal_item*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:120 (mvcc_functional_test+0x00000054d046)
11:38:53     couchbase#1 _wal_cmp_byseq(avl_node*, avl_node*, void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:143 (mvcc_functional_test+0x00000054cf26)
11:38:53     couchbase#2 avl_search /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/avltree.cc:325 (mvcc_functional_test+0x0000004e7df4)
11:38:53     couchbase#3 _wal_find(_fdb_transaction*, filemgr*, unsigned long, _fdb_key_cmp_info*, snap_handle*, fdb_doc_struct*, unsigned long*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:978 (mvcc_functional_test+0x0000005451ed)
11:38:53     couchbase#4 wal_find_kv_id /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:1041 (mvcc_functional_test+0x0000005455ec)
11:38:53     couchbase#5 fdb_get_byseq /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:3179 (mvcc_functional_test+0x000000516c64)
11:38:53     couchbase#6 auto_compaction_snapshots_test() crtstuff.c (mvcc_functional_test+0x0000004e235b)
11:38:53     couchbase#7 main crtstuff.c (mvcc_functional_test+0x0000004e7542)

Change-Id: Ib935696426aedb88465e61941ba2bf44faee2ad3
ns-codereview pushed a commit that referenced this pull request Apr 13, 2016
11:38:53 WARNING: ThreadSanitizer: data race (pid=116143)
11:38:53   Write of size 1 at 0x7d2000217641 by thread T27 (mutexes: write M702774, write M703325, write M702832):
11:38:53     #0 _wal_flush(filemgr*, void*, fdb_status (*)(void*, wal_item*, avl_tree*, avl_tree*), unsigned long (*)(void*, wal_item*), void (*)(void*, avl_tree*, avl_tree*), void (*)(filemgr*, avl_tree*), wal_flush_items*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:1628 (mvcc_functional_test+0x000000546a9d)
11:38:53     #1 wal_flush /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:1724 (mvcc_functional_test+0x0000005466a1)
11:38:53     #2 _fdb_compact_file(_fdb_kvs_handle*, filemgr*, btreeblk_handle*, docio_handle*, hbtrie*, hbtrie*, btree*, btree*, unsigned long, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:6691 (mvcc_functional_test+0x00000051a281)
11:38:53     #3 fdb_compact_file /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:6644 (mvcc_functional_test+0x00000051a05f)
11:38:53     #4 compactor_thread(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/compactor.cc:396 (mvcc_functional_test+0x0000004fb8a2)
11:38:53
11:38:53   Previous read of size 1 at 0x7d2000217641 by main thread (mutexes: write M702835):
11:38:53     #0 __wal_cmp_byseq(wal_item*, wal_item*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:120 (mvcc_functional_test+0x00000054d046)
11:38:53     #1 _wal_cmp_byseq(avl_node*, avl_node*, void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:143 (mvcc_functional_test+0x00000054cf26)
11:38:53     #2 avl_search /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/avltree.cc:325 (mvcc_functional_test+0x0000004e7df4)
11:38:53     #3 _wal_find(_fdb_transaction*, filemgr*, unsigned long, _fdb_key_cmp_info*, snap_handle*, fdb_doc_struct*, unsigned long*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:978 (mvcc_functional_test+0x0000005451ed)
11:38:53     #4 wal_find_kv_id /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:1041 (mvcc_functional_test+0x0000005455ec)
11:38:53     #5 fdb_get_byseq /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:3179 (mvcc_functional_test+0x000000516c64)
11:38:53     #6 auto_compaction_snapshots_test() crtstuff.c (mvcc_functional_test+0x0000004e235b)
11:38:53     #7 main crtstuff.c (mvcc_functional_test+0x0000004e7542)

Change-Id: Ib935696426aedb88465e61941ba2bf44faee2ad3
Reviewed-on: http://review.couchbase.org/62797
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: buildbot <[email protected]>
ns-codereview pushed a commit that referenced this pull request Apr 14, 2016
Change-Id: I98a94cd9cc7acfce02bdf15b67e0cf9ace95e0e0
14:15:16 WARNING: ThreadSanitizer: data race (pid=68020)
14:15:16   Write of size 8 at 0x7d6400163b28 by thread T15 (mutexes: write M13):
14:15:16     #0 _fname_create(filemgr*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:812 (e2etest+0x0000004d5c60)
14:15:16     #1 bcache_write /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:1062 (e2etest+0x0000004d526d)
14:15:16     #2 filemgr_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:2043 (e2etest+0x0000004f1a9b)
14:15:16     #3 _docio_read_through_buffer(docio_handle*, unsigned long, err_log_callback*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:691 (e2etest+0x0000004ea770)
14:15:16     #4 docio_read_doc /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:1212 (e2etest+0x0000004eb86f)
14:15:16     #5 fdb_kvs_header_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1123 (e2etest+0x000000522e4c)
14:15:16     #6 _fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:1720 (e2etest+0x0000004fa137)
14:15:16     #7 fdb_check_file_reopen /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:2800 (e2etest+0x0000004fcb77)
14:15:16     #8 fdb_set /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:3607 (e2etest+0x00000050372f)
14:15:16     #9 fdb_set_kv <null> (e2etest+0x0000004d2a29)
14:15:16     #10 update_thread(void*) crtstuff.c (e2etest+0x0000004c9d26)
14:15:16
14:15:16   Previous read of size 8 at 0x7d6400163b28 by thread T14:
14:15:16     #0 bcache_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:924 (e2etest+0x0000004d4ddf)
14:15:16     #1 filemgr_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1976 (e2etest+0x0000004f14f1)
14:15:16     #2 _docio_read_through_buffer(docio_handle*, unsigned long, err_log_callback*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:691 (e2etest+0x0000004ea770)
14:15:16     #3 docio_read_doc /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:1212 (e2etest+0x0000004eb86f)
14:15:16     #4 fdb_kvs_header_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1123 (e2etest+0x000000522e4c)
14:15:16     #5 _fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:1720 (e2etest+0x0000004fa137)
14:15:16     #6 fdb_check_file_reopen /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:2800 (e2etest+0x0000004fcb77)
14:15:16     #7 fdb_set /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:3607 (e2etest+0x00000050372f)
14:15:16     #8 fdb_set_kv <null> (e2etest+0x0000004d2a29)
14:15:16     #9 e2e_fdb_set_person crtstuff.c (e2etest+0x0000004d0392)
14:15:16     #10 seq_writer_thread(void*) crtstuff.c (e2etest+0x0000004c9c62)
Reviewed-on: http://review.couchbase.org/62820
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
ns-codereview pushed a commit that referenced this pull request Apr 15, 2016
11:25:22 WARNING: ThreadSanitizer: heap-use-after-free (pid=115558)
11:25:22   Read of size 8 at 0x7d040000f308 by main thread:
11:25:22     #0 _cmp_double(void*, unsigned long, void*, unsigned long) /home/couchbase/.ccache/tmp/fdb_functi.tmp.140592e37b0d.95346.ii (fdb_functional_test+0x0000004d4dcc)
11:25:22     #1 __wal_cmp_bykey(wal_item_header*, wal_item_header*, void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:80 (fdb_functional_test+0x000000548483)
11:25:22     #2 _snap_cmp_bykey(avl_node*, avl_node*, void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:116 (fdb_functional_test+0x000000547ffc)
11:25:22     #3 avl_search_greater /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/avltree.cc:351 (fdb_functional_test+0x0000004e2f96)
11:25:22     #4 wal_itr_search_greater /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:2179 (fdb_functional_test+0x000000542d42)
11:25:22     #5 fdb_iterator_init <null> (fdb_functional_test+0x00000052b345)
11:25:22     #6 custom_compare_primitive_test() crtstuff.c (fdb_functional_test+0x0000004d4692)
11:25:22     #7 main crtstuff.c (fdb_functional_test+0x0000004e258a)
11:25:22
11:25:22   Previous write of size 8 at 0x7d040000f308 by main thread (mutexes: write M672581587812037744):
11:25:22     #0 free <null> (fdb_functional_test+0x00000046144b)
11:25:22     #1 free_docio_object /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:1067 (fdb_functional_test+0x0000004fb29a)
11:25:22     #2 fdb_kvs_header_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1134 (fdb_functional_test+0x000000532fba)
11:25:22     #3 _fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:1980 (fdb_functional_test+0x00000050b393)
11:25:22     #4 fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:807 (fdb_functional_test+0x0000005096ea)
11:25:22     #5 seq_tree_exception_test() crtstuff.c (fdb_functional_test+0x0000004cde92)
11:25:22     #6 main crtstuff.c (fdb_functional_test+0x0000004e257b)

Change-Id: I9191bc57e00fefadb0f31fee7cc48c3ad04cf43b
Reviewed-on: http://review.couchbase.org/62875
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: Chiyoung Seo <[email protected]>
ns-codereview pushed a commit that referenced this pull request Apr 23, 2016
[1] WARNING: ThreadSanitizer: data race (pid=16606)
  Write of size 8 at 0x7d100020c0a8 by thread T2 (mutexes: write M10, write M15):
    #0 list_remove /home/abhinav/couchbaseTS/forestdb/src/list.cc:89 (fdb_functional_test+0x000000624716)
    #1 bcache_shutdown /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:1605 (fdb_functional_test+0x00000050dc8f)
    #2 filemgr_shutdown /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1758 (fdb_functional_test+0x0000005769ff)
    #3 fdb_shutdown /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7851 (fdb_functional_test+0x0000005c69a0)
    #4 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2011 (fdb_functional_test+0x0000004d81f1)

  Previous write of size 8 at 0x7d100020c0a8 by thread T1 (mutexes: write M23078079052191248, write M17):
    #0 list_push_front /home/abhinav/couchbaseTS/forestdb/src/list.cc:34 (fdb_functional_test+0x000000623dfe)
    #1 _bcache_release_freeblock(bcache_item*) /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:315 (fdb_functional_test+0x000000505972)
    #2 bcache_remove_clean_blocks /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:1324 (fdb_functional_test+0x00000050b627)
    #3 filemgr_free_func /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1614 (fdb_functional_test+0x00000056ad37)
    #4 filemgr_close /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1567 (fdb_functional_test+0x00000057568b)
    #5 _fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7299 (fdb_functional_test+0x0000005a309a)
    #6 _fdb_close_root /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7270 (fdb_functional_test+0x0000005a197c)
    #7 fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7228 (fdb_functional_test+0x0000005c2d2f)
    #8 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2008 (fdb_functional_test+0x0000004d8132)

[2] WARNING: ThreadSanitizer: data race (pid=3464)
  Write of size 8 at 0x7db000000000 by thread T2 (mutexes: write M10, write M15):
    #0 free <null> (fdb_functional_test+0x000000456f1b)
    #1 bcache_shutdown /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:1620 (fdb_functional_test+0x0000004de9d6)
    #2 filemgr_shutdown /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1758 (fdb_functional_test+0x0000004f989b)
    #3 fdb_shutdown /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7851 (fdb_functional_test+0x0000005152af)
    #4 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2011 (fdb_functional_test+0x0000004c87be)

  Previous write of size 8 at 0x7db000000000 by thread T1 (mutexes: write M18):
    #0 _fname_try_free(fnamedic_item*) /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:852 (fdb_functional_test+0x0000004ddccb)
    #1 filemgr_free_func /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1615 (fdb_functional_test+0x0000004f676f)
    #2 filemgr_close /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1567 (fdb_functional_test+0x0000004f927b)
    #3 _fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7299 (fdb_functional_test+0x000000506bcb)
    #4 _fdb_close_root /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7270 (fdb_functional_test+0x000000506070)
    #5 fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7228 (fdb_functional_test+0x000000513a5a)
    #6 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2008 (fdb_functional_test+0x0000004c8767)

Change-Id: Ib1bb146310bf1f07ba2e1317c66d421906b11794
Reviewed-on: http://review.couchbase.org/63242
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
ns-codereview pushed a commit that referenced this pull request Jul 6, 2016
Context: FileMgr/BlockCache

If a FileMgr's shutdown and freeFunc were racing, ensure the
blockCache operations are serialized. Also is during freeFunc
no BlockCacheManager's instance is available, the file's blocks
needn't be freed, as they already would've been cleaned out as
part of BlockCacheManager's destroyInstance.

12:37:16 WARNING: ThreadSanitizer: data race (pid=159237)
12:37:16   Write of size 8 at 0x7d380000ddc0 by thread T10 (mutexes: write M8, write M11, write M15):
12:37:16     #0 operator delete(void*) <null> (fdb_functional_test+0x000000462d2b)
12:37:16     #1 BlockCacheManager::destroyInstance() /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:1325 (fdb_functional_test+0x0000004f0239)
12:37:16     #2 FileMgr::shutdown() /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1866 (fdb_functional_test+0x00000050dcfe)
12:37:16     #3 fdb_shutdown /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7867 (fdb_functional_test+0x00000052c5ff)
12:37:16     #4 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2015 (fdb_functional_test+0x0000004d3c1e)
12:37:16
12:37:16   Previous read of size 8 at 0x7d380000ddc0 by thread T11 (mutexes: write M1209917129374096872):
12:37:16     #0 BlockCacheManager::prepareDeallocationForFileBlockCache(FileBlockCache*) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_iterator.h:729 (fdb_functional_test+0x0000004edd00)
12:37:16     #1 BlockCacheManager::removeFile(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:1240 (fdb_functional_test+0x0000004efb99)
12:37:16     #2 FileMgr::freeFunc(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1756 (fdb_functional_test+0x00000050a9a3)
12:37:16     #3 FileMgr::close(FileMgr*, bool, char const*, ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1657 (fdb_functional_test+0x00000050d7c5)
12:37:16     #4 _fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7294 (fdb_functional_test+0x00000051edaf)
12:37:16     #5 _fdb_close_root /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7268 (fdb_functional_test+0x00000051e57a)
12:37:16     #6 fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7226 (fdb_functional_test+0x00000052a924)
12:37:16     #7 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2012 (fdb_functional_test+0x0000004d3bc7)

Change-Id: I6046675df18dfb985472a64e6192a2f13770ac92
Reviewed-on: http://review.couchbase.org/65453
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: buildbot <[email protected]>
ns-codereview pushed a commit that referenced this pull request Jul 12, 2016
frame #6: 0x0000000100009910 fdb_functional_test`basic_test() +
22080 at fdb_functional_test.cc:260
frame #7: 0x0000000100061214 fdb_functional_test`main + 20 at
fdb_functional_test.cc:5174

and

frame #5: 0x00000001003d872e
libclang_rt.asan_osx_dynamic.dylib`__asan_report_load4 + 46
frame #6: 0x0000000100021066
iterator_functional_test`iterator_complete_test(insert_opt=0,
        delete_opt=0) + 29654 at iterator_functional_test.cc:1206
frame #7: 0x0000000100060e00 iterator_functional_test`main +
80 at iterator_functional_test.cc:4124

Change-Id: I704b05cdea57ee1e425e7129891abe2828141eb0
Reviewed-on: http://review.couchbase.org/65663
Reviewed-by: abhinav dangeti <[email protected]>
Tested-by: buildbot <[email protected]>
ns-codereview pushed a commit that referenced this pull request Jul 14, 2016
17:00:16 Direct leak of 136 byte(s) in 1 object(s) allocated from:
17:00:16     #0 0x4ec732 in operator new(unsigned long) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/compact_functional_test+0x4ec732)
17:00:16     #1 0x5d2ff2 in Superblock::readLatest(ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/superblock.cc:207:28
17:00:16     #2 0x561101 in FileMgr::loadSuperBlock(ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:877:22
17:00:16     #3 0x561101 in FileMgr::destroyFile(std::string, FileMgrConfig*, std::unordered_set<std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> >*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:2824
17:00:16     #4 0x593906 in fdb_destroy /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:7496:14
17:00:16     #5 0x4ff443 in compaction_daemon_test(unsigned long) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:1962:14
17:00:16     #6 0x5102a6 in main /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:3701:5
17:00:16     #7 0x2ac02298376c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226

Change-Id: I243a939bbfafcdb82fa3e268e78a1001a1122a5f
Reviewed-on: http://review.couchbase.org/65794
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
ns-codereview pushed a commit that referenced this pull request Jul 14, 2016
Context:
- e2espec.cc
- compact_functional_test.cc

17:00:16 Direct leak of 9600000 byte(s) in 100000 object(s) allocated from:
17:00:16     #0 0x4cd42b in calloc (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/compact_functional_test+0x4cd42b)
17:00:16     #1 0x595308 in fdb_get_all_snap_markers /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:7809:38
17:00:16     #2 0x50c16b in compaction_cb_get(FdbFileHandle*, unsigned int, char const*, fdb_doc_struct*, unsigned long, unsigned long, void*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:3104:9
17:00:16     #3 0x58c26d in _fdb_compact_move_docs(FdbKvsHandle*, FileMgr*, HBTrie*, BTree*, HBTrie*, BTree*, BTree*, DocioHandle*, BTreeBlkHandle*, unsigned long*, bool) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:5299:36
17:00:16     #4 0x58668f in _fdb_compact_file(FdbKvsHandle*, FileMgr*, BTreeBlkHandle*, DocioHandle*, HBTrie*, HBTrie*, BTree*, BTree*, unsigned long, bool) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:6923:14
17:00:16     #5 0x584ff9 in fdb_compact_file /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:6799:14
17:00:16     #6 0x591d39 in _fdb_compact(FdbFileHandle*, char const*, unsigned long, bool, fdb_encryption_key const*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:7165:14
17:00:16     #7 0x50bc28 in compact_with_snapshot_open_test() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:3164:7
17:00:16     #8 0x51023c in main /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:3678:5
17:00:16     #9 0x2ac02298376c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226

Change-Id: Ieb0a01da70b9681be82f8dbc7e381e46bf4865f3
Reviewed-on: http://review.couchbase.org/65793
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 19, 2016
16:45:42 ==68667==ERROR: AddressSanitizer: heap-use-after-free on address 0x61f0000088c0 at pc 0x0000005452bb bp 0x7fffdf556050 sp 0x7fffdf556048
16:45:42 READ of size 8 at 0x61f0000088c0 thread T0
16:45:42     #0 0x5452ba in FileMgr::getNewFile() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.h:636:16
16:45:42     couchbase#1 0x5452ba in FileMgr::updateFilePointers() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:1528
16:45:42     couchbase#2 0x5452ba in FileMgr::close(FileMgr*, bool, char const*, ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:1677
16:45:42     couchbase#3 0x569bc3 in _fdb_close /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:7434:10
16:45:42     couchbase#4 0x5b3961 in _fdb_kvs_close(FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/kv_instance.cc:1470:10
16:45:42     couchbase#5 0x5b3961 in fdb_kvs_close /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/kv_instance.cc:1537
16:45:42     couchbase#6 0x4f9323 in FileHandlePool::~FileHandlePool() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:129:26
16:45:42     couchbase#7 0x4f94ed in FileHandlePool::~FileHandlePool() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:124:31
16:45:42     couchbase#8 0x4f56de in test_writes_on_kv_stores_with_compaction(unsigned short, int) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:815:5
16:45:42     couchbase#9 0x4f5f9a in main /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:880:5
16:45:42     couchbase#10 0x2b069543776c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
16:45:42     couchbase#11 0x447558 in _start (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/usecase/usecase_test+0x447558)
16:45:42
16:45:42 0x61f0000088c0 is located 2624 bytes inside of 3064-byte region [0x61f000007e80,0x61f000008a78)
16:45:42 freed by thread T47 here:
16:45:42     #0 0x4edf82 in operator delete(void*) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/usecase/usecase_test+0x4edf82)
16:45:42     couchbase#1 0x541095 in FileMgr::freeFunc(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:1758:5
16:45:42     couchbase#2 0x525c7c in CompactorThread::run() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/compactor.cc:398:17
16:45:42     couchbase#3 0x524de8 in launch_compactor_thread(void*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/compactor.cc:261:9
16:45:42     couchbase#4 0x2b06941a4e99 in start_thread /build/buildd/eglibc-2.15/nptl/pthread_create.c:308

Change-Id: Ifb5eb2255953b569891ebb7e59f36d902dad1152
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 19, 2016
16:45:42 ==68667==ERROR: AddressSanitizer: heap-use-after-free on address 0x61f0000088c0 at pc 0x0000005452bb bp 0x7fffdf556050 sp 0x7fffdf556048
16:45:42 READ of size 8 at 0x61f0000088c0 thread T0
16:45:42     #0 0x5452ba in FileMgr::getNewFile() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.h:636:16
16:45:42     couchbase#1 0x5452ba in FileMgr::updateFilePointers() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:1528
16:45:42     couchbase#2 0x5452ba in FileMgr::close(FileMgr*, bool, char const*, ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:1677
16:45:42     couchbase#3 0x569bc3 in _fdb_close /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:7434:10
16:45:42     couchbase#4 0x5b3961 in _fdb_kvs_close(FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/kv_instance.cc:1470:10
16:45:42     couchbase#5 0x5b3961 in fdb_kvs_close /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/kv_instance.cc:1537
16:45:42     couchbase#6 0x4f9323 in FileHandlePool::~FileHandlePool() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:129:26
16:45:42     couchbase#7 0x4f94ed in FileHandlePool::~FileHandlePool() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:124:31
16:45:42     couchbase#8 0x4f56de in test_writes_on_kv_stores_with_compaction(unsigned short, int) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:815:5
16:45:42     couchbase#9 0x4f5f9a in main /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:880:5
16:45:42     couchbase#10 0x2b069543776c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
16:45:42     couchbase#11 0x447558 in _start (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/usecase/usecase_test+0x447558)
16:45:42
16:45:42 0x61f0000088c0 is located 2624 bytes inside of 3064-byte region [0x61f000007e80,0x61f000008a78)
16:45:42 freed by thread T47 here:
16:45:42     #0 0x4edf82 in operator delete(void*) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/usecase/usecase_test+0x4edf82)
16:45:42     couchbase#1 0x541095 in FileMgr::freeFunc(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:1758:5
16:45:42     couchbase#2 0x525c7c in CompactorThread::run() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/compactor.cc:398:17
16:45:42     couchbase#3 0x524de8 in launch_compactor_thread(void*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/compactor.cc:261:9
16:45:42     couchbase#4 0x2b06941a4e99 in start_thread /build/buildd/eglibc-2.15/nptl/pthread_create.c:308

Change-Id: Ifb5eb2255953b569891ebb7e59f36d902dad1152
ns-codereview pushed a commit that referenced this pull request Jul 20, 2016
Address sanitizer fires a warning for this anomaly testcase,
so disabling running the test under address sanitizer for now.

18:55:29 ==129795==ERROR: AddressSanitizer failed to deallocate 0x2000 (8192) bytes at address 0x625000ee2100
18:55:29 ==129795==AddressSanitizer CHECK failed: /tmp/buildd/llvm-toolchain-3.6-3.6.2~svn240577/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc:136 "(("unable to unmap" && 0)) != (0)" (0x0, 0x0)
18:55:29     #0 0x4d5ce4 in __asan::AsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4d5ce4)
18:55:29     #1 0x4dc661 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4dc661)
18:55:29     #2 0x4e4fc1 in __sanitizer::UnmapOrDie(void*, unsigned long) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4e4fc1)
18:55:29     #3 0x4e5c0f in __sanitizer::UnsetAlternateSignalStack() (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4e5c0f)
18:55:29     #4 0x4d704f in __asan::AsanThread::Destroy() (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4d704f)
18:55:29     #5 0x2b876342ec82 in __nptl_deallocate_tsd /build/buildd/eglibc-2.15/nptl/pthread_create.c:156
18:55:29     #6 0x2b876342eea7 in start_thread /build/buildd/eglibc-2.15/nptl/pthread_create.c:315
18:55:29     #7 0x2b876479338c in clone /build/buildd/eglibc-2.15/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:112

Change-Id: I5c6aaab6e1bf534b3ad5f63656acb88782edcb6e
Reviewed-on: http://review.couchbase.org/66003
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 26, 2016
While updating the prevFile pointer of the next file in
the chain, update the pointer iff the next file points
to the current file.

16:45:42 ==68667==ERROR: AddressSanitizer: heap-use-after-free on address 0x61f0000088c0 at pc 0x0000005452bb bp 0x7fffdf556050 sp 0x7fffdf556048
16:45:42 READ of size 8 at 0x61f0000088c0 thread T0
16:45:42     #0 0x5452ba in FileMgr::getNewFile() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.h:636:16
16:45:42     couchbase#1 0x5452ba in FileMgr::updateFilePointers() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:1528
16:45:42     couchbase#2 0x5452ba in FileMgr::close(FileMgr*, bool, char const*, ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:1677
16:45:42     couchbase#3 0x569bc3 in _fdb_close /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:7434:10
16:45:42     couchbase#4 0x5b3961 in _fdb_kvs_close(FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/kv_instance.cc:1470:10
16:45:42     couchbase#5 0x5b3961 in fdb_kvs_close /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/kv_instance.cc:1537
16:45:42     couchbase#6 0x4f9323 in FileHandlePool::~FileHandlePool() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:129:26
16:45:42     couchbase#7 0x4f94ed in FileHandlePool::~FileHandlePool() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:124:31
16:45:42     couchbase#8 0x4f56de in test_writes_on_kv_stores_with_compaction(unsigned short, int) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:815:5
16:45:42     couchbase#9 0x4f5f9a in main /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/usecase/usecase_test.cc:880:5
16:45:42     couchbase#10 0x2b069543776c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
16:45:42     couchbase#11 0x447558 in _start (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/usecase/usecase_test+0x447558)
16:45:42
16:45:42 0x61f0000088c0 is located 2624 bytes inside of 3064-byte region [0x61f000007e80,0x61f000008a78)
16:45:42 freed by thread T47 here:
16:45:42     #0 0x4edf82 in operator delete(void*) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/usecase/usecase_test+0x4edf82)
16:45:42     couchbase#1 0x541095 in FileMgr::freeFunc(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:1758:5
16:45:42     couchbase#2 0x525c7c in CompactorThread::run() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/compactor.cc:398:17
16:45:42     couchbase#3 0x524de8 in launch_compactor_thread(void*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/compactor.cc:261:9
16:45:42     couchbase#4 0x2b06941a4e99 in start_thread /build/buildd/eglibc-2.15/nptl/pthread_create.c:308

Change-Id: Ifb5eb2255953b569891ebb7e59f36d902dad1152
abhinavdangeti pushed a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
This change makes sure that the background flusher shouldn't access
log_callback field in openfiles_elem direclty without grabbing the
lock.

18:25:18 WARNING: ThreadSanitizer: data race (pid=55378)
18:25:18   Write of size 8 at 0x7d6400016cc0 by main thread (mutexes: write M234):
18:25:18     #0 bgflusher_register_file crtstuff.c (libforestdb.so+0x0000000180c4)
18:25:18     couchbase#1 _fdb_open /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:1918 (libforestdb.so+0x000000029d76)
18:25:18     couchbase#2 _fdb_kvs_open crtstuff.c (libforestdb.so+0x000000053ad1)
18:25:18     couchbase#3 fdb_kvs_open <null> (libforestdb.so+0x000000054820)
18:25:18     couchbase#4 ForestKVStore::getKvsHandle(unsigned short, handleType) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:618 (ep-engine_kvstore_test+0x0000004f74bd)
18:25:18     couchbase#5 ForestKVStore::readVBState(unsigned short) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:224 (ep-engine_kvstore_test+0x0000004f49d9)
18:25:18     couchbase#6 ForestKVStore::ForestKVStore(KVStoreConfig&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:135 (ep-engine_kvstore_test+0x0000004f40c4)
18:25:18     couchbase#7 KVStoreFactory::create(KVStoreConfig&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/kvstore.cc:54 (ep-engine_kvstore_test+0x0000004cb480)
18:25:18     couchbase#8 basic_kvstore_test(std::string&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:114 (ep-engine_kvstore_test+0x0000004c679a)
18:25:18     couchbase#9 main /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:183 (ep-engine_kvstore_test+0x0000004c8634)
18:25:18
18:25:18   Previous read of size 8 at 0x7d6400016cc0 by thread T5:
18:25:18     #0 bgflusher_thread(void*) /home/couchbase/.ccache/tmp/bgflusher.tmp.8b44f18711b3.238821.ii (libforestdb.so+0x000000017d26)
18:25:18
18:25:18   Location is heap block of size 1248 at 0x7d6400016800 allocated by main thread:
18:25:18     #0 calloc <null> (ep-engine_kvstore_test+0x00000046079c)
18:25:18     couchbase#1 bgflusher_register_file crtstuff.c (libforestdb.so+0x0000000180dc)
18:25:18     couchbase#2 _fdb_open /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:1918 (libforestdb.so+0x000000029d76)
18:25:18     couchbase#3 fdb_open /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:642 (libforestdb.so+0x0000000279c6)
18:25:18     couchbase#4 ForestKVStore::ForestKVStore(KVStoreConfig&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:105 (ep-engine_kvstore_test+0x0000004f3599)
18:25:18     couchbase#5 KVStoreFactory::create(KVStoreConfig&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/kvstore.cc:54 (ep-engine_kvstore_test+0x0000004cb480)
18:25:18     couchbase#6 basic_kvstore_test(std::string&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:114 (ep-engine_kvstore_test+0x0000004c679a)
18:25:18     couchbase#7 main /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:183 (ep-engine_kvstore_test+0x0000004c8634)
18:25:18
18:25:18   Mutex M234 (0x7fee334665e8) created at:
18:25:18     #0 pthread_mutex_init <null> (ep-engine_kvstore_test+0x000000465770)
18:25:18     couchbase#1 bgflusher_init crtstuff.c (libforestdb.so+0x000000017a51)
18:25:18     couchbase#2 fdb_init /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:576 (libforestdb.so+0x0000000277c1)
18:25:18     couchbase#3 ForestKVStore::initForestDb() /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:34 (ep-engine_kvstore_test+0x0000004f2ae6)
18:25:18     couchbase#4 ForestKVStore::ForestKVStore(KVStoreConfig&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:103 (ep-engine_kvstore_test+0x0000004f355b)
18:25:18     couchbase#5 KVStoreFactory::create(KVStoreConfig&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/kvstore.cc:54 (ep-engine_kvstore_test+0x0000004cb480)
18:25:18     couchbase#6 basic_kvstore_test(std::string&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:114 (ep-engine_kvstore_test+0x0000004c679a)
18:25:18     couchbase#7 main /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:183 (ep-engine_kvstore_test+0x0000004c8634)
18:25:18
18:25:18   Thread T5 (tid=55391, running) created by main thread at:
18:25:18     #0 pthread_create <null> (ep-engine_kvstore_test+0x000000464341)
18:25:18     couchbase#1 bgflusher_init crtstuff.c (libforestdb.so+0x000000017b47)
18:25:18     couchbase#2 fdb_init /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/forestdb/src/forestdb.cc:576 (libforestdb.so+0x0000000277c1)
18:25:18     couchbase#3 ForestKVStore::initForestDb() /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:34 (ep-engine_kvstore_test+0x0000004f2ae6)
18:25:18     couchbase#4 ForestKVStore::ForestKVStore(KVStoreConfig&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/forest-kvstore/forest-kvstore.cc:103 (ep-engine_kvstore_test+0x0000004f355b)
18:25:18     couchbase#5 KVStoreFactory::create(KVStoreConfig&, bool) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/src/kvstore.cc:54 (ep-engine_kvstore_test+0x0000004cb480)
18:25:18     couchbase#6 basic_kvstore_test(std::string&) /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:114 (ep-engine_kvstore_test+0x0000004c679a)
18:25:18     couchbase#7 main /home/couchbase/jenkins/workspace/ep-engine-threadsanitizer-master/ep-engine/tests/module_tests/kvstore_test.cc:183 (ep-engine_kvstore_test+0x0000004c8634)

Change-Id: I34c97f3ea6c6e728847fa4e4919b6e0069c2ec4f
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
11:02:03 WARNING: ThreadSanitizer: data race (pid=108225)
11:02:03   Write of size 8 at 0x000001571768 by thread T14 (mutexes: write M57456, write M57552, write M14):
11:02:03     #0 _bcache_alloc_freeblock() /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:293 (fdb_functional_test+0x0000004e5a89)
11:02:03     couchbase#1 filemgr_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1989 (fdb_functional_test+0x000000501a8b)
11:02:03     couchbase#2 _docio_read_through_buffer(docio_handle*, unsigned long, err_log_callback*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:691 (fdb_functional_test+0x0000004faa70)
11:02:03     couchbase#3 docio_read_doc /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:1212 (fdb_functional_test+0x0000004fbb6f)
11:02:03     couchbase#4 fdb_kvs_header_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1123 (fdb_functional_test+0x00000053261c)
11:02:03     couchbase#5 _fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:1954 (fdb_functional_test+0x00000050ac08)
11:02:03     couchbase#6 fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:782 (fdb_functional_test+0x0000005090ba)
11:02:03     couchbase#7 _worker_thread(void*) crtstuff.c (fdb_functional_test+0x0000004d184b)
11:02:03
11:02:03   Previous read of size 8 at 0x000001571768 by thread T19:
11:02:03     #0 bcache_get_num_free_blocks /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:1410 (fdb_functional_test+0x0000004e7d64)
11:02:03     couchbase#1 _filemgr_prefetch_thread(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:612 (fdb_functional_test+0x0000004fe4da)

Change-Id: Id7344ae6a13f97fb3bc6f8ed9140d1788e78fe72
Reviewed-on: http://review.couchbase.org/62377
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: buildbot <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
In compaction scenario, before a file is freed, the
pointer to it held by a previous file and the pointer
to it held by a new file will need to be updated.

In the case of multiple files being present, and more than one
file has been redirected to the current file, the new_file pointers
of all those files will need to be updated in case the current file
is deleted.

10:59:36 WARNING: ThreadSanitizer: heap-use-after-free (pid=108627)
10:59:36   Read of size 1 at 0x7d640001f558 by main thread (mutexes: write M14, write M7597):
10:59:36     #0 filemgr_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1451 (iterator_functional_test+0x000000504b5f)
10:59:36     couchbase#1 _fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7203 (iterator_functional_test+0x0000005123bb)
10:59:36     couchbase#2 _fdb_close_root /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7174 (iterator_functional_test+0x000000511854)
10:59:36     couchbase#3 fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7135 (iterator_functional_test+0x00000051ee5a)
10:59:36     couchbase#4 iterator_concurrent_compaction() crtstuff.c (iterator_functional_test+0x0000004e2078)
10:59:36     couchbase#5 main crtstuff.c (iterator_functional_test+0x0000004e4e1d)
10:59:36
10:59:36   Previous write of size 8 at 0x7d640001f558 by main thread:
10:59:36     #0 free <null> (iterator_functional_test+0x00000046136b)
10:59:36     couchbase#1 filemgr_free_func /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1657 (iterator_functional_test+0x000000502a9f)
10:59:36     couchbase#2 filemgr_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1479 (iterator_functional_test+0x000000504ea4)
10:59:36     couchbase#3 _fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7203 (iterator_functional_test+0x0000005123bb)
10:59:36     couchbase#4 fdb_kvs_close_all /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1789 (iterator_functional_test+0x000000537922)
10:59:36     couchbase#5 _fdb_close_root /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7157 (iterator_functional_test+0x0000005117d3)
10:59:36     couchbase#6 fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7135 (iterator_functional_test+0x00000051ee5a)
10:59:36     couchbase#7 iterator_concurrent_compaction() crtstuff.c (iterator_functional_test+0x0000004e2078)
10:59:36     couchbase#8 main crtstuff.c (iterator_functional_test+0x0000004e4e1d)

Change-Id: Iacf78604494026b33085663146d2adfda319fff9
Reviewed-on: http://review.couchbase.org/62449
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
11:38:53 WARNING: ThreadSanitizer: data race (pid=116143)
11:38:53   Write of size 1 at 0x7d2000217641 by thread T27 (mutexes: write M702774, write M703325, write M702832):
11:38:53     #0 _wal_flush(filemgr*, void*, fdb_status (*)(void*, wal_item*, avl_tree*, avl_tree*), unsigned long (*)(void*, wal_item*), void (*)(void*, avl_tree*, avl_tree*), void (*)(filemgr*, avl_tree*), wal_flush_items*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:1628 (mvcc_functional_test+0x000000546a9d)
11:38:53     couchbase#1 wal_flush /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:1724 (mvcc_functional_test+0x0000005466a1)
11:38:53     couchbase#2 _fdb_compact_file(_fdb_kvs_handle*, filemgr*, btreeblk_handle*, docio_handle*, hbtrie*, hbtrie*, btree*, btree*, unsigned long, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:6691 (mvcc_functional_test+0x00000051a281)
11:38:53     couchbase#3 fdb_compact_file /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:6644 (mvcc_functional_test+0x00000051a05f)
11:38:53     couchbase#4 compactor_thread(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/compactor.cc:396 (mvcc_functional_test+0x0000004fb8a2)
11:38:53
11:38:53   Previous read of size 1 at 0x7d2000217641 by main thread (mutexes: write M702835):
11:38:53     #0 __wal_cmp_byseq(wal_item*, wal_item*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:120 (mvcc_functional_test+0x00000054d046)
11:38:53     couchbase#1 _wal_cmp_byseq(avl_node*, avl_node*, void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:143 (mvcc_functional_test+0x00000054cf26)
11:38:53     couchbase#2 avl_search /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/avltree.cc:325 (mvcc_functional_test+0x0000004e7df4)
11:38:53     couchbase#3 _wal_find(_fdb_transaction*, filemgr*, unsigned long, _fdb_key_cmp_info*, snap_handle*, fdb_doc_struct*, unsigned long*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:978 (mvcc_functional_test+0x0000005451ed)
11:38:53     couchbase#4 wal_find_kv_id /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:1041 (mvcc_functional_test+0x0000005455ec)
11:38:53     couchbase#5 fdb_get_byseq /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:3179 (mvcc_functional_test+0x000000516c64)
11:38:53     couchbase#6 auto_compaction_snapshots_test() crtstuff.c (mvcc_functional_test+0x0000004e235b)
11:38:53     couchbase#7 main crtstuff.c (mvcc_functional_test+0x0000004e7542)

Change-Id: Ib935696426aedb88465e61941ba2bf44faee2ad3
Reviewed-on: http://review.couchbase.org/62797
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: buildbot <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
Change-Id: I98a94cd9cc7acfce02bdf15b67e0cf9ace95e0e0
14:15:16 WARNING: ThreadSanitizer: data race (pid=68020)
14:15:16   Write of size 8 at 0x7d6400163b28 by thread T15 (mutexes: write M13):
14:15:16     #0 _fname_create(filemgr*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:812 (e2etest+0x0000004d5c60)
14:15:16     couchbase#1 bcache_write /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:1062 (e2etest+0x0000004d526d)
14:15:16     couchbase#2 filemgr_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:2043 (e2etest+0x0000004f1a9b)
14:15:16     couchbase#3 _docio_read_through_buffer(docio_handle*, unsigned long, err_log_callback*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:691 (e2etest+0x0000004ea770)
14:15:16     couchbase#4 docio_read_doc /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:1212 (e2etest+0x0000004eb86f)
14:15:16     couchbase#5 fdb_kvs_header_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1123 (e2etest+0x000000522e4c)
14:15:16     couchbase#6 _fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:1720 (e2etest+0x0000004fa137)
14:15:16     couchbase#7 fdb_check_file_reopen /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:2800 (e2etest+0x0000004fcb77)
14:15:16     couchbase#8 fdb_set /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:3607 (e2etest+0x00000050372f)
14:15:16     couchbase#9 fdb_set_kv <null> (e2etest+0x0000004d2a29)
14:15:16     couchbase#10 update_thread(void*) crtstuff.c (e2etest+0x0000004c9d26)
14:15:16
14:15:16   Previous read of size 8 at 0x7d6400163b28 by thread T14:
14:15:16     #0 bcache_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:924 (e2etest+0x0000004d4ddf)
14:15:16     couchbase#1 filemgr_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1976 (e2etest+0x0000004f14f1)
14:15:16     couchbase#2 _docio_read_through_buffer(docio_handle*, unsigned long, err_log_callback*, bool) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:691 (e2etest+0x0000004ea770)
14:15:16     couchbase#3 docio_read_doc /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:1212 (e2etest+0x0000004eb86f)
14:15:16     couchbase#4 fdb_kvs_header_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1123 (e2etest+0x000000522e4c)
14:15:16     couchbase#5 _fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:1720 (e2etest+0x0000004fa137)
14:15:16     couchbase#6 fdb_check_file_reopen /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:2800 (e2etest+0x0000004fcb77)
14:15:16     couchbase#7 fdb_set /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:3607 (e2etest+0x00000050372f)
14:15:16     couchbase#8 fdb_set_kv <null> (e2etest+0x0000004d2a29)
14:15:16     couchbase#9 e2e_fdb_set_person crtstuff.c (e2etest+0x0000004d0392)
14:15:16     couchbase#10 seq_writer_thread(void*) crtstuff.c (e2etest+0x0000004c9c62)
Reviewed-on: http://review.couchbase.org/62820
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
11:25:22 WARNING: ThreadSanitizer: heap-use-after-free (pid=115558)
11:25:22   Read of size 8 at 0x7d040000f308 by main thread:
11:25:22     #0 _cmp_double(void*, unsigned long, void*, unsigned long) /home/couchbase/.ccache/tmp/fdb_functi.tmp.140592e37b0d.95346.ii (fdb_functional_test+0x0000004d4dcc)
11:25:22     couchbase#1 __wal_cmp_bykey(wal_item_header*, wal_item_header*, void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:80 (fdb_functional_test+0x000000548483)
11:25:22     couchbase#2 _snap_cmp_bykey(avl_node*, avl_node*, void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:116 (fdb_functional_test+0x000000547ffc)
11:25:22     couchbase#3 avl_search_greater /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/avltree.cc:351 (fdb_functional_test+0x0000004e2f96)
11:25:22     couchbase#4 wal_itr_search_greater /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/wal.cc:2179 (fdb_functional_test+0x000000542d42)
11:25:22     couchbase#5 fdb_iterator_init <null> (fdb_functional_test+0x00000052b345)
11:25:22     couchbase#6 custom_compare_primitive_test() crtstuff.c (fdb_functional_test+0x0000004d4692)
11:25:22     couchbase#7 main crtstuff.c (fdb_functional_test+0x0000004e258a)
11:25:22
11:25:22   Previous write of size 8 at 0x7d040000f308 by main thread (mutexes: write M672581587812037744):
11:25:22     #0 free <null> (fdb_functional_test+0x00000046144b)
11:25:22     couchbase#1 free_docio_object /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/docio.cc:1067 (fdb_functional_test+0x0000004fb29a)
11:25:22     couchbase#2 fdb_kvs_header_read /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/kv_instance.cc:1134 (fdb_functional_test+0x000000532fba)
11:25:22     couchbase#3 _fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:1980 (fdb_functional_test+0x00000050b393)
11:25:22     couchbase#4 fdb_open /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:807 (fdb_functional_test+0x0000005096ea)
11:25:22     couchbase#5 seq_tree_exception_test() crtstuff.c (fdb_functional_test+0x0000004cde92)
11:25:22     couchbase#6 main crtstuff.c (fdb_functional_test+0x0000004e257b)

Change-Id: I9191bc57e00fefadb0f31fee7cc48c3ad04cf43b
Reviewed-on: http://review.couchbase.org/62875
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: Chiyoung Seo <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
[1] WARNING: ThreadSanitizer: data race (pid=16606)
  Write of size 8 at 0x7d100020c0a8 by thread T2 (mutexes: write M10, write M15):
    #0 list_remove /home/abhinav/couchbaseTS/forestdb/src/list.cc:89 (fdb_functional_test+0x000000624716)
    couchbase#1 bcache_shutdown /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:1605 (fdb_functional_test+0x00000050dc8f)
    couchbase#2 filemgr_shutdown /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1758 (fdb_functional_test+0x0000005769ff)
    couchbase#3 fdb_shutdown /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7851 (fdb_functional_test+0x0000005c69a0)
    couchbase#4 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2011 (fdb_functional_test+0x0000004d81f1)

  Previous write of size 8 at 0x7d100020c0a8 by thread T1 (mutexes: write M23078079052191248, write M17):
    #0 list_push_front /home/abhinav/couchbaseTS/forestdb/src/list.cc:34 (fdb_functional_test+0x000000623dfe)
    couchbase#1 _bcache_release_freeblock(bcache_item*) /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:315 (fdb_functional_test+0x000000505972)
    couchbase#2 bcache_remove_clean_blocks /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:1324 (fdb_functional_test+0x00000050b627)
    couchbase#3 filemgr_free_func /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1614 (fdb_functional_test+0x00000056ad37)
    couchbase#4 filemgr_close /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1567 (fdb_functional_test+0x00000057568b)
    couchbase#5 _fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7299 (fdb_functional_test+0x0000005a309a)
    couchbase#6 _fdb_close_root /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7270 (fdb_functional_test+0x0000005a197c)
    couchbase#7 fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7228 (fdb_functional_test+0x0000005c2d2f)
    couchbase#8 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2008 (fdb_functional_test+0x0000004d8132)

[2] WARNING: ThreadSanitizer: data race (pid=3464)
  Write of size 8 at 0x7db000000000 by thread T2 (mutexes: write M10, write M15):
    #0 free <null> (fdb_functional_test+0x000000456f1b)
    couchbase#1 bcache_shutdown /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:1620 (fdb_functional_test+0x0000004de9d6)
    couchbase#2 filemgr_shutdown /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1758 (fdb_functional_test+0x0000004f989b)
    couchbase#3 fdb_shutdown /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7851 (fdb_functional_test+0x0000005152af)
    couchbase#4 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2011 (fdb_functional_test+0x0000004c87be)

  Previous write of size 8 at 0x7db000000000 by thread T1 (mutexes: write M18):
    #0 _fname_try_free(fnamedic_item*) /home/abhinav/couchbaseTS/forestdb/src/blockcache.cc:852 (fdb_functional_test+0x0000004ddccb)
    couchbase#1 filemgr_free_func /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1615 (fdb_functional_test+0x0000004f676f)
    couchbase#2 filemgr_close /home/abhinav/couchbaseTS/forestdb/src/filemgr.cc:1567 (fdb_functional_test+0x0000004f927b)
    couchbase#3 _fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7299 (fdb_functional_test+0x000000506bcb)
    couchbase#4 _fdb_close_root /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7270 (fdb_functional_test+0x000000506070)
    couchbase#5 fdb_close /home/abhinav/couchbaseTS/forestdb/src/forestdb.cc:7228 (fdb_functional_test+0x000000513a5a)
    couchbase#6 multi_thread_client_shutdown(void*) /home/abhinav/couchbaseTS/forestdb/tests/functional/fdb_functional_test.cc:2008 (fdb_functional_test+0x0000004c8767)

Change-Id: Ib1bb146310bf1f07ba2e1317c66d421906b11794
Reviewed-on: http://review.couchbase.org/63242
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
Context: FileMgr/BlockCache

If a FileMgr's shutdown and freeFunc were racing, ensure the
blockCache operations are serialized. Also is during freeFunc
no BlockCacheManager's instance is available, the file's blocks
needn't be freed, as they already would've been cleaned out as
part of BlockCacheManager's destroyInstance.

12:37:16 WARNING: ThreadSanitizer: data race (pid=159237)
12:37:16   Write of size 8 at 0x7d380000ddc0 by thread T10 (mutexes: write M8, write M11, write M15):
12:37:16     #0 operator delete(void*) <null> (fdb_functional_test+0x000000462d2b)
12:37:16     couchbase#1 BlockCacheManager::destroyInstance() /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:1325 (fdb_functional_test+0x0000004f0239)
12:37:16     couchbase#2 FileMgr::shutdown() /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1866 (fdb_functional_test+0x00000050dcfe)
12:37:16     couchbase#3 fdb_shutdown /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7867 (fdb_functional_test+0x00000052c5ff)
12:37:16     couchbase#4 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2015 (fdb_functional_test+0x0000004d3c1e)
12:37:16
12:37:16   Previous read of size 8 at 0x7d380000ddc0 by thread T11 (mutexes: write M1209917129374096872):
12:37:16     #0 BlockCacheManager::prepareDeallocationForFileBlockCache(FileBlockCache*) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_iterator.h:729 (fdb_functional_test+0x0000004edd00)
12:37:16     couchbase#1 BlockCacheManager::removeFile(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/blockcache.cc:1240 (fdb_functional_test+0x0000004efb99)
12:37:16     couchbase#2 FileMgr::freeFunc(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1756 (fdb_functional_test+0x00000050a9a3)
12:37:16     couchbase#3 FileMgr::close(FileMgr*, bool, char const*, ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/filemgr.cc:1657 (fdb_functional_test+0x00000050d7c5)
12:37:16     couchbase#4 _fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7294 (fdb_functional_test+0x00000051edaf)
12:37:16     couchbase#5 _fdb_close_root /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7268 (fdb_functional_test+0x00000051e57a)
12:37:16     couchbase#6 fdb_close /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/src/forestdb.cc:7226 (fdb_functional_test+0x00000052a924)
12:37:16     couchbase#7 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-threadsanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2012 (fdb_functional_test+0x0000004d3bc7)

Change-Id: I6046675df18dfb985472a64e6192a2f13770ac92
Reviewed-on: http://review.couchbase.org/65453
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: buildbot <[email protected]>
abhinavdangeti pushed a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
frame couchbase#6: 0x0000000100009910 fdb_functional_test`basic_test() +
22080 at fdb_functional_test.cc:260
frame couchbase#7: 0x0000000100061214 fdb_functional_test`main + 20 at
fdb_functional_test.cc:5174

and

frame couchbase#5: 0x00000001003d872e
libclang_rt.asan_osx_dynamic.dylib`__asan_report_load4 + 46
frame couchbase#6: 0x0000000100021066
iterator_functional_test`iterator_complete_test(insert_opt=0,
        delete_opt=0) + 29654 at iterator_functional_test.cc:1206
frame couchbase#7: 0x0000000100060e00 iterator_functional_test`main +
80 at iterator_functional_test.cc:4124

Change-Id: I704b05cdea57ee1e425e7129891abe2828141eb0
Reviewed-on: http://review.couchbase.org/65663
Reviewed-by: abhinav dangeti <[email protected]>
Tested-by: buildbot <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
17:00:16 Direct leak of 136 byte(s) in 1 object(s) allocated from:
17:00:16     #0 0x4ec732 in operator new(unsigned long) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/compact_functional_test+0x4ec732)
17:00:16     couchbase#1 0x5d2ff2 in Superblock::readLatest(ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/superblock.cc:207:28
17:00:16     couchbase#2 0x561101 in FileMgr::loadSuperBlock(ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:877:22
17:00:16     couchbase#3 0x561101 in FileMgr::destroyFile(std::string, FileMgrConfig*, std::unordered_set<std::string, std::hash<std::string>, std::equal_to<std::string>, std::allocator<std::string> >*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/filemgr.cc:2824
17:00:16     couchbase#4 0x593906 in fdb_destroy /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:7496:14
17:00:16     couchbase#5 0x4ff443 in compaction_daemon_test(unsigned long) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:1962:14
17:00:16     couchbase#6 0x5102a6 in main /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:3701:5
17:00:16     couchbase#7 0x2ac02298376c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226

Change-Id: I243a939bbfafcdb82fa3e268e78a1001a1122a5f
Reviewed-on: http://review.couchbase.org/65794
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
Context:
- e2espec.cc
- compact_functional_test.cc

17:00:16 Direct leak of 9600000 byte(s) in 100000 object(s) allocated from:
17:00:16     #0 0x4cd42b in calloc (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/compact_functional_test+0x4cd42b)
17:00:16     couchbase#1 0x595308 in fdb_get_all_snap_markers /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:7809:38
17:00:16     couchbase#2 0x50c16b in compaction_cb_get(FdbFileHandle*, unsigned int, char const*, fdb_doc_struct*, unsigned long, unsigned long, void*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:3104:9
17:00:16     couchbase#3 0x58c26d in _fdb_compact_move_docs(FdbKvsHandle*, FileMgr*, HBTrie*, BTree*, HBTrie*, BTree*, BTree*, DocioHandle*, BTreeBlkHandle*, unsigned long*, bool) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:5299:36
17:00:16     couchbase#4 0x58668f in _fdb_compact_file(FdbKvsHandle*, FileMgr*, BTreeBlkHandle*, DocioHandle*, HBTrie*, HBTrie*, BTree*, BTree*, unsigned long, bool) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:6923:14
17:00:16     couchbase#5 0x584ff9 in fdb_compact_file /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:6799:14
17:00:16     couchbase#6 0x591d39 in _fdb_compact(FdbFileHandle*, char const*, unsigned long, bool, fdb_encryption_key const*) /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/src/forestdb.cc:7165:14
17:00:16     couchbase#7 0x50bc28 in compact_with_snapshot_open_test() /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:3164:7
17:00:16     couchbase#8 0x51023c in main /home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/forestdb/tests/functional/compact_functional_test.cc:3678:5
17:00:16     couchbase#9 0x2ac02298376c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226

Change-Id: Ieb0a01da70b9681be82f8dbc7e381e46bf4865f3
Reviewed-on: http://review.couchbase.org/65793
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
abhinavdangeti added a commit to abhinavdangeti/forestdb that referenced this pull request Jul 30, 2016
Address sanitizer fires a warning for this anomaly testcase,
so disabling running the test under address sanitizer for now.

18:55:29 ==129795==ERROR: AddressSanitizer failed to deallocate 0x2000 (8192) bytes at address 0x625000ee2100
18:55:29 ==129795==AddressSanitizer CHECK failed: /tmp/buildd/llvm-toolchain-3.6-3.6.2~svn240577/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc:136 "(("unable to unmap" && 0)) != (0)" (0x0, 0x0)
18:55:29     #0 0x4d5ce4 in __asan::AsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4d5ce4)
18:55:29     couchbase#1 0x4dc661 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4dc661)
18:55:29     couchbase#2 0x4e4fc1 in __sanitizer::UnmapOrDie(void*, unsigned long) (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4e4fc1)
18:55:29     couchbase#3 0x4e5c0f in __sanitizer::UnsetAlternateSignalStack() (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4e5c0f)
18:55:29     couchbase#4 0x4d704f in __asan::AsanThread::Destroy() (/home/couchbase/jenkins/workspace/forestdb-addresssanitizer-master/build/forestdb/tests/functional/fdb_functional_test+0x4d704f)
18:55:29     couchbase#5 0x2b876342ec82 in __nptl_deallocate_tsd /build/buildd/eglibc-2.15/nptl/pthread_create.c:156
18:55:29     couchbase#6 0x2b876342eea7 in start_thread /build/buildd/eglibc-2.15/nptl/pthread_create.c:315
18:55:29     couchbase#7 0x2b876479338c in clone /build/buildd/eglibc-2.15/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:112

Change-Id: I5c6aaab6e1bf534b3ad5f63656acb88782edcb6e
Reviewed-on: http://review.couchbase.org/66003
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
ns-codereview pushed a commit that referenced this pull request Aug 25, 2016
Change-Id: I15d7fea7bf6dfe7409a258aa484866b7f1cf2bcc
13:09:58 WARNING: ThreadSanitizer: data race (pid=103894)
13:09:58   Read of size 1 at 0x7d100047b1a0 by thread T19:
13:09:58     #0 fdb_kvs_find_cmp_chunk /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/kv_instance.cc:255 (compact_functional_test+0x0000005521bf)
13:09:58     #1 HBTrie::_insert(void*, int, void*, void*, unsigned char) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/hbtrie.cc:208 (compact_functional_test+0x000000544b6e)
13:09:58     #2 HBTrie::insert(void*, int, void*, void*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/hbtrie.cc:1452 (compact_functional_test+0x000000544937)
13:09:58     #3 WalFlushCallbacks::flushItem(void*, wal_item*, avl_tree*, avl_tree*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/forestdb.cc:5291 (compact_functional_test+0x00000053d016)
13:09:58     #4 Wal::_wal_do_flush(wal_item*, fdb_status (*)(void*, wal_item*, avl_tree*, avl_tree*), void*, avl_tree*, avl_tree*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/wal.cc:1705 (compact_functional_test+0x00000056df7b)
13:09:58     #5 Wal::flushByCompactor_Wal(void*, fdb_status (*)(void*, wal_item*, avl_tree*, avl_tree*), unsigned long (*)(void*, wal_item*), void (*)(void*, avl_tree*, avl_tree*), void (*)(FileMgr*, avl_tree*), wal_flush_items*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/wal.cc:1923 (compact_functional_test+0x00000056e321)
13:09:58     #6 Compaction::copyDocs(FdbKvsHandle*, unsigned long*, bool) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/compaction.cc:1341 (compact_functional_test+0x0000004ff2b3)
13:09:58     #7 Compaction::compactFile(FdbFileHandle*, char const*, bool, unsigned long, bool, fdb_encryption_key const*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/compaction.cc:306 (compact_functional_test+0x0000004fc749)
13:09:58     #8 CompactionTask::run() /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/compactor.cc:374 (compact_functional_test+0x00000050660f)
13:09:58     #9 ExecutorThread::run() crtstuff.c (compact_functional_test+0x00000051ac29)
13:09:58     #10 launch_executor_thread(void*) /home/couchbase/.ccache/tmp/executorth.tmp.37a3ca72313b.96623.ii (compact_functional_test+0x00000051a8d5)
13:09:58
13:09:58   Previous write of size 1 at 0x7d100047b1a0 by main thread (mutexes: write M20407327, write M20420268):
13:09:58     #0 FdbEngine::createKvs(FdbKvsHandle*, char const*, fdb_kvs_config*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/kv_instance.cc:2129 (compact_functional_test+0x000000556a39)
13:09:58     #1 FdbEngine::openKvs(FdbKvsHandle*, fdb_config*, fdb_kvs_config*, FileMgr*, char const*, char const*, FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/kv_instance.cc:1803 (compact_functional_test+0x0000005562ba)
13:09:58     #2 FdbEngine::openKvs(FdbFileHandle*, FdbKvsHandle**, char const*, fdb_kvs_config*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/kv_instance.cc:1747 (compact_functional_test+0x000000554c29)
13:09:58     #3 fdb_kvs_open /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/src/kv_instance.cc:1065 (compact_functional_test+0x000000554780)
13:09:58     #4 auto_compaction_with_custom_cmp_function() /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/tests/functional/compact_functional_test.cc:2125 (compact_functional_test+0x0000004d671f)
13:09:58     #5 main /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-unstable/forestdb/tests/functional/compact_functional_test.cc:3704 (compact_functional_test+0x0000004e032e)
Reviewed-on: http://review.couchbase.org/67042
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
ns-codereview pushed a commit that referenced this pull request Aug 26, 2016
This is to avoid racing in setting KvHeader which could potentially
cause leaks.

11:58:40 Direct leak of 56 byte(s) in 1 object(s) allocated from:
11:58:40     #0 0x4eead2 in operator new(unsigned long) (/home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/build/forestdb/tests/usecase/usecase_test+0x4eead2)
11:58:40     #1 0x5db423 in _fdb_kvs_header_create /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/kv_instance.cc:282:28
11:58:40     #2 0x599fb4 in FdbEngine::openFdb(FdbKvsHandle*, char const*, fdb_filename_mode_t, fdb_config const*) /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/forestdb.cc:2302:25
11:58:40     #3 0x5a582b in fdb_check_file_reopen /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/forestdb.cc:1175:18
11:58:40     #4 0x5aa1dc in FdbEngine::set(FdbKvsHandle*, fdb_doc_struct*) /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/forestdb.cc:3341:10
11:58:40     #5 0x506741 in FdbEngine::setKeyValue(FdbKvsHandle*, void const*, unsigned long, void const*, unsigned long) /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/api_wrapper.cc:165:10
11:58:40     #6 0x4f6acd in test_writes_on_kv_stores_with_compaction(unsigned short, int) /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/tests/usecase/usecase_test.cc:988:22
11:58:40     #7 0x4fc60a in main /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/tests/usecase/usecase_test.cc:1262:5
11:58:40     #8 0x2b3f217b376c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226

Change-Id: Ic23d15d8e95bfea5945fe3c4a3051bc491f21820
Reviewed-on: http://review.couchbase.org/67078
Tested-by: buildbot <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
ns-codereview pushed a commit that referenced this pull request Aug 31, 2016
This is to avoid racing in setting KvHeader which could potentially
cause leaks.

11:58:40 Direct leak of 56 byte(s) in 1 object(s) allocated from:
11:58:40     #0 0x4eead2 in operator new(unsigned long) (/home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/build/forestdb/tests/usecase/usecase_test+0x4eead2)
11:58:40     #1 0x5db423 in _fdb_kvs_header_create /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/kv_instance.cc:282:28
11:58:40     #2 0x599fb4 in FdbEngine::openFdb(FdbKvsHandle*, char const*, fdb_filename_mode_t, fdb_config const*) /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/forestdb.cc:2302:25
11:58:40     #3 0x5a582b in fdb_check_file_reopen /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/forestdb.cc:1175:18
11:58:40     #4 0x5aa1dc in FdbEngine::set(FdbKvsHandle*, fdb_doc_struct*) /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/forestdb.cc:3341:10
11:58:40     #5 0x506741 in FdbEngine::setKeyValue(FdbKvsHandle*, void const*, unsigned long, void const*, unsigned long) /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/src/api_wrapper.cc:165:10
11:58:40     #6 0x4f6acd in test_writes_on_kv_stores_with_compaction(unsigned short, int) /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/tests/usecase/usecase_test.cc:988:22
11:58:40     #7 0x4fc60a in main /home/couchbase/jenkins/workspace/forestdb-address_sanitizer-unstable/forestdb/tests/usecase/usecase_test.cc:1262:5
11:58:40     #8 0x2b3f217b376c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226

(Reviewed-on: http://review.couchbase.org/67078)

Change-Id: Ic23d15d8e95bfea5945fe3c4a3051bc491f21820
Reviewed-on: http://review.couchbase.org/67173
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: buildbot <[email protected]>
ns-codereview pushed a commit that referenced this pull request Sep 22, 2016
If there are open taskables, fail executor pool's shutdown.

10:34:37 WARNING: ThreadSanitizer: data race (pid=16877)
10:34:37   Read of size 8 at 0x7d4c0001bfd8 by thread T3 (mutexes: write M1730):
10:34:37     #0 ExecutorPool::shutdown() /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_tree.h:736 (fdb_functional_test+0x00000051d75b)
10:34:37     #1 FdbEngine::destroyInstance() /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:2015 (fdb_functional_test+0x000000547a35)
10:34:37     #2 fdb_shutdown /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:1900 (fdb_functional_test+0x0000005479af)
10:34:37     #3 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2036 (fdb_functional_test+0x0000004d5a1e)
10:34:37
10:34:37   Previous write of size 8 at 0x7d4c0001bfd8 by thread T4 (mutexes: write M64224):
10:34:37     #0 std::_Rb_tree<void*, void*, std::_Identity<void*>, std::less<void*>, std::allocator<void*> >::_M_erase_aux(std::_Rb_tree_const_iterator<void*>, std::_Rb_tree_const_iterator<void*>) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_tree.h:909 (fdb_functional_test+0x0000005231b9)
10:34:37     #1 ExecutorPool::_unregisterTaskable(Taskable&, bool) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_set.h:621 (fdb_functional_test+0x00000051d899)
10:34:37     #2 ExecutorPool::unregisterTaskable(Taskable&, bool) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/executorpool.cc:662 (fdb_functional_test+0x000000522ec4)
10:34:37     #3 FileMgr::freeFunc(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/filemgr.cc:1745 (fdb_functional_test+0x00000052b404)
10:34:37     #4 FileMgr::close(FileMgr*, bool, char const*, ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/filemgr.cc:1667 (fdb_functional_test+0x00000052d1b3)
10:34:37     #5 FdbEngine::closeKVHandle(FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:5058 (fdb_functional_test+0x00000054124b)
10:34:37     #6 FdbEngine::closeRootHandle(FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:5029 (fdb_functional_test+0x000000549c98)
10:34:37     #7 FdbEngine::closeFile(FdbFileHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:4987 (fdb_functional_test+0x0000005455e9)
10:34:37     #8 fdb_close /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:1769 (fdb_functional_test+0x000000545503)
10:34:37     #9 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2033 (fdb_functional_test+0x0000004d59c7)

Change-Id: I3758ed5955c1e70e1600eecde5caad8cf31fd944
Reviewed-on: http://review.couchbase.org/67862
Reviewed-by: Sundararaman Sridharan <[email protected]>
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: buildbot <[email protected]>
ns-codereview pushed a commit that referenced this pull request Sep 22, 2016
If there are open taskables, fail executor pool's shutdown.

10:34:37 WARNING: ThreadSanitizer: data race (pid=16877)
10:34:37   Read of size 8 at 0x7d4c0001bfd8 by thread T3 (mutexes: write M1730):
10:34:37     #0 ExecutorPool::shutdown() /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_tree.h:736 (fdb_functional_test+0x00000051d75b)
10:34:37     #1 FdbEngine::destroyInstance() /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:2015 (fdb_functional_test+0x000000547a35)
10:34:37     #2 fdb_shutdown /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:1900 (fdb_functional_test+0x0000005479af)
10:34:37     #3 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2036 (fdb_functional_test+0x0000004d5a1e)
10:34:37
10:34:37   Previous write of size 8 at 0x7d4c0001bfd8 by thread T4 (mutexes: write M64224):
10:34:37     #0 std::_Rb_tree<void*, void*, std::_Identity<void*>, std::less<void*>, std::allocator<void*> >::_M_erase_aux(std::_Rb_tree_const_iterator<void*>, std::_Rb_tree_const_iterator<void*>) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_tree.h:909 (fdb_functional_test+0x0000005231b9)
10:34:37     #1 ExecutorPool::_unregisterTaskable(Taskable&, bool) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_set.h:621 (fdb_functional_test+0x00000051d899)
10:34:37     #2 ExecutorPool::unregisterTaskable(Taskable&, bool) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/executorpool.cc:662 (fdb_functional_test+0x000000522ec4)
10:34:37     #3 FileMgr::freeFunc(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/filemgr.cc:1745 (fdb_functional_test+0x00000052b404)
10:34:37     #4 FileMgr::close(FileMgr*, bool, char const*, ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/filemgr.cc:1667 (fdb_functional_test+0x00000052d1b3)
10:34:37     #5 FdbEngine::closeKVHandle(FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:5058 (fdb_functional_test+0x00000054124b)
10:34:37     #6 FdbEngine::closeRootHandle(FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:5029 (fdb_functional_test+0x000000549c98)
10:34:37     #7 FdbEngine::closeFile(FdbFileHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:4987 (fdb_functional_test+0x0000005455e9)
10:34:37     #8 fdb_close /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:1769 (fdb_functional_test+0x000000545503)
10:34:37     #9 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2033 (fdb_functional_test+0x0000004d59c7)

(Reviewed-on: http://review.couchbase.org/67862)

Change-Id: I3758ed5955c1e70e1600eecde5caad8cf31fd944
Reviewed-on: http://review.couchbase.org/67906
Reviewed-by: Chiyoung Seo <[email protected]>
Tested-by: buildbot <[email protected]>
ns-codereview pushed a commit that referenced this pull request Aug 19, 2021
As reported by ASan:

    ==25822==ERROR: LeakSanitizer: detected memory leaks

    Direct leak of 721424 byte(s) in 11 object(s) allocated from:
	#0 0xffff9f6d18bc in malloc (/opt/gcc-10.2.0/lib64/libasan.so.6+0x9d8bc)
	#1 0x4b0284 in hash_init ../forestdb/src/hash.cc:32
	#2 0x40e254 in _fname_create ../forestdb/src/blockcache.cc:806
	#3 0x410698 in bcache_write ../forestdb/src/blockcache.cc:1063
	#4 0x457dc8 in filemgr_read ../forestdb/src/filemgr.cc:2147
	#5 0x4474d4 in _docio_read_through_buffer(docio_handle*, unsigned long, err_log_callback*, bool) ../forestdb/src/docio.cc:711
	#6 0x4474d4 in _docio_read_length ../forestdb/src/docio.cc:803
	#7 0x44c8c0 in docio_read_doc ../forestdb/src/docio.cc:1242
	#8 0x4d6a3c in fdb_kvs_header_read ../forestdb/src/kv_instance.cc:1142
	#9 0x485b94 in _fdb_open ../forestdb/src/forestdb.cc:2076
	#10 0x4adfbc in _fdb_recover_compaction(_fdb_kvs_handle*, char const*) ../forestdb/src/forestdb.cc:585
	#11 0x4869ac in _fdb_open ../forestdb/src/forestdb.cc:2237
	#12 0x486f74 in fdb_open ../forestdb/src/forestdb.cc:848
	#13 0x525da0 in compact_rename_to_original_test() ../forestdb/tests/functional/compact_functional_test.cc:525
	#14 0x546878 in main ../forestdb/tests/functional/compact_functional_test.cc:3904
	#15 0xffff9e4e2ce0 in __libc_start_main (/lib64/libc.so.6+0x1fce0)
	#16 0x404c4c  (/home/couchbase/server/build/forestdb/tests/functional/compact_functional_test+0x404c4c)

    Direct leak of 721424 byte(s) in 11 object(s) allocated from:
	#0 0xffff9f6d18bc in malloc (/opt/gcc-10.2.0/lib64/libasan.so.6+0x9d8bc)
	#1 0x4b0284 in hash_init ../forestdb/src/hash.cc:32
	#2 0x40e254 in _fname_create ../forestdb/src/blockcache.cc:806
	#3 0x410698 in bcache_write ../forestdb/src/blockcache.cc:1063
	#4 0x457dc8 in filemgr_read ../forestdb/src/filemgr.cc:2147
	#5 0x4474d4 in _docio_read_through_buffer(docio_handle*, unsigned long, err_log_callback*, bool) ../forestdb/src/docio.cc:711
	#6 0x4474d4 in _docio_read_length ../forestdb/src/docio.cc:803
	#7 0x44c8c0 in docio_read_doc ../forestdb/src/docio.cc:1242
	#8 0x4d6a3c in fdb_kvs_header_read ../forestdb/src/kv_instance.cc:1142
	#9 0x485b94 in _fdb_open ../forestdb/src/forestdb.cc:2076
	#10 0x486f74 in fdb_open ../forestdb/src/forestdb.cc:848
	#11 0x524460 in compaction_delete_old_test() ../forestdb/tests/functional/compact_functional_test.cc:345
	#12 0x546874 in main ../forestdb/tests/functional/compact_functional_test.cc:3903
	#13 0xffff9e4e2ce0 in __libc_start_main (/lib64/libc.so.6+0x1fce0)
	#14 0x404c4c  (/home/couchbase/server/build/forestdb/tests/functional/compact_functional_test+0x404c4c)

Change-Id: I6179654af9da764d4ceed04fb2702ca84f43c874
Reviewed-on: http://review.couchbase.org/c/forestdb/+/159308
Tested-by: Build Bot <[email protected]>
Reviewed-by: Trond Norbye <[email protected]>
greensky00 added a commit to greensky00/forestdb that referenced this pull request Sep 5, 2023
* If the start key of an iterator is greater then the skipped common
prefix of a B+tree, HB+trie iterator should go back to the parent
B+tree and pick the next entry of it.

* The same thing should be done for backward move.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants