Commit e96a9f5
MB-43028: [1/2] Make overhead tracking safe at VBucket destruction
Cherry-picks http://review.couchbase.org/c/kv_engine/+/141492
Note: This patch is cherry-picked as the issue it resolves prevents
clean forward-merging of a change _earlier_ in mad-hatter history.
Merging http://review.couchbase.org/c/kv_engine/+/136495 into master
uncovered santizer issues (mad-hatter CV runs an older Clang and did
not identify these issues).
This patch resolves one of these issues, before the above patch may
be merged to master.
WARNING: ThreadSanitizer: heap-use-after-free (pid=73551)
Read of size 8 at 0x7b5800000310 by main thread:
#0 operator() ../kv_engine/engines/ep/src/ephemeral_bucket.cc:301 (libep.so+0x00000034705f)
#1 std::_Function_handler<void (long), EphemeralBucket::makeVBucket(...>::_M_invoke(std::_Any_data const&, long&&)
#3 ~Checkpoint ../kv_engine/engines/ep/src/checkpoint.cc:228 (libep.so+0x00000019dc97)
#10 ~CheckpointManager ../kv_engine/engines/ep/src/checkpoint_manager.h:73 (libep.so+0x00000042f782)
...
#13 ~VBucket ../kv_engine/engines/ep/src/vbucket.cc:286 (libep.so+0x00000041689a)
During VBucket destruction, the CheckpointManager member, and any
remaining Checkpoints it holds are destroyed. This can trigger the
memOverheadChangedCallback, as destroying Checkpoints reduces the
memory overhead.
This was unsafe, as the state member had already been destroyed as it
is declared later in VBucket.
Move the CheckpointManager to be declared after state, so it is
destroyed first.
Change-Id: I0a34d3a11cd053f18f3168d6fbbb9dc974bbd2fc
Reviewed-on: http://review.couchbase.org/c/kv_engine/+/141492
Reviewed-by: Dave Rigby <[email protected]>
Tested-by: Build Bot <[email protected]>
Well-Formed: Build Bot <[email protected]>
Reviewed-on: http://review.couchbase.org/c/kv_engine/+/1414981 parent 02c3f75 commit e96a9f5
2 files changed
+17
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | 193 | | |
202 | 194 | | |
203 | 195 | | |
| |||
220 | 212 | | |
221 | 213 | | |
222 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
837 | 837 | | |
838 | 838 | | |
839 | 839 | | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | 840 | | |
844 | 841 | | |
845 | 842 | | |
| |||
2442 | 2439 | | |
2443 | 2440 | | |
2444 | 2441 | | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
2445 | 2451 | | |
2446 | 2452 | | |
2447 | 2453 | | |
| |||
0 commit comments