You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a pointer is allocated on one shard and then reallocated smaller on another it crashes in most cases [1], e.g., this test crashes:
SEASTAR_TEST_CASE(test_cross_thread_realloc) {
// needs at least 2 shards to test what we want to test but will
// still pass fine on 1 shard
void *p = malloc(100);
auto other_shard = (this_shard_id() + 1) % smp::count;
return smp::submit_to(other_shard, [p]{
BOOST_REQUIRE(realloc(p, 50));
});
}
Cross-shard shrinking realloc crashes because we assert that the
incoming pointer is shard local inside the shrink method but there is
no particular reason to assume this is the case with a realloc: the
initial allocation may have been made on another shard.
Fix this by falling through to the free/malloc/memcpy path. This also
means that realloc using the same size is a way to "rehome" a possibly
foreign pointer: this does nothing if the pointer is already local but
it will allocate a local pointer and copy the allocation contents if
not.
Fixesscylladb#2202.
Cross-shard shrinking realloc crashes because we assert that the
incoming pointer is shard local inside the shrink method but there is
no particular reason to assume this is the case with a realloc: the
initial allocation may have been made on another shard.
Fix this by falling through to the free/malloc/memcpy path. This also
means that realloc using the same size is a way to "rehome" a possibly
foreign pointer: this does nothing if the pointer is already local but
it will allocate a local pointer and copy the allocation contents if
not.
Fixesscylladb#2202.
If a pointer is allocated on one shard and then reallocated smaller on another it crashes in most cases [1], e.g., this test crashes:
Crash:
This seems to violate the general contract of
realloc
and I think should be handled in the same way as cross-core frees. Fix incoming.[1] The exceptions are if the new size is zero or the size class of the new size is the same as the old.
The text was updated successfully, but these errors were encountered: