From: Waldemar Kozaczuk <jwkozac...@gmail.com> Committer: Waldemar Kozaczuk <jwkozac...@gmail.com> Branch: master
vdso: initialize it only once The namespaces functionality requires new elf::program is instantiated for every new namespace. That would trigger the vdso ELF to be re-initialized again which is wrong and is manifested by the failure of the tst-namespace.cc on aarch64: 0x0000000fc00ea06c in abort (fmt=fmt@entry=0xfc049be50 "Assertion failed: %s (%s: %s: %d)\n") at runtime.cc:145 0x0000000fc00ea094 in __assert_fail (expr=<optimized out>, file=<optimized out>, line=<optimized out>, func=<optimized out>) at runtime.cc:153 0x0000000fc0163a54 in elf::object::relocate_pltgot (this=this@entry=0x600040e8e810) at core/elf.cc:783 0x0000000fc0163ad4 in elf::object::relocate (this=0x600040e8e810) at core/elf.cc:866 0x0000000fc0163c1c in elf::program::initialize_libvdso (this=this@entry=0x600040d1ce00) at /usr/include/c++/11/bits/shared_ptr_base.h:1295 0x0000000fc01642ec in elf::program::program (this=this@entry=0x600040d1ce00, addr=addr@entry=0x100400000000) at core/elf.cc:1359 0x0000000fc0283b30 in osv::application::new_program (this=0x600040d1cc10) at core/app.cc:520 To prevent it, we change the vdso initialization logic to ensure it only happens for the very initial program instance. Otherwise we simply reference the vdso instance of the initial program when constructing other new programs. Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com> --- diff --git a/core/elf.cc b/core/elf.cc --- a/core/elf.cc +++ b/core/elf.cc @@ -1361,12 +1361,16 @@ program::program(void* addr) void program::initialize_libvdso() { - _libvdso = std::make_shared<memory_image>(*this, &libvdso_start); - _libvdso->set_base(&libvdso_start); - _libvdso->load_segments(); - _libvdso->process_headers(); - _libvdso->relocate(); - _libvdso->fix_permissions(); + if (!s_program) { + _libvdso = std::make_shared<memory_image>(*this, &libvdso_start); + _libvdso->set_base(&libvdso_start); + _libvdso->load_segments(); + _libvdso->process_headers(); + _libvdso->relocate(); + _libvdso->fix_permissions(); + } else { + _libvdso = s_program->_libvdso; + } } void program::set_search_path(std::initializer_list<std::string> path) -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/0000000000002ff8150603f2b21f%40google.com.