Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV when running multilple cassandra-stress with user profile and smp #25

Closed
slivne opened this issue Jul 19, 2015 · 45 comments
Closed

Comments

@slivne
Copy link
Contributor

slivne commented Jul 19, 2015

I get the following when running multiple cassandra-stress with user profile (which means that we are doing create_table viq cql and not via thrift

on monster

sudo rm -Rf /data2/shlomi/tmp/* ; sudo gdb --args build/release/seastar --datadir /data2/shlomi/tmp --commitlog-directory /data2/shlomi/tmp --smp 6 --network-stack native --dpdk-pmd --dhcp 0 --host-ipv4-addr 192.168.10.101 --netmask-ipv4-addr 255.255.255.0 --seed-provider-parameters seeds=127.0.0.1

on godzilla
sleep 1
taskset -c 1,17 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 2,18 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 3,19 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 4,20 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 5,21 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 6,22 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 7,23 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 8,24 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 9,25 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 10,26 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 11,27 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 12,28 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &
taskset -c 13,29 ~/cassandra/tools/bin/cassandra-stress user duration=2m profile=./urchin-qa-internal/simple_test_no_compression.yaml 'ops(insert=1)' -mode cql3 native -rate threads=16 -node 192.168.10.101 &

before the SIGSEGV there are some
WARNING: exceptional future ignored of type 'query::no_such_column': keyspace_name
WARNING: exceptional future ignored of type 'query::no_such_column': keyspace_name
WARNING: exceptional future ignored of type 'query::no_such_column': keyspace_name

which I'll try to catch and open a new bug for them

[Switching to Thread 0x7ffde39fb700 (LWP 42787)]
find (__k=..., this=0x6040004b16c8) at /usr/include/c++/4.9.2/bits/hashtable.h:1321
1321          __node_type* __p = _M_find_node(__n, __k, __code);
Missing separate debuginfos, use: debuginfo-install boost-date-time-1.55.0-8.fc21.x86_64 boost-filesystem-1.55.0-8.fc21.x86_64 boost-program-options-1.55.0-8.fc21.x86_64 boost-system-1.55.0-8.fc21.x86_64 boost-test-1.55.0-8.fc21.x86_64 boost-thread-1.55.0-8.fc21.x86_64 cryptopp-5.6.2-5.fc21.x86_64 hwloc-libs-1.10.0-1.fc21.x86_64 jsoncpp-0.6.0-0.14.rc2.fc21.x86_64 keyutils-libs-1.5.9-4.fc21.x86_64 krb5-libs-1.12.2-15.fc21.x86_64 libaio-0.3.110-4.fc21.x86_64 libcom_err-1.42.12-4.fc21.x86_64 libgcc-4.9.2-6.fc21.x86_64 libpciaccess-0.13.3-0.3.fc21.x86_64 libselinux-2.3-9.fc21.x86_64 libstdc++-4.9.2-6.fc21.x86_64 libtool-ltdl-2.4.2-31.fc21.x86_64 libxml2-2.9.1-7.fc21.x86_64 lz4-r128-2.fc21.x86_64 numactl-libs-2.0.9-4.fc21.x86_64 openssl-libs-1.0.1k-6.fc21.x86_64 pcre-8.35-11.fc21.x86_64 snappy-1.1.1-3.fc21.x86_64 thrift-0.9.1-13.fc21.1.x86_64 xz-libs-5.1.2-14alpha.fc21.x86_64 yaml-cpp-0.5.1-4.fc21.x86_64 zlib-1.2.8-7.fc21.x86_64
(gdb) where
#0  find (__k=..., this=0x6040004b16c8) at /usr/include/c++/4.9.2/bits/hashtable.h:1321
#1  find (__x=..., this=0x6040004b16c8) at /usr/include/c++/4.9.2/bits/unordered_map.h:578
#2  query::result_set_row::get_data_value (this=0x6040004b16c0, column_name=...) at ./query-result-set.hh:46
#3  0x0000000000556379 in get<basic_sstring<char, unsigned int, 15u> > (column_name=..., this=<optimized out>) at ./query-result-set.hh:56
#4  query::result_set_row::get_nonnull<basic_sstring<char, unsigned int, 15u> > (this=<optimized out>, column_name=...) at ./query-result-set.hh:64
#5  0x00000000007ddd5d in db::legacy_schema_tables::create_table_from_table_row_and_column_rows (builder=..., table_row=..., serialized_column_definitions=...) at db/legacy_schema_tables.cc:1240
#6  0x00000000007e24ef in _ZZN6futureIISt4pairIK13basic_sstringIcjLj15EE13lw_shared_ptrIN5query10result_setEEEEE4thenIS4_IK6schemaEZN2db20legacy_schema_tables27create_table_from_table_rowERN7service13storage_proxyERKNS5_14result_set_rowEEUlT_E_ZNS9_4thenISN_S_IISD_EEEET0_OT_EUlO12future_stateIIS8_EEE_EEN8futurizeISR_E4typeEOSQ_OT1_ENUlOSM_E_clISU_EEDaSS_ () at db/legacy_schema_tables.cc:1197
#7  0x00000000009528a2 in reactor::run_tasks (this=this@entry=0x604000119000, tasks=..., quota=<optimized out>) at core/reactor.cc:1025
#8  0x0000000000974db4 in reactor::run (this=0x604000119000) at core/reactor.cc:1122
#9  0x000000000097b7a6 in smp::<lambda()>::operator()(void) const (__closure=0x60000005fe00) at core/reactor.cc:1772
#10 0x00000000009539c9 in dpdk_thread_adaptor (f=<optimized out>) at core/reactor.cc:1637
#11 0x0000000000be7e13 in eal_thread_loop ()
#12 0x00007ffff425f52a in start_thread () from /lib64/libpthread.so.0
#13 0x00007ffff3f9b22d in clone () from /lib64/libc.so.6
@penberg
Copy link
Contributor

penberg commented Jul 23, 2015

@slivne, this should be fixed by commit ea668b5. Please retest.

@slivne
Copy link
Contributor Author

slivne commented Jul 25, 2015

@penberg with the following head I still get a SIGSEGV

commit 095c2f2920b2dd592fe6b57c5436c0b6163829bc
Merge: 73dfa66 45b4471
Author: Avi Kivity <avi@cloudius-systems.com>
Date:   Sat Jul 25 17:47:40 2015 +0300

    Merge "Fixes for partition_range model" from Tomasz

    "range::is_wrap_around() will not work with current ring_position, because it
    relies on total ordering. Same for range::contains(). Currently ring_position
    is weakly ordered. This series fixes this problem by making ring_position
    totally ordered.

    Another problem fixed by this series is handling of wrap-around ranges. In
    Origin, ]x; x] is treated as a wrap around range covering whole ring."

.
.
.
WARNING: exceptional future ignored of type 'query::no_such_column': keyspace_name
WARNING: exceptional future ignored of type 'query::no_such_column': keyspace_name
WARNING: exceptional future ignored of type 'query::no_such_column': keyspace_name

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffde53fe700 (LWP 12352)]
find (__k=..., this=0x60100066b848) at /usr/include/c++/4.9.2/bits/hashtable.h:1321
1321          __node_type* __p = _M_find_node(__n, __k, __code);
Missing separate debuginfos, use: debuginfo-install boost-filesystem-1.55.0-8.fc21.x86_64 boost-program-options-1.55.0-8.fc21.x86_64 boost-system-1.55.0-8.fc21.x86_64 boost-test-1.55.0-8.fc21.x86_64 boost-thread-1.55.0-8.fc21.x86_64 cryptopp-5.6.2-5.fc21.x86_64 hwloc-libs-1.10.0-1.fc21.x86_64 jsoncpp-0.6.0-0.14.rc2.fc21.x86_64 keyutils-libs-1.5.9-4.fc21.x86_64 krb5-libs-1.12.2-15.fc21.x86_64 libaio-0.3.110-4.fc21.x86_64 libcom_err-1.42.12-4.fc21.x86_64 libgcc-4.9.2-6.fc21.x86_64 libpciaccess-0.13.3-0.3.fc21.x86_64 libselinux-2.3-9.fc21.x86_64 libstdc++-4.9.2-6.fc21.x86_64 libtool-ltdl-2.4.2-31.fc21.x86_64 libxml2-2.9.1-7.fc21.x86_64 lz4-r128-2.fc21.x86_64 numactl-libs-2.0.9-4.fc21.x86_64 openssl-libs-1.0.1k-6.fc21.x86_64 pcre-8.35-11.fc21.x86_64 snappy-1.1.1-3.fc21.x86_64 thrift-0.9.1-13.fc21.1.x86_64 xz-libs-5.1.2-14alpha.fc21.x86_64 yaml-cpp-0.5.1-4.fc21.x86_64 zlib-1.2.8-7.fc21.x86_64
(gdb) where
#0  find (__k=..., this=0x60100066b848) at /usr/include/c++/4.9.2/bits/hashtable.h:1321
#1  find (__x=..., this=0x60100066b848) at /usr/include/c++/4.9.2/bits/unordered_map.h:578
#2  query::result_set_row::get_data_value (this=0x60100066b840, column_name=...) at ./query-result-set.hh:46
#3  0x000000000065c0a9 in get<basic_sstring<char, unsigned int, 15u> > (column_name=..., this=<optimized out>) at ./query-result-set.hh:56
#4  query::result_set_row::get_nonnull<basic_sstring<char, unsigned int, 15u> > (this=<optimized out>, column_name=...) at ./query-result-set.hh:64
#5  0x00000000008f440d in db::legacy_schema_tables::create_table_from_table_row_and_column_rows (builder=..., table_row=..., serialized_column_definitions=...) at db/legacy_schema_tables.cc:1247
#6  0x00000000008f8f9f in _ZZN6futureIISt4pairIK13basic_sstringIcjLj15EE13lw_shared_ptrIN5query10result_setEEEEE4thenIS4_IK6schemaEZN2db20legacy_schema_tables27create_table_from_table_rowERN7service13storage_proxyERKNS5_14result_set_rowEEUlT_E_ZNS9_4thenISN_S_IISD_EEEET0_OT_EUlO12future_stateIIS8_EEE_EEN8futurizeISR_E4typeEOSQ_OT1_ENUlOSM_E_clISU_EEDaSS_ () at db/legacy_schema_tables.cc:1204
#7  0x0000000000440822 in reactor::run_tasks (this=this@entry=0x601000119000, tasks=..., quota=<optimized out>) at core/reactor.cc:1037
#8  0x0000000000463e24 in reactor::run (this=0x601000119000) at core/reactor.cc:1134
#9  0x000000000046a816 in smp::<lambda()>::operator()(void) const (__closure=0x600000097f00) at core/reactor.cc:1784
#10 0x0000000000441949 in dpdk_thread_adaptor (f=<optimized out>) at core/reactor.cc:1649
#11 0x00000000005bf763 in eal_thread_loop ()
#12 0x00007ffff447152a in start_thread () from /lib64/libpthread.so.0
#13 0x00007ffff41ad22d in clone () from /lib64/libc.so.6

@slivne slivne added this to the Beta milestone Jul 26, 2015
@penberg
Copy link
Contributor

penberg commented Jul 27, 2015

@slivne, I am trying to reproduce locally but all I get is this error when I try to run cassandra-stress:

[penberg@nero apache-cassandra-2.1.7]$ tools/bin/cassandra-stress user duration=2m profile=/home/penberg/urchin-qa-internal/simple_test_no_compression.yamlops(insert=1)' -mode cql3 native -rate threads=16
INFO  13:57:27 Using data-center name 'datacenter1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)
INFO  13:57:27 New Cassandra host localhost/127.0.0.1:9042 added
Connected to cluster: Test Cluster
Datatacenter: datacenter1; Host: localhost/127.0.0.1; Rack: rack1
ERROR 13:57:27 Asked to rebuild table KEYSPACE.keyspace2 but I don't know keyspace KEYSPACE
ERROR 13:57:27 Asked to rebuild table TABLE.keyspace2 but I don't know keyspace TABLE
Created schema. Sleeping 1s for propagation.
Sleeping 2s...
Warming up insert with 50000 iterations...
Failed to connect over JMX; not collecting these stats
Generating batches with [1..1] partitions and [0..0] rows (of [1..1] total rows in the partitions)
Exception in thread "main" java.lang.RuntimeException: org.apache.thrift.TApplicationException: sorry, not implemented
    at org.apache.cassandra.stress.StressProfile.getInsert(StressProfile.java:382)
    at org.apache.cassandra.stress.settings.SettingsCommandUser$1.get(SettingsCommandUser.java:82)
    at org.apache.cassandra.stress.settings.SettingsCommandUser$1.get(SettingsCommandUser.java:78)
    at org.apache.cassandra.stress.operations.SampledOpDistributionFactory$1.get(SampledOpDistributionFactory.java:78)
    at org.apache.cassandra.stress.StressAction$Consumer.<init>(StressAction.java:269)
    at org.apache.cassandra.stress.StressAction.run(StressAction.java:204)
    at org.apache.cassandra.stress.StressAction.warmup(StressAction.java:105)
    at org.apache.cassandra.stress.StressAction.run(StressAction.java:61)
    at org.apache.cassandra.stress.Stress.main(Stress.java:109)
Caused by: org.apache.thrift.TApplicationException: sorry, not implemented
    at org.apache.thrift.TApplicationException.read(TApplicationException.java:111)
    at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:71)
    at org.apache.cassandra.thrift.Cassandra$Client.recv_prepare_cql3_query(Cassandra.java:1797)
    at org.apache.cassandra.thrift.Cassandra$Client.prepare_cql3_query(Cassandra.java:1783)
    at org.apache.cassandra.stress.util.SimpleThriftClient.prepare_cql3_query(SimpleThriftClient.java:79)
    at org.apache.cassandra.stress.StressProfile.getInsert(StressProfile.java:378)
    ... 8 more

@slivne
Copy link
Contributor Author

slivne commented Jul 27, 2015

@penberg

Please use the modified cassandra stress available at:
https://github.com/slivne/cassandra update_stress

we do not support prepared cql over thrift - so I had removed it from the cassandra-stress code

@penberg
Copy link
Contributor

penberg commented Jul 28, 2015

@slivne, @pdziepak, how much work is it to support prepared CQL over Thrift? We already have quite a few forks of the Cassandra tools and test suites and it would be good to be able to consolidate them before the beta.

@penberg
Copy link
Contributor

penberg commented Jul 28, 2015

I am not able to reproduce locally with "--smp 2" which is not that surprising. Can you please try to reproduce the issue with the debug build on Godzilla? Please note that commit b3b0d51 might be related to the issue at hand.

@pdziepak
Copy link
Contributor

@penberg There already is my unmerged patchset which adds support for executing "normal" CQL queries over Thrift. That already deals with maintaining proper connection state and translating CQL output to "CQL over Thrift" output. What is lacking to support prepared statements is mostly handling and storing them on server side (the logic is different for CQL over native and CQL over Thrift, the code responsible for the latter is untranslated).

@slivne
Copy link
Contributor Author

slivne commented Jul 28, 2015

currently blocked by #51

On Tue, Jul 28, 2015 at 3:27 PM, Paweł Dziepak notifications@github.com
wrote:

@penberg https://github.com/penberg There already is my unmerged
patchset which adds support for executing "normal" CQL queries over Thrift.
That already deals with maintaining proper connection state and translating
CQL output to "CQL over Thrift" output. What is lacking to support prepared
statements is mostly handling and storing them on server side (the logic is
different for CQL over native and CQL over Thrift, the code responsible for
the latter is untranslated).


Reply to this email directly or view it on GitHub
#25 (comment)
.

@slivne
Copy link
Contributor Author

slivne commented Jul 28, 2015

with #51 fixed

@penberg with debug I am getting the following

executing

sudo rm -Rf /data2/shlomi/tmp/* ; sudo build/debug/scylla --datadir /data2/shlomi/tmp --commitlog-directory /data2/shlomi/tmp --smp 6 --listen-address 192.168.10.101 --seed-provider-parameters seeds=192.168.10.101 --rpc-address 192.168.10.101 --default-log-level debug

CQL server listening on 192.168.10.101:9042 ...
Thrift server listening on 192.168.10.101:9160 ...
Seastar HTTP server listening on 192.168.10.101:10000 ...
WARNING: Not implemented: AUTH
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
WARNING: Not implemented: AUTH
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
WARNING: Not implemented: AUTH
WARNING: Not implemented: AUTH
warning: ignoring event registration
WARNING: Not implemented: AUTH
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
WARNING: Not implemented: AUTH
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
WARNING: Not implemented: VALIDATION
WARNING: Not implemented: VALIDATION
WARNING: Not implemented: VALIDATION
WARNING: Not implemented: VALIDATION
WARNING: Not implemented: VALIDATION
=================================================================
==19932==AddressSanitizer: while reporting a bug found another one.Ignoring.
==19932==ERROR: AddressSanitizer: heap-use-after-free on address 0x60600053b230 at pc 0xf830e3 bp 0x7ffdd13d8210 sp 0x7ffdd13d8200
READ of size 8 at 0x60600053b230 thread T0
==19932==AddressSanitizer: while reporting a bug found another one.Ignoring.
==19932==AddressSanitizer: while reporting a bug found another one.Ignoring.
==19932==AddressSanitizer: while reporting a bug found another one.Ignoring.
    #0 0xf830e2 in std::_Hashtable<basic_sstring<char, unsigned int, 15u>, std::pair<basic_sstring<char, unsigned int, 15u> const, data_value>, std::allocator<std::pair<basic_sstring<char, unsigned int, 15u> const, data_value> >, std::__detail::_Select1st, std::equal_to<basic_sstring<char, unsigned int, 15u> >, std::hash<basic_sstring<char, unsigned int, 15u> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_bucket_index(basic_sstring<char, unsigned int, 15u> const&, unsigned long) const (/home/shlomi/urchin/build/debug/scylla+0xf830e2)

I am not able to run in gdb

I added a pair of printouts at the start,end of db::legacy_schema_tables::create_table_from_table_row_and_... and enabled debug logging to get a bit more info so now I get



WARNING: Not implemented: AUTH
WARNING: Not implemented: AUTH
warning: ignoring event registration
warning: ignoring event registration
WARNING: Not implemented: AUTH
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
WARNING: Not implemented: AUTH
WARNING: Not implemented: AUTH
warning: ignoring event registration
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
WARNING: Not implemented: AUTH
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
 [shard 3] Migration Manager - Create new Keyspace: keyspace2
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Digest.sha1 
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Summary.db 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-CRC.db 
warning: ignoring event registration
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Filter.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Summary.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Statistics.db 
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Filter.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-TOC.txt 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Statistics.db 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-TOC.txt 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Statistics.db 
 [shard 0] Migration Manager - Create new Keyspace: keyspace2
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-TOC.txt 
 [shard 5] Migration Manager - Create new Keyspace: keyspace2
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Statistics.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Summary.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Filter.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Summary.db 
 [shard 4] Migration Manager - Create new table: standard1
 [shard 4] Migration Manager - Create new table: standard1
 [shard 4] Migration Manager - Create new table: standard1
 [shard 2] Migration Manager - Create new table: standard1
WARNING: Not implemented: VALIDATION
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=3478cea9-7cfc-3673-a957-2dec1bd9170d
 [shard 0] Migration Manager - Gossiping my schema version 3478cea9-7cfc-3673-a957-2dec1bd9170d
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-TOC.txt 
 [shard 2] Migration Manager - Create new table: standard1
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Statistics.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Summary.db 
 [shard 4] Migration Manager - Create new table: standard1
 [shard 0] Migration Manager - Create new table: standard1
 [shard 3] Migration Manager - Create new table: standard1
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=8131d18b-36b6-3fec-9ad6-aca5174114cd
 [shard 0] Migration Manager - Gossiping my schema version 8131d18b-36b6-3fec-9ad6-aca5174114cd
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Statistics.db 
 [shard 0] Migration Manager - Create new table: standard1
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Statistics.db 
 [shard 5] Migration Manager - Create new table: standard1
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Summary.db 
WARNING: Not implemented: VALIDATION
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=20d16a36-10ae-3bf7-8e99-5615c856848b
 [shard 0] Migration Manager - Gossiping my schema version 20d16a36-10ae-3bf7-8e99-5615c856848b
 [shard 3] Migration Manager - Create new table: standard1
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Summary.db 
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Digest.sha1 
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Digest.sha1 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Filter.db 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-CRC.db 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-CRC.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Statistics.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Summary.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Summary.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-TOC.txt 
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Filter.db 
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Filter.db 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Statistics.db 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Statistics.db 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Statistics.db 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-TOC.txt 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-TOC.txt 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Filter.db 
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-TOC.txt 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Summary.db 
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-TOC.txt 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Filter.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Summary.db 
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Statistics.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Summary.db 
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Statistics.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Filter.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Filter.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Summary.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Summary.db 
 [shard 0] Migration Manager - Create new table: standard1
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
WARNING: Not implemented: VALIDATION
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=fcd4cf2c-6a0e-373b-adf6-814e24718439
 [shard 0] Migration Manager - Gossiping my schema version fcd4cf2c-6a0e-373b-adf6-814e24718439
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Statistics.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Filter.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Summary.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Summary.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Summary.db 
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows
=================================================================
==23495==ERROR: AddressSanitizer: heap-use-after-free on address 0x6060003d5a50 at pc 0xf830e3 bp 0x7f55f5aeb560 sp 0x7f55f5aeb550
READ of size 8 at 0x6060003d5a50 thread T5
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
==23495==AddressSanitizer: while reporting a bug found another one.Ignoring.
==23495==AddressSanitizer: while reporting a bug found another one.Ignoring.
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
==23495==AddressSanitizer: while reporting a bug found another one.Ignoring.
==23495==AddressSanitizer: while reporting a bug found another one.Ignoring.

so the failure point is in the create table function or maybe something after it and some of the cores have not completed the operation

another run

Start Storage service ...
 [shard 0] database - Populating Keyspace system
 [shard 5] database - Populating Keyspace system
 [shard 2] database - Populating Keyspace system
 [shard 3] database - Populating Keyspace system
 [shard 4] database - Populating Keyspace system
 [shard 1] database - Populating Keyspace system
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
 [shard 2] database - database found file with unknown type system
 [shard 0] database - database found file with unknown type system
 [shard 2] database - database found file with unknown type work0
 [shard 2] database - database found file with unknown type work2
 [shard 0] database - database found file with unknown type work0
 [shard 2] database - database found file with unknown type work5
 [shard 0] database - database found file with unknown type work2
 [shard 1] database - database found file with unknown type system
 [shard 4] database - database found file with unknown type system
 [shard 1] database - database found file with unknown type work0
 [shard 2] database - database found file with unknown type work3
 [shard 0] database - database found file with unknown type work5
 [shard 5] database - database found file with unknown type system
 [shard 3] database - database found file with unknown type system
 [shard 4] database - database found file with unknown type work0
 [shard 3] database - database found file with unknown type work0
 [shard 4] database - database found file with unknown type work2
 [shard 4] database - database found file with unknown type work5
 [shard 0] database - database found file with unknown type work3
 [shard 5] database - database found file with unknown type work0
 [shard 1] database - database found file with unknown type work2
 [shard 5] database - database found file with unknown type work2
 [shard 3] database - database found file with unknown type work2
 [shard 4] database - database found file with unknown type work3
 [shard 0] database - database found file with unknown type work4
 [shard 2] database - database found file with unknown type work4
 [shard 1] database - database found file with unknown type work5
 [shard 2] database - database found file with unknown type work1
 [shard 3] database - database found file with unknown type work5
 [shard 1] database - database found file with unknown type work3
 [shard 0] database - database found file with unknown type work1
 [shard 4] database - database found file with unknown type work4
 [shard 5] database - database found file with unknown type work5
 [shard 4] database - database found file with unknown type work1
 [shard 5] database - database found file with unknown type work3
 [shard 3] database - database found file with unknown type work3
WARNING: closing file in reactor thread during exception recovery
 [shard 1] database - database found file with unknown type work4
 [shard 5] database - database found file with unknown type work4
 [shard 1] database - database found file with unknown type work1
 [shard 3] database - database found file with unknown type work4
 [shard 5] database - database found file with unknown type work1
WARNING: closing file in reactor thread during exception recovery
 [shard 3] database - database found file with unknown type work1
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: closing file in reactor thread during exception recovery
WARNING: Not implemented: VALIDATION
WARNING: Not implemented: INDEXES
 [shard 0] storage_service - Starting up server gossip
Start gossiper service ...
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=3, value=datacenter1
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=4, value=rack1
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=59adb24e-f3cd-3e02-97f0-5b395827453f
 [shard 0] Migration Manager - Gossiping my schema version 59adb24e-f3cd-3e02-97f0-5b395827453f
==23535==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7fef850c8a40; bottom 0x7fef7f9ec000; size: 0x0000056dca40 (91081280)
False positive error reports may follow
For details see http://code.google.com/p/address-sanitizer/issues/detail?id=189
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-Digest.sha1 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-CRC.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-Summary.db 
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-Filter.db 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-Statistics.db 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-TOC.txt 
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-TOC.txt 
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-Statistics.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-Filter.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/local-7ad54392-bcdd-35a6-8417-4e047860b377/la-9-big-Summary.db 
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=13, value=c63af0c6f642ca58;8fe360edf2562dee;c022052cf27e99ed
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - SS::handle_state_bootstrap endpoint=192.168.10.101
 [shard 0] storage_service - endpoint=192.168.10.101, tokens_string=c63af0c6f642ca58;8fe360edf2562dee;c022052cf27e99ed
 [shard 0] storage_service - token=c63af0c6f642ca58
 [shard 0] storage_service - token=8fe360edf2562dee
 [shard 0] storage_service - token=c022052cf27e99ed
 [shard 0] storage_service - Node 192.168.10.101 state jump to normal
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=0, value=NORMAL,TOKENS
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=59adb24e-f3cd-3e02-97f0-5b395827453f
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=3, value=datacenter1
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=4, value=rack1
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=5, value=urchin_1_0
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=8, value=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=11, value=0
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=12, value=3377aea4-ffa6-4aaf-8093-55ffd8810d52
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=13, value=c63af0c6f642ca58;8fe360edf2562dee;c022052cf27e99ed
WARNING: Not implemented: GOSSIP
 [shard 0] storage_service - New node 192.168.10.101 at token 8f e3 60 ed f2 56 2d ee 
 [shard 0] storage_service - New node 192.168.10.101 at token c6 3a f0 c6 f6 42 ca 58 
CQL server listening on 192.168.10.101:9042 ...
Thrift server listening on 192.168.10.101:9160 ...
Seastar HTTP server listening on 192.168.10.101:10000 ...
WARNING: Not implemented: AUTH
WARNING: Not implemented: AUTH
WARNING: Not implemented: AUTH
WARNING: Not implemented: AUTH
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
WARNING: Not implemented: AUTH
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
warning: ignoring event registration
 [shard 1] Migration Manager - Create new Keyspace: keyspace2
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Digest.sha1 
 [shard 1] Migration Manager - Create new Keyspace: keyspace2
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Summary.db 
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Digest.sha1 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-CRC.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Summary.db 
 [shard 2] Migration Manager - Create new Keyspace: keyspace2
 [shard 2] Migration Manager - Create new Keyspace: keyspace2
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Filter.db 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Statistics.db 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-TOC.txt 
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-TOC.txt 
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Statistics.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Statistics.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Filter.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Summary.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Filter.db 
 [shard 3] Migration Manager - Create new Keyspace: keyspace2
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Summary.db 
 [shard 2] Migration Manager - Create new Keyspace: keyspace2
 [shard 5] Migration Manager - Create new table: standard1
WARNING: Not implemented: VALIDATION
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=2de5df1f-e0b3-38b9-b328-bc9f66b9a6f8
 [shard 0] Migration Manager - Gossiping my schema version 2de5df1f-e0b3-38b9-b328-bc9f66b9a6f8
 [shard 2] Migration Manager - Create new table: standard1
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Digest.sha1 
 [shard 5] Migration Manager - Create new table: standard1
WARNING: Not implemented: AUTH
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-TOC.txt 
 [shard 4] Migration Manager - Create new table: standard1
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Statistics.db 
 [shard 2] Migration Manager - Create new table: standard1
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Summary.db 
 [shard 0] Migration Manager - Create new table: standard1
 [shard 2] Migration Manager - Create new table: standard1
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=ff13741a-aa35-3cd4-bb8f-3b495624534a
 [shard 0] Migration Manager - Gossiping my schema version ff13741a-aa35-3cd4-bb8f-3b495624534a
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Statistics.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-23-big-Summary.db 
WARNING: Not implemented: VALIDATION
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=a63be81c-933a-3d81-bcc1-4a03cf583c75
 [shard 0] Migration Manager - Gossiping my schema version a63be81c-933a-3d81-bcc1-4a03cf583c75
 [shard 1] Migration Manager - Create new table: standard1
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Statistics.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-29-big-Summary.db 
 [shard 1] Migration Manager - Create new table: standard1
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=a63be81c-933a-3d81-bcc1-4a03cf583c75
 [shard 0] Migration Manager - Gossiping my schema version a63be81c-933a-3d81-bcc1-4a03cf583c75
 [shard 2] Migration Manager - Create new table: standard1
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Statistics.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-35-big-Summary.db 
WARNING: Not implemented: VALIDATION
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=d60ec17b-6131-38b5-8840-57f5cb721eb6
 [shard 0] Migration Manager - Gossiping my schema version d60ec17b-6131-38b5-8840-57f5cb721eb6
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-TOC.txt 
 [shard 2] Migration Manager - Create new table: standard1
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-Statistics.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-41-big-Summary.db 
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=ccc28ed4-ce6d-3213-8a7a-fd6683a2a2ac
 [shard 0] Migration Manager - Gossiping my schema version ccc28ed4-ce6d-3213-8a7a-fd6683a2a2ac
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-CRC.db 
 [shard 3] Migration Manager - Create new table: standard1
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Digest.sha1 
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Digest.sha1 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Summary.db 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-CRC.db 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-CRC.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Summary.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-Filter.db 
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Filter.db 
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-Statistics.db 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Statistics.db 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-TOC.txt 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-TOC.txt 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-TOC.txt 
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-TOC.txt 
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-TOC.txt 
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Statistics.db 
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Statistics.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Filter.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Filter.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-Filter.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Filter.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Filter.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Summary.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Summary.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-47-big-Summary.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Summary.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Summary.db 
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
WARNING: Not implemented: VALIDATION
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=eab4d14c-8b50-3ba9-9a4b-e5cdfdabb3ea
 [shard 0] Migration Manager - Gossiping my schema version eab4d14c-8b50-3ba9-9a4b-e5cdfdabb3ea
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-Statistics.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Filter.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Filter.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-17-big-Summary.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-17-big-Summary.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-53-big-Summary.db 
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
WARNING: exceptional future ignored of type 'std::runtime_error': not implemented
WARNING: exceptional future ignored of type 'std::runtime_error': not implemented
WARNING: exceptional future ignored of type 'std::runtime_error': not implemented
create_table_from_table_row_and_column_rows
=================================================================
==23535==ERROR: AddressSanitizer: heap-use-after-free on address 0x60600044d9f0 at pc 0xf830e3 bp 0x7fef866d5560 sp 0x7fef866d5550
READ of size 8 at 0x60600044d9f0 thread T2
create_table_from_table_row_and_column_rows
==23535==AddressSanitizer: while reporting a bug found another one.Ignoring.

@slivne
Copy link
Contributor Author

slivne commented Jul 28, 2015

for reference this is what happens when urchin is run with --smp 6 and a single cassandra-stress client with debug enabled

CQL server listening on 192.168.10.101:9042 ...
Thrift server listening on 192.168.10.101:9160 ...
Seastar HTTP server listening on 192.168.10.101:10000 ...
WARNING: Not implemented: AUTH
warning: ignoring event registration
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
WARNING: Not implemented: AUTH
WARNING: Not implemented: INDEXES
WARNING: Not implemented: METRICS
WARNING: Not implemented: PERMISSIONS
WARNING: Not implemented: PAGING
 [shard 2] Migration Manager - Create new Keyspace: keyspace2
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Digest.sha1 
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Digest.sha1 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-CRC.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Summary.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Summary.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Filter.db 
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Filter.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Statistics.db 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Statistics.db 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-TOC.txt 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-TOC.txt 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Statistics.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-11-big-Summary.db 
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-TOC.txt 
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Statistics.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Filter.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-9-big-Summary.db 
WARNING: Not implemented: VALIDATION
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=f445215f-f718-3d5d-97a0-a268ab53e7f6
 [shard 0] Migration Manager - Gossiping my schema version f445215f-f718-3d5d-97a0-a268ab53e7f6
 [shard 2] Migration Manager - Create new table: standard1
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Digest.sha1 
 [shard 5] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Digest.sha1 
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Digest.sha1 
 [shard 3] sstable - Writing Digest file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Digest.sha1 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-CRC.db 
 [shard 5] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-CRC.db 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-CRC.db 
 [shard 3] sstable - Writing CRC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-CRC.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Summary.db 
 [shard 3] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Summary.db 
 [shard 5] sstable - Writing Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Summary.db 
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Filter.db 
 [shard 3] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Filter.db 
 [shard 5] sstable - Writing Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Filter.db 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Statistics.db 
 [shard 3] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Statistics.db 
 [shard 5] sstable - Writing Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Statistics.db 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-TOC.txt 
 [shard 3] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-TOC.txt 
 [shard 5] sstable - Writing TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-TOC.txt 
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-TOC.txt 
 [shard 3] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-TOC.txt 
 [shard 5] sstable - Reading TOC file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-TOC.txt 
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Statistics.db 
 [shard 3] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Statistics.db 
 [shard 5] sstable - Reading Statistics.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Statistics.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Filter.db 
 [shard 3] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Filter.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-9-big-Summary.db 
 [shard 3] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-9-big-Summary.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Filter.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_keyspaces-b0f22357-4458-3cdb-9631-c43e59ce3676/la-17-big-Summary.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columns-296e9c04-9bec-3085-827d-c17d3df2122a/la-11-big-Summary.db 
 [shard 5] sstable - Reading Filter.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Filter.db 
 [shard 5] sstable - Reading Summary.db file /data2/shlomi/tmp/system/schema_columnfamilies-45f5b360-24bc-3f83-a363-1034ea4fa697/la-11-big-Summary.db 
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows
create_table_from_table_row_and_column_rows end
create_table_from_table_row_and_column_rows end
 [shard 0] storage_service - SS::on_change endpoint=192.168.10.101
 [shard 0] storage_service - storage_service:: Update ep=192.168.10.101, state=2, value=d021b91a-1f87-38b3-95e2-c15c89e8fd6e
 [shard 0] Migration Manager - Gossiping my schema version d021b91a-1f87-38b3-95e2-c15c89e8fd6e
WARNING: Not implemented: TRIGGERS

@penberg
Copy link
Contributor

penberg commented Jul 28, 2015

@slivne, does

addr2line -e build/debug/scylla 0xf830e3

report anything interesting?

@avikivity any ideas why address sanitizer doesn't report a proper backtrace?

@slivne
Copy link
Contributor Author

slivne commented Jul 28, 2015

@penberg

/usr/include/c++/4.9.2/bits/hashtable.h:614

@avikivity
Copy link
Member

Usually it does report a complete backtrace, no idea why it didn't now.

@penberg
Copy link
Contributor

penberg commented Jul 28, 2015

@slivne That suggests that the query result set is used after it's free'd.

@tgrabiec, @avikivity, is that parallel_for_each() in create_tables_from_tables_partition() safe?

@avikivity
Copy link
Member

It's not safe. In its caller it's a lambda parameter, so it dies as soon as the create_tables_from_tables_partition() returns (which is before the parallel_for_each() completes).

Suggest passing it by value to create_tables_from_tables_partition(), and using do_with() to protect it.

@penberg
Copy link
Contributor

penberg commented Jul 28, 2015

@avikivity, would map_reduce work as well?

@avikivity
Copy link
Member

It would, but that's unrelated to the bug.

I don't think it's worth it, there isn't a readily-available reducer to use here. You could replace the shared_ptr with do_with (but again that's not related to the bug).

@penberg
Copy link
Contributor

penberg commented Jul 28, 2015

@avikivity Well, too late, I already sent a patch that uses map_reduce(). That's what we use elsewhere in the code as well. Lets talk more about it on the mailing list.

@tgrabiec
Copy link
Contributor

2015-07-28 18:21 GMT+02:00 Avi Kivity notifications@github.com:

It's not safe. In its caller it's a lambda parameter, so it dies as soon
as the create_tables_from_tables_partition() returns (which is before the
parallel_for_each() completes).

Suggest passing it by value to create_tables_from_tables_partition(), and
using do_with() to protect it.

The argument is passed by reference here (v.second):

create_tables_from_tables_partition(proxy.local(), v.second)

"v" comes from lambda parameter, also passed by reference:

return do_parse_system_tables(proxy,
db::legacy_schema_tables::COLUMNFAMILIES, [this, &proxy](schema_result::value_type &v) {

do_parse_system_tables calls that lambda with "v" wrapped in do_with():

return do_with(std::move(v), [func = std::forward(func), cf_name](auto& v) {

                return func(v).then_wrapped([cf_name, &v] (future<> f) {

It seems to me that we should be fine here.

@penberg
Copy link
Contributor

penberg commented Jul 28, 2015

The ASan traces point to the unordered_map in query::result_set_row but I don't really understand what the problem could be. Query result set should be accessible on all cores and they're protected by do_with().

@penberg
Copy link
Contributor

penberg commented Jul 29, 2015

So what happens is that there's multiple clients bombarding the server with "create table" statements. We start processing them on all cores and end up creating create table mutations with slightly different UUIDs (they're time-based generated).

We then attempt to make sense of it all in merge_schema() just like Origin does. However, as we don't support updating tables which the merge algorithm attempts, we throw an exception. For some reason, we bail out from the invoke_on_all block and drop the lock while still attempting to run the remaining per-core in-memory updates.

This causes various kinds of issues and sometimes manifests as use-after-free and a SIGSEGV.

@slivne
Copy link
Contributor Author

slivne commented Jul 29, 2015

We do not untend to support alter table

But wedi need to support create table

It seems we are taking the lock to "late" or missung a check adter taking
if someone elze alreaxy dix the operation
On Jul 29, 2015 2:32 PM, "Pekka Enberg" notifications@github.com wrote:

So what happens is that there's multiple clients bombarding the server
with "create table" statements. We start processing them on all cores and
end up creating create table mutations with slightly different UUIDs
(they're time-based generated).

We then attempt to make sense of it all in merge_schema() just like
Origin does. However, as we don't support updating tables which the merge
algorithm attempts, we throw an exception. For some reason, we bail out
from the invoke_on_all block and drop the lock while still attempting to
run the remaining per-core in-memory updates.

This causes various kinds of issues and sometimes manifests as
use-after-free and a SIGSEGV.


Reply to this email directly or view it on GitHub
#25 (comment)
.

@penberg
Copy link
Contributor

penberg commented Jul 29, 2015

@slivne Please re-read what I commented above. We take the lock at the right time and the exception we throw is supposed to be harmless. Origin also throws an exception for your scenario, just a different one. However, we seem to drop the lock way too early which causes various issues.

You can workaround the error by removing the throw std::runtime_error line from database::update_keyspace() and database::update_column_family().

@slivne
Copy link
Contributor Author

slivne commented Jul 29, 2015

Q: even if we solve it on a single node will it work in a cluster
On Jul 29, 2015 2:38 PM, "Shlomi Livne" shlomi@cloudius-systems.com wrote:

We do not untend to support alter table

But wedi need to support create table

It seems we are taking the lock to "late" or missung a check adter taking
if someone elze alreaxy dix the operation
On Jul 29, 2015 2:32 PM, "Pekka Enberg" notifications@github.com wrote:

So what happens is that there's multiple clients bombarding the server
with "create table" statements. We start processing them on all cores and
end up creating create table mutations with slightly different UUIDs
(they're time-based generated).

We then attempt to make sense of it all in merge_schema() just like
Origin does. However, as we don't support updating tables which the merge
algorithm attempts, we throw an exception. For some reason, we bail out
from the invoke_on_all block and drop the lock while still attempting to
run the remaining per-core in-memory updates.

This causes various kinds of issues and sometimes manifests as
use-after-free and a SIGSEGV.


Reply to this email directly or view it on GitHub
#25 (comment)
.

@penberg
Copy link
Contributor

penberg commented Jul 29, 2015

@slivne I don't know. We would first need to determine what happens in Origin. Schema updates are handled via the same code path so I suspect you'd see the same UUID mismatch exception as with the case where single node is bombarded with parallel table creation.

@penberg
Copy link
Contributor

penberg commented Jul 30, 2015

Commit scylladb/seastar@732dba1 fixed the SIGSEGV for me.

@slivne please retest on Godzilla.

@avikivity
Copy link
Member

Anyway it looks like stress is generating invalid inserts with 0 rows.

bhalevy added a commit to bhalevy/scylla that referenced this issue Mar 10, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.
Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue Mar 11, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.
Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue Apr 13, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.
Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue Apr 17, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.
Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue Apr 29, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.
Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue Apr 30, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.
Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue May 5, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.
Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue May 6, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.

Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

`verifier` was not captured in the scan_dir.then() continuation.
We could add a capture in that lambda, but it's cleaner and safer to let do_with hold on to it instead.

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue May 11, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.

Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

`verifier` was not captured in the scan_dir.then() continuation.
We could add a capture in that lambda, but it's cleaner and safer to let do_with hold on to it instead.

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue May 13, 2020
Rather than using lw_shared_ptr to keep it around, use do_with.

Fixes a use-after-free seen with interrupt_build_process_with_resharding_half_to_max_test
in debug mode:

`verifier` was not captured in the scan_dir.then() continuation.
We could add a capture in that lambda, but it's cleaner and safer to let do_with hold on to it instead.

==406079==ERROR: AddressSanitizer: heap-use-after-free on address 0x603001320ac0 at pc 0x00000777a062 bp 0x7ffdeb77b010 sp 0x7ffdeb77b000
READ of size 8 at 0x603001320ac0 thread T0
    #0 0x777a061 in _M_next /usr/include/c++/9/bits/hashtable_policy.h:283
    scylladb#1 0x779ead7 in _M_incr /usr/include/c++/9/bits/hashtable_policy.h:299
    scylladb#2 0x777bbac in operator++ /usr/include/c++/9/bits/hashtable_policy.h:362
    scylladb#3 0x77f8384 in run_and_dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future-util.hh:568
    scylladb#4 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#5 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#6 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#7 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#8 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#9 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#10 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)
    scylladb#11 0x42b69d in _start (/local/home/bhalevy/.dtest/dtest-q85idok7/test/node1/bin/scylla+0x42b69d)

0x603001320ac0 is located 0 bytes inside of 32-byte region [0x603001320ac0,0x603001320ae0)
freed by thread T0 here:
    #0 0x7fb86520996f in operator delete(void*) (/lib64/libasan.so.5+0x11096f)
    scylladb#1 0x77d1889 in deallocate /usr/include/c++/9/ext/new_allocator.h:128
    scylladb#2 0x77bcbb2 in deallocate /usr/include/c++/9/bits/alloc_traits.h:470
    scylladb#3 0x77bccc5 in _M_deallocate_node_ptr /usr/include/c++/9/bits/hashtable_policy.h:2113
    scylladb#4 0x779dc59 in _M_deallocate_node /usr/include/c++/9/bits/hashtable_policy.h:2103
    scylladb#5 0x77bc8b6 in _M_deallocate_nodes /usr/include/c++/9/bits/hashtable_policy.h:2124
    scylladb#6 0x779d18f in clear /usr/include/c++/9/bits/hashtable.h:2028
    scylladb#7 0x7779b8e in ~_Hashtable /usr/include/c++/9/bits/hashtable.h:1352
    scylladb#8 0x774cfed in ~unordered_map /usr/include/c++/9/bits/unordered_map.h:102
    scylladb#9 0x774d288 in ~shared_ptr_no_esft /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:157
    scylladb#10 0x774d2f1 in dispose /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#11 0x76f9642 in ~lw_shared_ptr /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#12 0x76f9642 in ~<lambda> /local/home/bhalevy/dev/scylla/distributed_loader.cc:743
    scylladb#13 0x771e0a7 in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1167
    scylladb#14 0x777c64c in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:133
    scylladb#15 0x586059 in seastar::noncopyable_function<seastar::future<> ()>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:165
    scylladb#16 0x5867da in seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}::~future_state() /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/future.hh:1192
    scylladb#17 0xab704d in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::~continu
ation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:507
    scylladb#18 0xab7216 in seastar::continuation<seastar::future<>::then_impl<seastar::noncopyable_function<seastar::future<> ()>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> ()>&&)::{lambda()scylladb#1}::operator()() const::{lambda(seastar::future_state<>&&)scylladb#1}>::run_and_
dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:512
    scylladb#19 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#20 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#21 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#22 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#23 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#24 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#25 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

previously allocated by thread T0 here:
    #0 0x7fb8652089d7 in operator new(unsigned long) (/lib64/libasan.so.5+0x10f9d7)
    scylladb#1 0x77d1796 in allocate /usr/include/c++/9/ext/new_allocator.h:114
    scylladb#2 0x77bcab3 in allocate /usr/include/c++/9/bits/alloc_traits.h:444
    scylladb#3 0x779d936 in _M_allocate_node<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable_policy.h:2081
    scylladb#4 0x777a2ed in _M_emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:1638
    scylladb#5 0x774d707 in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/hashtable.h:749
    scylladb#6 0x771ce3e in emplace<long int&, distributed_loader::cleanup_column_family_sstables(seastar::distributed<database>&, seastar::sstring, seastar::sstring, seastar::sstring)::sstable_descriptor> /usr/include/c++/9/bits/unordered_map.h:388
    scylladb#7 0x76f8280 in operator() /local/home/bhalevy/dev/scylla/distributed_loader.cc:732
    scylladb#8 0x774dc5d in _M_invoke /usr/include/c++/9/bits/std_function.h:286
    scylladb#9 0x6cde67b in std::function<seastar::future<> (std::filesystem::__cxx11::path, seastar::directory_entry)>::operator()(std::filesystem::__cxx11::path, seastar::directory_entry) const /usr/include/c++/9/bits/std_function.h:690
    scylladb#10 0x6cd345d in operator() /local/home/bhalevy/dev/scylla/lister.cc:30
    scylladb#11 0x6cd96e0 in apply /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#12 0x6cd9854 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#13 0x6cd9953 in apply<lister::visit(seastar::directory_entry)::<lambda(seastar::directory_entry)>&, seastar::directory_entry&&> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#14 0x6cd6ba9 in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1168
    scylladb#15 0x6cdbac0 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:101
    scylladb#16 0x6ce6178 in seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>::operator()(seastar::directory_entry&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:184
    scylladb#17 0x6ce3033 in seastar::apply_helper<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, std::tuple<seastar::directory_entry>&&, std::integer_sequence<unsigned long, 0ul> >::apply(seastar::noncopyable_function<seastar::future<> (seastar::directory_e
ntry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/apply.hh:36
    scylladb#18 0x6ce3130 in auto seastar::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<seastar::directory_entry>&&) /local/home/bha
levy/dev/scylla/seastar/include/seastar/core/apply.hh:44
    scylladb#19 0x6ce322f in seastar::future<> seastar::futurize<seastar::future<> >::apply<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::directory_entry>(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&, std::tuple<s
eastar::directory_entry>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1650
    scylladb#20 0x6cdf88d in seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lambda()scylladb#1}::operator()()
const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}::operator()(seastar::future_state<seastar::directory_entry>) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1196
    scylladb#21 0x6cea2e0 in seastar::continuation<seastar::future<seastar::directory_entry>::then_impl<seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>, seastar::future<> >(seastar::noncopyable_function<seastar::future<> (seastar::directory_entry&&)>&&)::{lamb
da()scylladb#1}::operator()() const::{lambda(seastar::future_state<seastar::directory_entry>&&)scylladb#1}, seastar::directory_entry>::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:511
    scylladb#22 0x9808883 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2091
    scylladb#23 0x980c831 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2506
    scylladb#24 0x9811c44 in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2666
    scylladb#25 0x967db93 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:199
    scylladb#26 0x967bbb9 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#27 0x475fcb in main /local/home/bhalevy/dev/scylla/main.cc:486
    scylladb#28 0x7fb862d981a2 in __libc_start_main (/lib64/libc.so.6+0x271a2)

SUMMARY: AddressSanitizer: heap-use-after-free /usr/include/c++/9/bits/hashtable_policy.h:283 in _M_next
Shadow bytes around the buggy address:
  0x0c068025c100: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c110: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c120: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c130: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c140: fd fd fd fa fa fa 00 00 00 fa fa fa fd fd fd fa
=>0x0c068025c150: fa fa fd fd fd fa fa fa[fd]fd fd fd fa fa fd fd
  0x0c068025c160: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c170: fd fd fd fa fa fa fd fd fd fa fa fa fd fd fd fa
  0x0c068025c180: fa fa fd fd fd fa fa fa fd fd fd fa fa fa fd fd
  0x0c068025c190: fd fa fa fa fd fd fd fa fa fa fd fd fd fa fa fa
  0x0c068025c1a0: fd fd fd fd fa fa fd fd fd fd fa fa 00 00 00 fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==406079==ABORTING

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue Oct 4, 2020
… token_metadata_ptr

Fixes use-after-free seen with putget_with_reloaded_certificates_test:
```
==215==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000a8b180 at pc 0x000012eb5a83 bp 0x7ffd2c16d4c0 sp 0x7ffd2c16d4b0
READ of size 8 at 0x603000a8b180 thread T0
    #0 0x12eb5a82 in std::__uniq_ptr_impl<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::_M_ptr() const /usr/include/c++/10/bits/unique_ptr.h:173
    scylladb#1 0x12ea230d in std::unique_ptr<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::get() const /usr/include/c++/10/bits/unique_ptr.h:422
    scylladb#2 0x12e8d3e8 in std::unique_ptr<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::operator->() const /usr/include/c++/10/bits/unique_ptr.h:416
    scylladb#3 0x12e5d0a2 in locator::token_metadata::ring_range(std::optional<interval_bound<dht::ring_position> > const&, bool) const locator/token_metadata.cc:1712
    scylladb#4 0x112d0126 in service::query_ranges_to_vnodes_generator::process_one_range(unsigned long, std::vector<nonwrapping_interval<dht::ring_position>, std::allocator<nonwrapping_interval<dht::ring_position> > >&) service/storage_proxy.cc:4658
    scylladb#5 0x112cf3c5 in service::query_ranges_to_vnodes_generator::operator()(unsigned long) service/storage_proxy.cc:4616
    scylladb#6 0x112b2261 in service::storage_proxy::query_partition_key_range_concurrent(std::chrono::time_point<seastar::lowres_clock, std::chrono::duration<long, std::ratio<1l, 1000l> > >, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >, std::allocator<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, unsigned long, unsigned int, std::unordered_map<nonwrapping_interval<dht::token>, std::vector<utils::UUID, std::allocator<utils::UUID> >, std::hash<nonwrapping_interval<dht::token> >, std::equal_to<nonwrapping_interval<dht::token> >, std::allocator<std::pair<nonwrapping_interval<dht::token> const, std::vector<utils::UUID, std::allocator<utils::UUID> > > > >, service_permit) service/storage_proxy.cc:4023
    scylladb#7 0x112b094e in operator() service/storage_proxy.cc:4160
    scylladb#8 0x1139c8bb in invoke<service::storage_proxy::query_partition_key_range_concurrent(seastar::lowres_clock::time_point, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, uint64_t, uint32_t, service::replicas_per_token_range, service_permit)::<lambda(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2088
    scylladb#9 0x1136625b in futurize_invoke<service::storage_proxy::query_partition_key_range_concurrent(seastar::lowres_clock::time_point, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, uint64_t, uint32_t, service::replicas_per_token_range, service_permit)::<lambda(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2119
    scylladb#10 0x11366372 in operator()<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1480
    scylladb#11 0x1139cc3b in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:145
    scylladb#12 0x116f4944 in seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>::operator()(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#13 0x116b3397 in seastar::future<service::query_partition_key_range_concurrent_result> std::__invoke_impl<seastar::future<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >(std::__invoke_other, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) /usr/include/c++/10/bits/invoke.h:60
    scylladb#14 0x1165c3a6 in std::__invoke_result<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::type std::__invoke<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) /usr/include/c++/10/bits/invoke.h:96
    scylladb#15 0x115e6542 in decltype(auto) std::__apply_impl<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >, 0ul>(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, std::integer_sequence<unsigned long, 0ul>) /usr/include/c++/10/tuple:1724
    scylladb#16 0x115e6663 in decltype(auto) std::apply<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&) /usr/include/c++/10/tuple:1736
    scylladb#17 0x115e63f9 in seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const::{lambda()scylladb#1}::operator()() const /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1530
    scylladb#18 0x1165c4b9 in void seastar::futurize<seastar::future<service::query_partition_key_range_concurrent_result> >::satisfy_with_result_of<seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const::{lambda()scylladb#1}>(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2073
    scylladb#19 0x115e61f5 in seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1528
    scylladb#20 0x1176e9cc in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:746
    scylladb#21 0x16a9a455 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2196
    scylladb#22 0x16a9e691 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2575
    scylladb#23 0x16aa390e in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2730
    scylladb#24 0x168ae4f7 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:207
    scylladb#25 0x168ac541 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#26 0xd6cd3c4 in main /local/home/bhalevy/dev/scylla/main.cc:504
    scylladb#27 0x7f8d905d8041 in __libc_start_main (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x27041)
    scylladb#28 0xd67c9ed in _start (/local/home/bhalevy/.dtest/dtest-o0qoqmkr/test/node3/bin/scylla+0xd67c9ed)

0x603000a8b180 is located 16 bytes inside of 24-byte region [0x603000a8b170,0x603000a8b188)
freed by thread T0 here:
    #0 0x7f8d92a190cf in operator delete(void*, unsigned long) (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libasan.so.6+0xb30cf)
    scylladb#1 0xd7ebe54 in seastar::internal::lw_shared_ptr_accessors_no_esft<locator::token_metadata>::dispose(seastar::lw_shared_ptr_counter_base*) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#2 0x112b155d in seastar::lw_shared_ptr<locator::token_metadata const>::~lw_shared_ptr() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#3 0x112b155d in ~<lambda> service/storage_proxy.cc:4137
    scylladb#4 0x1132e92d in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1479
    scylladb#5 0x1139cc91 in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:148
    scylladb#6 0x11565673 in seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:181
    scylladb#7 0x1176e783 in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::~continuation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:729
    scylladb#8 0x1176ea06 in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:750
    scylladb#9 0x16a9a455 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2196
    scylladb#10 0x16a9e691 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2575
    scylladb#11 0x16aa390e in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2730
    scylladb#12 0x168ae4f7 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:207
    scylladb#13 0x168ac541 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#14 0xd6cd3c4 in main /local/home/bhalevy/dev/scylla/main.cc:504
    scylladb#15 0x7f8d905d8041 in __libc_start_main (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x27041)

previously allocated by thread T0 here:
    #0 0x7f8d92a18067 in operator new(unsigned long) (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libasan.so.6+0xb2067)
    scylladb#1 0x13cf7132 in seastar::lw_shared_ptr<locator::token_metadata> seastar::lw_shared_ptr<locator::token_metadata>::make<locator::token_metadata>(locator::token_metadata&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:266
    scylladb#2 0x13cc3bfa in seastar::lw_shared_ptr<locator::token_metadata> seastar::make_lw_shared<locator::token_metadata>(locator::token_metadata&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:422
    scylladb#3 0x13ca3007 in seastar::lw_shared_ptr<locator::token_metadata> locator::make_token_metadata_ptr<locator::token_metadata>(locator::token_metadata) locator/token_metadata.hh:338
    scylladb#4 0x13c9bdd4 in locator::shared_token_metadata::clone() const locator/token_metadata.hh:358
    scylladb#5 0x13c9c18a in service::storage_service::get_mutable_token_metadata_ptr() service/storage_service.hh:184
    scylladb#6 0x13a5a445 in service::storage_service::handle_state_normal(gms::inet_address) service/storage_service.cc:1129
    scylladb#7 0x13a6371c in service::storage_service::on_change(gms::inet_address, gms::application_state, gms::versioned_value const&) service/storage_service.cc:1421
    scylladb#8 0x12a86269 in operator() gms/gossiper.cc:1639
    scylladb#9 0x12ad3eea in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:145
    scylladb#10 0x12be2aff in seastar::noncopyable_function<void (seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>)>::operator()(seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#11 0x12bb8e98 in atomic_vector<seastar::shared_ptr<gms::i_endpoint_state_change_subscriber> >::for_each(seastar::noncopyable_function<void (seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>)>) utils/atomic_vector.hh:62
    scylladb#12 0x12a8662b in gms::gossiper::do_on_change_notifications(gms::inet_address, gms::application_state const&, gms::versioned_value const&) gms/gossiper.cc:1638
    scylladb#13 0x12a9387c in operator() gms/gossiper.cc:1978
    scylladb#14 0x12b49b20 in __invoke_impl<void, gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /usr/include/c++/10/bits/invoke.h:60
    scylladb#15 0x12b21fd6 in __invoke<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /usr/include/c++/10/bits/invoke.h:95
    scylladb#16 0x12b02865 in __apply_impl<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()>, std::tuple<> > /usr/include/c++/10/tuple:1723
    scylladb#17 0x12b028d8 in apply<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()>, std::tuple<> > /usr/include/c++/10/tuple:1734
    scylladb#18 0x12b02967 in apply<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2052
    scylladb#19 0x12ad866a in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/thread.hh:258
    scylladb#20 0x12b609c2 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:116
    scylladb#21 0xdfabb5f in seastar::noncopyable_function<void ()>::operator()() const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#22 0x16e21bb4 in seastar::thread_context::main() /local/home/bhalevy/dev/scylla/seastar/src/core/thread.cc:297
    scylladb#23 0x16e2190f in seastar::thread_context::s_main(int, int) /local/home/bhalevy/dev/scylla/seastar/src/core/thread.cc:275
    scylladb#24 0x7f8d9060322f  (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x5222f)
```

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue Oct 4, 2020
… token_metadata_ptr

Fixes use-after-free seen with putget_with_reloaded_certificates_test:
```
==215==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000a8b180 at pc 0x000012eb5a83 bp 0x7ffd2c16d4c0 sp 0x7ffd2c16d4b0
READ of size 8 at 0x603000a8b180 thread T0
    #0 0x12eb5a82 in std::__uniq_ptr_impl<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::_M_ptr() const /usr/include/c++/10/bits/unique_ptr.h:173
    scylladb#1 0x12ea230d in std::unique_ptr<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::get() const /usr/include/c++/10/bits/unique_ptr.h:422
    scylladb#2 0x12e8d3e8 in std::unique_ptr<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::operator->() const /usr/include/c++/10/bits/unique_ptr.h:416
    scylladb#3 0x12e5d0a2 in locator::token_metadata::ring_range(std::optional<interval_bound<dht::ring_position> > const&, bool) const locator/token_metadata.cc:1712
    scylladb#4 0x112d0126 in service::query_ranges_to_vnodes_generator::process_one_range(unsigned long, std::vector<nonwrapping_interval<dht::ring_position>, std::allocator<nonwrapping_interval<dht::ring_position> > >&) service/storage_proxy.cc:4658
    scylladb#5 0x112cf3c5 in service::query_ranges_to_vnodes_generator::operator()(unsigned long) service/storage_proxy.cc:4616
    scylladb#6 0x112b2261 in service::storage_proxy::query_partition_key_range_concurrent(std::chrono::time_point<seastar::lowres_clock, std::chrono::duration<long, std::ratio<1l, 1000l> > >, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >, std::allocator<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, unsigned long, unsigned int, std::unordered_map<nonwrapping_interval<dht::token>, std::vector<utils::UUID, std::allocator<utils::UUID> >, std::hash<nonwrapping_interval<dht::token> >, std::equal_to<nonwrapping_interval<dht::token> >, std::allocator<std::pair<nonwrapping_interval<dht::token> const, std::vector<utils::UUID, std::allocator<utils::UUID> > > > >, service_permit) service/storage_proxy.cc:4023
    scylladb#7 0x112b094e in operator() service/storage_proxy.cc:4160
    scylladb#8 0x1139c8bb in invoke<service::storage_proxy::query_partition_key_range_concurrent(seastar::lowres_clock::time_point, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, uint64_t, uint32_t, service::replicas_per_token_range, service_permit)::<lambda(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2088
    scylladb#9 0x1136625b in futurize_invoke<service::storage_proxy::query_partition_key_range_concurrent(seastar::lowres_clock::time_point, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, uint64_t, uint32_t, service::replicas_per_token_range, service_permit)::<lambda(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2119
    scylladb#10 0x11366372 in operator()<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1480
    scylladb#11 0x1139cc3b in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:145
    scylladb#12 0x116f4944 in seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>::operator()(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#13 0x116b3397 in seastar::future<service::query_partition_key_range_concurrent_result> std::__invoke_impl<seastar::future<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >(std::__invoke_other, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) /usr/include/c++/10/bits/invoke.h:60
    scylladb#14 0x1165c3a6 in std::__invoke_result<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::type std::__invoke<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) /usr/include/c++/10/bits/invoke.h:96
    scylladb#15 0x115e6542 in decltype(auto) std::__apply_impl<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >, 0ul>(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, std::integer_sequence<unsigned long, 0ul>) /usr/include/c++/10/tuple:1724
    scylladb#16 0x115e6663 in decltype(auto) std::apply<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&) /usr/include/c++/10/tuple:1736
    scylladb#17 0x115e63f9 in seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const::{lambda()scylladb#1}::operator()() const /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1530
    scylladb#18 0x1165c4b9 in void seastar::futurize<seastar::future<service::query_partition_key_range_concurrent_result> >::satisfy_with_result_of<seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const::{lambda()scylladb#1}>(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2073
    scylladb#19 0x115e61f5 in seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1528
    scylladb#20 0x1176e9cc in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:746
    scylladb#21 0x16a9a455 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2196
    scylladb#22 0x16a9e691 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2575
    scylladb#23 0x16aa390e in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2730
    scylladb#24 0x168ae4f7 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:207
    scylladb#25 0x168ac541 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#26 0xd6cd3c4 in main /local/home/bhalevy/dev/scylla/main.cc:504
    scylladb#27 0x7f8d905d8041 in __libc_start_main (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x27041)
    scylladb#28 0xd67c9ed in _start (/local/home/bhalevy/.dtest/dtest-o0qoqmkr/test/node3/bin/scylla+0xd67c9ed)

0x603000a8b180 is located 16 bytes inside of 24-byte region [0x603000a8b170,0x603000a8b188)
freed by thread T0 here:
    #0 0x7f8d92a190cf in operator delete(void*, unsigned long) (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libasan.so.6+0xb30cf)
    scylladb#1 0xd7ebe54 in seastar::internal::lw_shared_ptr_accessors_no_esft<locator::token_metadata>::dispose(seastar::lw_shared_ptr_counter_base*) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#2 0x112b155d in seastar::lw_shared_ptr<locator::token_metadata const>::~lw_shared_ptr() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#3 0x112b155d in ~<lambda> service/storage_proxy.cc:4137
    scylladb#4 0x1132e92d in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1479
    scylladb#5 0x1139cc91 in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:148
    scylladb#6 0x11565673 in seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:181
    scylladb#7 0x1176e783 in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::~continuation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:729
    scylladb#8 0x1176ea06 in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:750
    scylladb#9 0x16a9a455 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2196
    scylladb#10 0x16a9e691 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2575
    scylladb#11 0x16aa390e in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2730
    scylladb#12 0x168ae4f7 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:207
    scylladb#13 0x168ac541 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#14 0xd6cd3c4 in main /local/home/bhalevy/dev/scylla/main.cc:504
    scylladb#15 0x7f8d905d8041 in __libc_start_main (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x27041)

previously allocated by thread T0 here:
    #0 0x7f8d92a18067 in operator new(unsigned long) (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libasan.so.6+0xb2067)
    scylladb#1 0x13cf7132 in seastar::lw_shared_ptr<locator::token_metadata> seastar::lw_shared_ptr<locator::token_metadata>::make<locator::token_metadata>(locator::token_metadata&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:266
    scylladb#2 0x13cc3bfa in seastar::lw_shared_ptr<locator::token_metadata> seastar::make_lw_shared<locator::token_metadata>(locator::token_metadata&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:422
    scylladb#3 0x13ca3007 in seastar::lw_shared_ptr<locator::token_metadata> locator::make_token_metadata_ptr<locator::token_metadata>(locator::token_metadata) locator/token_metadata.hh:338
    scylladb#4 0x13c9bdd4 in locator::shared_token_metadata::clone() const locator/token_metadata.hh:358
    scylladb#5 0x13c9c18a in service::storage_service::get_mutable_token_metadata_ptr() service/storage_service.hh:184
    scylladb#6 0x13a5a445 in service::storage_service::handle_state_normal(gms::inet_address) service/storage_service.cc:1129
    scylladb#7 0x13a6371c in service::storage_service::on_change(gms::inet_address, gms::application_state, gms::versioned_value const&) service/storage_service.cc:1421
    scylladb#8 0x12a86269 in operator() gms/gossiper.cc:1639
    scylladb#9 0x12ad3eea in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:145
    scylladb#10 0x12be2aff in seastar::noncopyable_function<void (seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>)>::operator()(seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#11 0x12bb8e98 in atomic_vector<seastar::shared_ptr<gms::i_endpoint_state_change_subscriber> >::for_each(seastar::noncopyable_function<void (seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>)>) utils/atomic_vector.hh:62
    scylladb#12 0x12a8662b in gms::gossiper::do_on_change_notifications(gms::inet_address, gms::application_state const&, gms::versioned_value const&) gms/gossiper.cc:1638
    scylladb#13 0x12a9387c in operator() gms/gossiper.cc:1978
    scylladb#14 0x12b49b20 in __invoke_impl<void, gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /usr/include/c++/10/bits/invoke.h:60
    scylladb#15 0x12b21fd6 in __invoke<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /usr/include/c++/10/bits/invoke.h:95
    scylladb#16 0x12b02865 in __apply_impl<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()>, std::tuple<> > /usr/include/c++/10/tuple:1723
    scylladb#17 0x12b028d8 in apply<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()>, std::tuple<> > /usr/include/c++/10/tuple:1734
    scylladb#18 0x12b02967 in apply<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2052
    scylladb#19 0x12ad866a in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/thread.hh:258
    scylladb#20 0x12b609c2 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:116
    scylladb#21 0xdfabb5f in seastar::noncopyable_function<void ()>::operator()() const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#22 0x16e21bb4 in seastar::thread_context::main() /local/home/bhalevy/dev/scylla/seastar/src/core/thread.cc:297
    scylladb#23 0x16e2190f in seastar::thread_context::s_main(int, int) /local/home/bhalevy/dev/scylla/seastar/src/core/thread.cc:275
    scylladb#24 0x7f8d9060322f  (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x5222f)
```

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue Oct 22, 2020
… token_metadata_ptr

Fixes use-after-free seen with putget_with_reloaded_certificates_test:
```
==215==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000a8b180 at pc 0x000012eb5a83 bp 0x7ffd2c16d4c0 sp 0x7ffd2c16d4b0
READ of size 8 at 0x603000a8b180 thread T0
    #0 0x12eb5a82 in std::__uniq_ptr_impl<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::_M_ptr() const /usr/include/c++/10/bits/unique_ptr.h:173
    scylladb#1 0x12ea230d in std::unique_ptr<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::get() const /usr/include/c++/10/bits/unique_ptr.h:422
    scylladb#2 0x12e8d3e8 in std::unique_ptr<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::operator->() const /usr/include/c++/10/bits/unique_ptr.h:416
    scylladb#3 0x12e5d0a2 in locator::token_metadata::ring_range(std::optional<interval_bound<dht::ring_position> > const&, bool) const locator/token_metadata.cc:1712
    scylladb#4 0x112d0126 in service::query_ranges_to_vnodes_generator::process_one_range(unsigned long, std::vector<nonwrapping_interval<dht::ring_position>, std::allocator<nonwrapping_interval<dht::ring_position> > >&) service/storage_proxy.cc:4658
    scylladb#5 0x112cf3c5 in service::query_ranges_to_vnodes_generator::operator()(unsigned long) service/storage_proxy.cc:4616
    scylladb#6 0x112b2261 in service::storage_proxy::query_partition_key_range_concurrent(std::chrono::time_point<seastar::lowres_clock, std::chrono::duration<long, std::ratio<1l, 1000l> > >, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >, std::allocator<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, unsigned long, unsigned int, std::unordered_map<nonwrapping_interval<dht::token>, std::vector<utils::UUID, std::allocator<utils::UUID> >, std::hash<nonwrapping_interval<dht::token> >, std::equal_to<nonwrapping_interval<dht::token> >, std::allocator<std::pair<nonwrapping_interval<dht::token> const, std::vector<utils::UUID, std::allocator<utils::UUID> > > > >, service_permit) service/storage_proxy.cc:4023
    scylladb#7 0x112b094e in operator() service/storage_proxy.cc:4160
    scylladb#8 0x1139c8bb in invoke<service::storage_proxy::query_partition_key_range_concurrent(seastar::lowres_clock::time_point, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, uint64_t, uint32_t, service::replicas_per_token_range, service_permit)::<lambda(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2088
    scylladb#9 0x1136625b in futurize_invoke<service::storage_proxy::query_partition_key_range_concurrent(seastar::lowres_clock::time_point, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, uint64_t, uint32_t, service::replicas_per_token_range, service_permit)::<lambda(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2119
    scylladb#10 0x11366372 in operator()<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1480
    scylladb#11 0x1139cc3b in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:145
    scylladb#12 0x116f4944 in seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>::operator()(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#13 0x116b3397 in seastar::future<service::query_partition_key_range_concurrent_result> std::__invoke_impl<seastar::future<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >(std::__invoke_other, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) /usr/include/c++/10/bits/invoke.h:60
    scylladb#14 0x1165c3a6 in std::__invoke_result<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::type std::__invoke<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) /usr/include/c++/10/bits/invoke.h:96
    scylladb#15 0x115e6542 in decltype(auto) std::__apply_impl<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >, 0ul>(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, std::integer_sequence<unsigned long, 0ul>) /usr/include/c++/10/tuple:1724
    scylladb#16 0x115e6663 in decltype(auto) std::apply<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&) /usr/include/c++/10/tuple:1736
    scylladb#17 0x115e63f9 in seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const::{lambda()scylladb#1}::operator()() const /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1530
    scylladb#18 0x1165c4b9 in void seastar::futurize<seastar::future<service::query_partition_key_range_concurrent_result> >::satisfy_with_result_of<seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const::{lambda()scylladb#1}>(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2073
    scylladb#19 0x115e61f5 in seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1528
    scylladb#20 0x1176e9cc in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:746
    scylladb#21 0x16a9a455 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2196
    scylladb#22 0x16a9e691 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2575
    scylladb#23 0x16aa390e in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2730
    scylladb#24 0x168ae4f7 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:207
    scylladb#25 0x168ac541 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#26 0xd6cd3c4 in main /local/home/bhalevy/dev/scylla/main.cc:504
    scylladb#27 0x7f8d905d8041 in __libc_start_main (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x27041)
    scylladb#28 0xd67c9ed in _start (/local/home/bhalevy/.dtest/dtest-o0qoqmkr/test/node3/bin/scylla+0xd67c9ed)

0x603000a8b180 is located 16 bytes inside of 24-byte region [0x603000a8b170,0x603000a8b188)
freed by thread T0 here:
    #0 0x7f8d92a190cf in operator delete(void*, unsigned long) (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libasan.so.6+0xb30cf)
    scylladb#1 0xd7ebe54 in seastar::internal::lw_shared_ptr_accessors_no_esft<locator::token_metadata>::dispose(seastar::lw_shared_ptr_counter_base*) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#2 0x112b155d in seastar::lw_shared_ptr<locator::token_metadata const>::~lw_shared_ptr() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#3 0x112b155d in ~<lambda> service/storage_proxy.cc:4137
    scylladb#4 0x1132e92d in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1479
    scylladb#5 0x1139cc91 in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:148
    scylladb#6 0x11565673 in seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:181
    scylladb#7 0x1176e783 in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::~continuation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:729
    scylladb#8 0x1176ea06 in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:750
    scylladb#9 0x16a9a455 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2196
    scylladb#10 0x16a9e691 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2575
    scylladb#11 0x16aa390e in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2730
    scylladb#12 0x168ae4f7 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:207
    scylladb#13 0x168ac541 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#14 0xd6cd3c4 in main /local/home/bhalevy/dev/scylla/main.cc:504
    scylladb#15 0x7f8d905d8041 in __libc_start_main (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x27041)

previously allocated by thread T0 here:
    #0 0x7f8d92a18067 in operator new(unsigned long) (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libasan.so.6+0xb2067)
    scylladb#1 0x13cf7132 in seastar::lw_shared_ptr<locator::token_metadata> seastar::lw_shared_ptr<locator::token_metadata>::make<locator::token_metadata>(locator::token_metadata&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:266
    scylladb#2 0x13cc3bfa in seastar::lw_shared_ptr<locator::token_metadata> seastar::make_lw_shared<locator::token_metadata>(locator::token_metadata&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:422
    scylladb#3 0x13ca3007 in seastar::lw_shared_ptr<locator::token_metadata> locator::make_token_metadata_ptr<locator::token_metadata>(locator::token_metadata) locator/token_metadata.hh:338
    scylladb#4 0x13c9bdd4 in locator::shared_token_metadata::clone() const locator/token_metadata.hh:358
    scylladb#5 0x13c9c18a in service::storage_service::get_mutable_token_metadata_ptr() service/storage_service.hh:184
    scylladb#6 0x13a5a445 in service::storage_service::handle_state_normal(gms::inet_address) service/storage_service.cc:1129
    scylladb#7 0x13a6371c in service::storage_service::on_change(gms::inet_address, gms::application_state, gms::versioned_value const&) service/storage_service.cc:1421
    scylladb#8 0x12a86269 in operator() gms/gossiper.cc:1639
    scylladb#9 0x12ad3eea in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:145
    scylladb#10 0x12be2aff in seastar::noncopyable_function<void (seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>)>::operator()(seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#11 0x12bb8e98 in atomic_vector<seastar::shared_ptr<gms::i_endpoint_state_change_subscriber> >::for_each(seastar::noncopyable_function<void (seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>)>) utils/atomic_vector.hh:62
    scylladb#12 0x12a8662b in gms::gossiper::do_on_change_notifications(gms::inet_address, gms::application_state const&, gms::versioned_value const&) gms/gossiper.cc:1638
    scylladb#13 0x12a9387c in operator() gms/gossiper.cc:1978
    scylladb#14 0x12b49b20 in __invoke_impl<void, gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /usr/include/c++/10/bits/invoke.h:60
    scylladb#15 0x12b21fd6 in __invoke<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /usr/include/c++/10/bits/invoke.h:95
    scylladb#16 0x12b02865 in __apply_impl<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()>, std::tuple<> > /usr/include/c++/10/tuple:1723
    scylladb#17 0x12b028d8 in apply<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()>, std::tuple<> > /usr/include/c++/10/tuple:1734
    scylladb#18 0x12b02967 in apply<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2052
    scylladb#19 0x12ad866a in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/thread.hh:258
    scylladb#20 0x12b609c2 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:116
    scylladb#21 0xdfabb5f in seastar::noncopyable_function<void ()>::operator()() const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#22 0x16e21bb4 in seastar::thread_context::main() /local/home/bhalevy/dev/scylla/seastar/src/core/thread.cc:297
    scylladb#23 0x16e2190f in seastar::thread_context::s_main(int, int) /local/home/bhalevy/dev/scylla/seastar/src/core/thread.cc:275
    scylladb#24 0x7f8d9060322f  (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x5222f)
```

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
bhalevy added a commit to bhalevy/scylla that referenced this issue Nov 11, 2020
… token_metadata_ptr

Fixes use-after-free seen with putget_with_reloaded_certificates_test:
```
==215==ERROR: AddressSanitizer: heap-use-after-free on address 0x603000a8b180 at pc 0x000012eb5a83 bp 0x7ffd2c16d4c0 sp 0x7ffd2c16d4b0
READ of size 8 at 0x603000a8b180 thread T0
    #0 0x12eb5a82 in std::__uniq_ptr_impl<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::_M_ptr() const /usr/include/c++/10/bits/unique_ptr.h:173
    scylladb#1 0x12ea230d in std::unique_ptr<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::get() const /usr/include/c++/10/bits/unique_ptr.h:422
    scylladb#2 0x12e8d3e8 in std::unique_ptr<locator::token_metadata_impl, std::default_delete<locator::token_metadata_impl> >::operator->() const /usr/include/c++/10/bits/unique_ptr.h:416
    scylladb#3 0x12e5d0a2 in locator::token_metadata::ring_range(std::optional<interval_bound<dht::ring_position> > const&, bool) const locator/token_metadata.cc:1712
    scylladb#4 0x112d0126 in service::query_ranges_to_vnodes_generator::process_one_range(unsigned long, std::vector<nonwrapping_interval<dht::ring_position>, std::allocator<nonwrapping_interval<dht::ring_position> > >&) service/storage_proxy.cc:4658
    scylladb#5 0x112cf3c5 in service::query_ranges_to_vnodes_generator::operator()(unsigned long) service/storage_proxy.cc:4616
    scylladb#6 0x112b2261 in service::storage_proxy::query_partition_key_range_concurrent(std::chrono::time_point<seastar::lowres_clock, std::chrono::duration<long, std::ratio<1l, 1000l> > >, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >, std::allocator<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, unsigned long, unsigned int, std::unordered_map<nonwrapping_interval<dht::token>, std::vector<utils::UUID, std::allocator<utils::UUID> >, std::hash<nonwrapping_interval<dht::token> >, std::equal_to<nonwrapping_interval<dht::token> >, std::allocator<std::pair<nonwrapping_interval<dht::token> const, std::vector<utils::UUID, std::allocator<utils::UUID> > > > >, service_permit) service/storage_proxy.cc:4023
    scylladb#7 0x112b094e in operator() service/storage_proxy.cc:4160
    scylladb#8 0x1139c8bb in invoke<service::storage_proxy::query_partition_key_range_concurrent(seastar::lowres_clock::time_point, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, uint64_t, uint32_t, service::replicas_per_token_range, service_permit)::<lambda(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2088
    scylladb#9 0x1136625b in futurize_invoke<service::storage_proxy::query_partition_key_range_concurrent(seastar::lowres_clock::time_point, std::vector<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, seastar::lw_shared_ptr<query::read_command>, db::consistency_level, service::query_ranges_to_vnodes_generator&&, int, tracing::trace_state_ptr, uint64_t, uint32_t, service::replicas_per_token_range, service_permit)::<lambda(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2119
    scylladb#10 0x11366372 in operator()<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1480
    scylladb#11 0x1139cc3b in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:145
    scylladb#12 0x116f4944 in seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>::operator()(seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#13 0x116b3397 in seastar::future<service::query_partition_key_range_concurrent_result> std::__invoke_impl<seastar::future<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >(std::__invoke_other, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) /usr/include/c++/10/bits/invoke.h:60
    scylladb#14 0x1165c3a6 in std::__invoke_result<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::type std::__invoke<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&) /usr/include/c++/10/bits/invoke.h:96
    scylladb#15 0x115e6542 in decltype(auto) std::__apply_impl<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >, 0ul>(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&, std::integer_sequence<unsigned long, 0ul>) /usr/include/c++/10/tuple:1724
    scylladb#16 0x115e6663 in decltype(auto) std::apply<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >&&) /usr/include/c++/10/tuple:1736
    scylladb#17 0x115e63f9 in seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const::{lambda()scylladb#1}::operator()() const /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1530
    scylladb#18 0x1165c4b9 in void seastar::futurize<seastar::future<service::query_partition_key_range_concurrent_result> >::satisfy_with_result_of<seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const::{lambda()scylladb#1}>(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2073
    scylladb#19 0x115e61f5 in seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}::operator()(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1528
    scylladb#20 0x1176e9cc in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:746
    scylladb#21 0x16a9a455 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2196
    scylladb#22 0x16a9e691 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2575
    scylladb#23 0x16aa390e in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2730
    scylladb#24 0x168ae4f7 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:207
    scylladb#25 0x168ac541 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#26 0xd6cd3c4 in main /local/home/bhalevy/dev/scylla/main.cc:504
    scylladb#27 0x7f8d905d8041 in __libc_start_main (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x27041)
    scylladb#28 0xd67c9ed in _start (/local/home/bhalevy/.dtest/dtest-o0qoqmkr/test/node3/bin/scylla+0xd67c9ed)

0x603000a8b180 is located 16 bytes inside of 24-byte region [0x603000a8b170,0x603000a8b188)
freed by thread T0 here:
    #0 0x7f8d92a190cf in operator delete(void*, unsigned long) (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libasan.so.6+0xb30cf)
    scylladb#1 0xd7ebe54 in seastar::internal::lw_shared_ptr_accessors_no_esft<locator::token_metadata>::dispose(seastar::lw_shared_ptr_counter_base*) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:213
    scylladb#2 0x112b155d in seastar::lw_shared_ptr<locator::token_metadata const>::~lw_shared_ptr() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:300
    scylladb#3 0x112b155d in ~<lambda> service/storage_proxy.cc:4137
    scylladb#4 0x1132e92d in ~<lambda> /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:1479
    scylladb#5 0x1139cc91 in destroy /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:148
    scylladb#6 0x11565673 in seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>::~noncopyable_function() /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:181
    scylladb#7 0x1176e783 in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::~continuation() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:729
    scylladb#8 0x1176ea06 in seastar::continuation<seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::then_impl_nrvo<seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>, seastar::future<service::query_partition_key_range_concurrent_result> >(seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&&)::{lambda(seastar::internal::promise_base_with_type<service::query_partition_key_range_concurrent_result>&&, seastar::noncopyable_function<seastar::future<service::query_partition_key_range_concurrent_result> (seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> >&&)>&, seastar::future_state<std::tuple<seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > > >&&)scylladb#1}, seastar::foreign_ptr<seastar::lw_shared_ptr<query::result> > >::run_and_dispose() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:750
    scylladb#9 0x16a9a455 in seastar::reactor::run_tasks(seastar::reactor::task_queue&) /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2196
    scylladb#10 0x16a9e691 in seastar::reactor::run_some_tasks() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2575
    scylladb#11 0x16aa390e in seastar::reactor::run() /local/home/bhalevy/dev/scylla/seastar/src/core/reactor.cc:2730
    scylladb#12 0x168ae4f7 in seastar::app_template::run_deprecated(int, char**, std::function<void ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:207
    scylladb#13 0x168ac541 in seastar::app_template::run(int, char**, std::function<seastar::future<int> ()>&&) /local/home/bhalevy/dev/scylla/seastar/src/core/app-template.cc:115
    scylladb#14 0xd6cd3c4 in main /local/home/bhalevy/dev/scylla/main.cc:504
    scylladb#15 0x7f8d905d8041 in __libc_start_main (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x27041)

previously allocated by thread T0 here:
    #0 0x7f8d92a18067 in operator new(unsigned long) (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libasan.so.6+0xb2067)
    scylladb#1 0x13cf7132 in seastar::lw_shared_ptr<locator::token_metadata> seastar::lw_shared_ptr<locator::token_metadata>::make<locator::token_metadata>(locator::token_metadata&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:266
    scylladb#2 0x13cc3bfa in seastar::lw_shared_ptr<locator::token_metadata> seastar::make_lw_shared<locator::token_metadata>(locator::token_metadata&&) /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/shared_ptr.hh:422
    scylladb#3 0x13ca3007 in seastar::lw_shared_ptr<locator::token_metadata> locator::make_token_metadata_ptr<locator::token_metadata>(locator::token_metadata) locator/token_metadata.hh:338
    scylladb#4 0x13c9bdd4 in locator::shared_token_metadata::clone() const locator/token_metadata.hh:358
    scylladb#5 0x13c9c18a in service::storage_service::get_mutable_token_metadata_ptr() service/storage_service.hh:184
    scylladb#6 0x13a5a445 in service::storage_service::handle_state_normal(gms::inet_address) service/storage_service.cc:1129
    scylladb#7 0x13a6371c in service::storage_service::on_change(gms::inet_address, gms::application_state, gms::versioned_value const&) service/storage_service.cc:1421
    scylladb#8 0x12a86269 in operator() gms/gossiper.cc:1639
    scylladb#9 0x12ad3eea in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:145
    scylladb#10 0x12be2aff in seastar::noncopyable_function<void (seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>)>::operator()(seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>) const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#11 0x12bb8e98 in atomic_vector<seastar::shared_ptr<gms::i_endpoint_state_change_subscriber> >::for_each(seastar::noncopyable_function<void (seastar::shared_ptr<gms::i_endpoint_state_change_subscriber>)>) utils/atomic_vector.hh:62
    scylladb#12 0x12a8662b in gms::gossiper::do_on_change_notifications(gms::inet_address, gms::application_state const&, gms::versioned_value const&) gms/gossiper.cc:1638
    scylladb#13 0x12a9387c in operator() gms/gossiper.cc:1978
    scylladb#14 0x12b49b20 in __invoke_impl<void, gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /usr/include/c++/10/bits/invoke.h:60
    scylladb#15 0x12b21fd6 in __invoke<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /usr/include/c++/10/bits/invoke.h:95
    scylladb#16 0x12b02865 in __apply_impl<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()>, std::tuple<> > /usr/include/c++/10/tuple:1723
    scylladb#17 0x12b028d8 in apply<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()>, std::tuple<> > /usr/include/c++/10/tuple:1734
    scylladb#18 0x12b02967 in apply<gms::gossiper::add_local_application_state(std::__cxx11::list<std::pair<gms::application_state, gms::versioned_value> >)::<lambda(gms::gossiper&)> mutable::<lambda()> > /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/future.hh:2052
    scylladb#19 0x12ad866a in operator() /local/home/bhalevy/dev/scylla/seastar/include/seastar/core/thread.hh:258
    scylladb#20 0x12b609c2 in call /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:116
    scylladb#21 0xdfabb5f in seastar::noncopyable_function<void ()>::operator()() const /local/home/bhalevy/dev/scylla/seastar/include/seastar/util/noncopyable_function.hh:201
    scylladb#22 0x16e21bb4 in seastar::thread_context::main() /local/home/bhalevy/dev/scylla/seastar/src/core/thread.cc:297
    scylladb#23 0x16e2190f in seastar::thread_context::s_main(int, int) /local/home/bhalevy/dev/scylla/seastar/src/core/thread.cc:275
    scylladb#24 0x7f8d9060322f  (/local/home/bhalevy/dev/scylla/build/debug/dynamic_libs/libc.so.6+0x5222f)
```

Signed-off-by: Benny Halevy <bhalevy@scylladb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants