From: Martin Quinson Date: Sun, 29 Oct 2023 16:04:06 +0000 (+0100) Subject: Change the way we're inserting elements in this map X-Git-Tag: v3.35~89^2~37 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/709596538aad175a7b69477ea32c90050e856844 Change the way we're inserting elements in this map This is an attempt to work around this segfaut on FreeBSD: ==72834== Invalid read of size 1 ==72834== at 0x4A09B22: __is_long (include/c++/v1/string:1445) ==72834== by 0x4A09B22: __get_pointer (include/c++/v1/string:1544) ==72834== by 0x4A09B22: data (include/c++/v1/string:1251) ==72834== by 0x4A09B22: operator basic_string_view (include/c++/v1/string:879) ==72834== by 0x4A09B22: compare (include/c++/v1/string:3845) ==72834== by 0x4A09B22: operator<, std::__1::allocator > (include/c++/v1/string:4072) ==72834== by 0x4A09B22: operator(), std::__1::allocator > &, const std::__1::basic_string, std::__1::allocator > &> (include/c++/v1/__functional/operations.h:499) ==72834== by 0x4A09B22: operator() (include/c++/v1/map:577) ==72834== by 0x4A09B22: std::__1::__tree_node_base*& std::__1::__tree, std::__1::allocator >, boost::intrusive_ptr >, std::__1::__map_value_compare, std::__1::allocator >, std::__1::__ value_type, std::__1::allocator >, boost::intrusive_ptr >, std::__1::less, true>, st d::__1::allocator, std::__1::allocator >, boost::intrusive_ptr > > >::__find_equal, std::__1::allocator > >(std::__1::__tree_end_node*>*&, std::__1::basic_strin g, std::__1::allocator > const&) (include/c++/v1/__tree:1977) ==72834== by 0x4A091E0: __emplace_unique_key_args, std::__1::allocator >, const std::__1::piecewise_construct_t &, std::__1: :tuple, std::__1::allocator > &>, std::__1::tuple<> > (include/c++/v1/__tree:2093) ==72834== by 0x4A091E0: std::__1::map, std::__1::allocator >, boost::intrusive_ptr, std ::__1::less, std::__1::allocator, std::__1::allocator > const, boost::intrusive_ptr > > >::operator[](std::__1::basic_string, std::__1::allocator > const&) (include/c++/v1/map:1588) ==72834== by 0x498CD41: UnknownInlinedFun (HostImpl.cpp:240) ==72834== by 0x498CD41: operator() (s4u_Host.cpp:356) ==72834== by 0x498CD41: simcall_answered<(lambda at /builds/workspace/SimGrid/build_mode/Debug/node/freebsd/build/simgrid-3.34.1/src/s4u/s4u_Host.cpp:354:42)> (simix.hpp:49) ==72834== by 0x498CD41: simgrid::s4u::Host::create_disk(std::__1::basic_string, std::__1::allocator > const&, double, double) (s4u_Host.cpp:354) ==72834== by 0x4AE9A23: simgrid::plugin::Jbod::create_jbod(simgrid::s4u::NetZone*, std::__1::basic_string, std::__1::allocator > const&, double, un signed int, simgrid::plugin::Jbod::RAID, double, double) (jbod.cpp:30) ==72834== by 0x401C2A: main (examples/cpp/plugin-jbod/s4u-plugin-jbod.cpp:43) ==72834== Address 0xffffffff00000023 is not stack'd, malloc'd or (recently) free'd --- diff --git a/src/kernel/resource/HostImpl.cpp b/src/kernel/resource/HostImpl.cpp index b4c78c5721..da11f9aa1e 100644 --- a/src/kernel/resource/HostImpl.cpp +++ b/src/kernel/resource/HostImpl.cpp @@ -237,7 +237,7 @@ s4u::Disk* HostImpl::create_disk(const std::string& name, double read_bandwidth, void HostImpl::add_disk(const s4u::Disk* disk) { - disks_[disk->get_name()] = kernel::resource::DiskImplPtr(disk->get_impl()); + disks_.insert({disk->get_name(), kernel::resource::DiskImplPtr(disk->get_impl())}); } void HostImpl::remove_disk(const std::string& name)