]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
fix ASAN for DeleteFilesInRange test case rocksdb-5.9.2 v5.9.2
authorAndrew Kryczka <andrewkr@fb.com>
Thu, 7 Dec 2017 19:07:44 +0000 (11:07 -0800)
committerAndrew Kryczka <andrewkr@fb.com>
Thu, 7 Dec 2017 19:47:51 +0000 (11:47 -0800)
Summary:
error message was

```
==3095==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffd18216c40 at pc 0x0000005edda1 bp 0x7ffd18215550 sp 0x7ffd18214d00
...
Address 0x7ffd18216c40 is located in stack of thread T0 at offset 1952 in frame
     #0 internal_repo_rocksdb/db_compaction_test.cc:1520 rocksdb::DBCompactionTest_DeleteFileRangeFileEndpointsOverlapBug_Test::TestBody()
```

It was unsafe to have slices referring to the temporary string objects' buffers, as those strings were destroyed before the slices were used. Fixed it by assigning the strings returned by `Key()` to local variables.
Closes https://github.com/facebook/rocksdb/pull/3238

Differential Revision: D6507864

Pulled By: ajkr

fbshipit-source-id: dd07de1a0070c6748c1ab4f3d7bd31f9a81889d0

db/db_compaction_test.cc

index 13c30995ffeec82cdfb4a94a17e901345b6d3f06..6458519d0868009454eb3e4484c62371648778df 100644 (file)
@@ -1563,8 +1563,8 @@ TEST_F(DBCompactionTest, DeleteFileRangeFileEndpointsOverlapBug) {
 
   // Verify `DeleteFilesInRange` can't drop only file 0 which would cause
   // "1 -> vals[0]" to reappear.
-  Slice begin = Key(0);
-  Slice end = Key(1);
+  std::string begin_str = Key(0), end_str = Key(1);
+  Slice begin = begin_str, end = end_str;
   ASSERT_OK(DeleteFilesInRange(db_, db_->DefaultColumnFamily(), &begin, &end));
   ASSERT_EQ(vals[1], Get(Key(1)));