Comments (3)
One thing in common for these use cases you report is that free() happens while exiting. Can we have a flag set when we're exiting (and there is just a single thread alive) that will allow at that stage free() of any memory from any thread to succeed?
Come to think of it, at that point, free() might as well just be a no-op - it's an utter waste of time to do a real free() at that point, when the program is going down.
I.e., instead of
assert(((reinterpret_cast<uintptr_t>(ptr) >> cpu_id_shift) & 0xff) == cpu_id);
how about
if(((reinterpret_cast<uintptr_t>(ptr) >> cpu_id_shift) & 0xff) != cpu_id) {
if (going_down)
return;
abort(); // or whatever
}
from seastar.
It is now legal to do cross-cpu frees, although this is quite slow.
from seastar.
@avikivity I'm not sure this issue can be closed. We don't handle the case when the "cpu" thread in which the memory was allocated was terminated before we try to free it. In such case the storage for such objects will be removed before free()
is called on them and the final free()
will result in SIGSEGV.
It's easy to run into this when you have global structures which are destroyed after reactor was shut down.
Example trace:
#0 0x0000000000474271 in load (__m=std::memory_order_relaxed, this=0x7ffff45ff500) at /usr/include/c++/4.9/bits/atomic_base.h:809
#1 load (__m=std::memory_order_relaxed, this=0x7ffff45ff500) at /usr/include/c++/4.9/atomic:390
#2 memory::cpu_pages::free_cross_cpu (this=0x7ffff7fc5800, cpu_id=0x1, ptr=0x6010000505e8) at core/memory.cc:449
#3 0x000000000046728e in deallocate (this=<optimized out>, __p=<optimized out>) at /usr/include/c++/4.9/ext/new_allocator.h:110
#4 deallocate (__a=..., __n=0x1, __p=<optimized out>) at /usr/include/c++/4.9/bits/alloc_traits.h:383
#5 _M_put_node (this=0x6f6c30 <instance+176>, __p=<optimized out>) at /usr/include/c++/4.9/bits/stl_tree.h:389
#6 _M_destroy_node (this=0x6f6c30 <instance+176>, __p=<optimized out>) at /usr/include/c++/4.9/bits/stl_tree.h:438
#7 std::_Rb_tree<std::string, std::string, std::_Identity<std::string>, std::less<std::string>, std::allocator<std::string> >::_M_erase (this=this@entry=0x6f6c30 <instance+176>, __x=<optimized out>) at /usr/include/c++/4.9/bits/stl_tree.h:1247
#8 0x000000000049719f in ~_Rb_tree (this=0x6f6c30 <instance+176>, __in_chrg=<optimized out>) at /usr/include/c++/4.9/bits/stl_tree.h:715
#9 ~set (this=0x6f6c30 <instance+176>, __in_chrg=<optimized out>) at /usr/include/c++/4.9/bits/stl_set.h:90
#10 ~variables_map (this=0x6f6bf0 <instance+112>, __in_chrg=<optimized out>) at /usr/include/boost/program_options/variables_map.hpp:146
#11 destroy_impl (this=0x6f6be8 <instance+104>) at /usr/include/boost/optional/optional.hpp:479
#12 destroy (this=0x6f6be8 <instance+104>) at /usr/include/boost/optional/optional.hpp:439
#13 ~optional_base (this=0x6f6be8 <instance+104>, __in_chrg=<optimized out>) at /usr/include/boost/optional/optional.hpp:268
#14 ~optional (this=0x6f6be8 <instance+104>, __in_chrg=<optimized out>) at /usr/include/boost/optional/optional.hpp:567
#15 ~app_template (this=0x6f6b80 <instance>, __in_chrg=<optimized out>) at ./core/app-template.hh:11
#16 test_runner::~test_runner (this=0x6f6b80 <instance>, __in_chrg=<optimized out>) at tests/test_runner.cc:8
#17 0x00007ffff5005259 in __run_exit_handlers (status=0x0, listp=0x7ffff53886c8 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=0x1) at exit.c:82
#18 0x00007ffff50052a5 in __GI_exit (status=<optimized out>) at exit.c:104
#19 0x00007ffff4feaecc in __libc_start_main (main=0x40bf30 <main(int, char**)>, argc=0x1, argv=0x7fffffffda18, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffda08) at libc-start.c:321
#20 0x000000000040e5f5 in _start ()
from seastar.
Related Issues (20)
- metrics: trying to add summaries is unsafe HOT 1
- cgroups v1 isn't supported HOT 8
- use undeprecated functions in c-ares HOT 2
- Cross-shard realloc shrink crashes
- Additional data when segfaulting
- Dynamic metric aggregation
- create_scheduling_group / scheduling_group_key_create not exception safe when SG key data constructor throws
- add a unit test for json2code
- create_scheduling_group / scheduling_group_key_create are not safe to run in parallel HOT 1
- add test for prometheus (aggregation)
- [project unrelated] Question about solving __common_cmp_cat duplicate definition problem HOT 1
- High lowres clock drift > 1s in debug mode HOT 4
- add an integration test with scylla
- the workflow of "Tests (clang++-18, C++23, release, --enable-dpdk) fails due to dpdk build failure HOT 3
- seastar allocator causes infinite recursive call if seastar is compiled as a shared library
- io_uring reactor backend not available when importing and using seastar as a module HOT 2
- circleci CI was removed but it's still being reported HOT 9
- should revert ba395a22e1951a1572be2a570092524d91996c67 once clang 18.1.6 is in f40
- Update the benchmark HOT 1
- Integrate with industry-standard benchmarks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from seastar.