diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-01-02 18:16:57 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-01-02 18:16:57 +1100 |
commit | ccf7a52cff7630020aff1f367c6f988c93e06166 (patch) | |
tree | 3528b1f0b7f0290340be11b00d937b34ad9dea69 /src/conn | |
parent | 9dd055a6e523f60fa5635595890e5d87b6c95f70 (diff) | |
download | mongo-ccf7a52cff7630020aff1f367c6f988c93e06166.tar.gz |
If we fail to open a data handle when the session already has a reference, don't decrement the reference count.
This fixes accesses after freeing data handles detected by valgrind and clang address sanitizer in test/fops.
refs #827, 816.
Diffstat (limited to 'src/conn')
-rw-r--r-- | src/conn/conn_dhandle.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/conn/conn_dhandle.c b/src/conn/conn_dhandle.c index fb82d22e3cd..ce7b1d81199 100644 --- a/src/conn/conn_dhandle.c +++ b/src/conn/conn_dhandle.c @@ -339,7 +339,16 @@ __conn_btree_open( if (0) { err: F_CLR(btree, WT_BTREE_SPECIAL_FLAGS); - WT_TRET(__wt_conn_btree_close(session, 1)); + /* + * If the open failed, close the handle. If there was no + * reference to the handle in this session, we incremented the + * session reference count, so decrement it here. Otherwise, + * just close the handle without decrementing. + */ + if (!LF_ISSET(WT_DHANDLE_HAVE_REF)) + WT_TRET(__wt_conn_btree_close(session, 1)); + else if (F_ISSET(dhandle, WT_DHANDLE_OPEN)) + WT_TRET(__wt_conn_btree_sync_and_close(session)); } return (ret); |