The following is identified as spam hence cannot be posted in the gitlab repo. Thus, it is here.
9.2.6 is working with my case, 9.30 and 9.3.1 are not.
SIGFPE is thrown during startup at this location.
bt:
#0 0x000055555c0c6b69 in std::__detail::_Mod_range_hashing::operator() (this=0x7fffffffd1bf, __num=3849577002, __den=0) at /usr/include/c++/12/bits/hashtable_policy.h:488
No locals.
#1 0x000055555c116bc9 in std::__detail::_Hash_code_base<vtkStringToken, std::pair<vtkStringToken const, std::function<vtkSmartPointer<vtkCellMetadata> (vtkCellGrid*)> >, std::__detail::_Select1st, std::hash<vtkStringToken>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::_M_bucket_index(unsigned long, unsigned long) const (this=0x55555e9151a0 <vtkCellMetadata::Constructors>, __c=3849577002, __bkt_count=0) at /usr/include/c++/12/bits/hashtable_policy.h:1305
No locals.
#2 0x000055555c1166fb in std::_Hashtable<vtkStringToken, std::pair<vtkStringToken const, std::function<vtkSmartPointer<vtkCellMetadata> (vtkCellGrid*)> >, std::allocator<std::pair<vtkStringToken const, std::function<vtkSmartPointer<vtkCellMetadata> (vtkCellGrid*)> > >, std::__detail::_Select1st, std::equal_to<vtkStringToken>, std::hash<vtkStringToken>, 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(unsigned long) const (this=0x55555e9151a0 <vtkCellMetadata::Constructors>, __c=3849577002) at /usr/include/c++/12/bits/hashtable.h:798
No locals.
#3 0x000055555c116257 in std::_Hashtable<vtkStringToken, std::pair<vtkStringToken const, std::function<vtkSmartPointer<vtkCellMetadata> (vtkCellGrid*)> >, std::allocator<std::pair<vtkStringToken const, std::function<vtkSmartPointer<vtkCellMetadata> (vtkCellGrid*)> > >, std::__detail::_Select1st, std::equal_to<vtkStringToken>, std::hash<vtkStringToken>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_emplace<std::pair<vtkStringToken, vtkCellMetadata::RegisterType<vtkDGHex>()::{lambda(vtkCellGrid*)#1}> >(std::integral_constant<bool, true>, std::pair<vtkStringToken, vtkCellMetadata::RegisterType<vtkDGHex>()::{lambda(vtkCellGrid*)#1}>&&) (this=0x55555e9151a0 <vtkCellMetadata::Constructors>) at /usr/include/c++/12/bits/hashtable.h:2074
__node = {_M_h = 0x55555e9151a0 <vtkCellMetadata::Constructors>, _M_node = 0x55555e973590}
__k = @0x55555e973598: {Id = 3849577002, static hash32a_const = 2166136261, static hash32b_const = 16777619, static hash64a_const = 14695981039346656037, static hash64b_const = 1099511628211}
__code = 3849577002
__bkt = 93825116235701
__pos = {<std::__detail::_Node_iterator_base<std::pair<const vtkStringToken, std::function<vtkSmartPointer<vtkCellMetadata>(vtkCellGrid*)> >, true>> = {_M_cur = 0x0}, <No data fields>}
#4 0x000055555c115f40 in std::_Hashtable<vtkStringToken, std::pair<vtkStringToken const, std::function<vtkSmartPointer<vtkCellMetadata> (vtkCellGrid*)> >, std::allocator<std::pair<vtkStringToken const, std::function<vtkSmartPointer<vtkCellMetadata> (vtkCellGrid*)> > >, std::__detail::_Select1st, std::equal_to<vtkStringToken>, std::hash<vtkStringToken>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::emplace<std::pair<vtkStringToken, vtkCellMetadata::RegisterType<vtkDGHex>()::{lambda(vtkCellGrid*)#1}> >(std::pair<vtkStringToken, vtkCellMetadata::RegisterType<vtkDGHex>()::{lambda(vtkCellGrid*)#1}>&&) (this=0x55555e9151a0 <vtkCellMetadata::Constructors>) at /usr/include/c++/12/bits/hashtable.h:950
No locals.
#5 0x000055555c115bc2 in std::unordered_map<vtkStringToken, std::function<vtkSmartPointer<vtkCellMetadata> (vtkCellGrid*)>, std::hash<vtkStringToken>, std::equal_to<vtkStringToken>, std::allocator<std::pair<vtkStringToken const, std::function<vtkSmartPointer<vtkCellMetadata> (vtkCellGrid*)> > > >::insert<std::pair<vtkStringToken, vtkCellMetadata::RegisterType<vtkDGHex>()::{lambda(vtkCellGrid*)#1}> >(std::pair<vtkStringToken, vtkCellMetadata::RegisterType<vtkDGHex>()::{lambda(vtkCellGrid*)#1}>&&) (this=0x55555e9151a0 <vtkCellMetadata::Constructors>, __x=...) at /usr/include/c++/12/bits/unordered_map.h:564
No locals.
#6 0x000055555c115868 in vtkCellMetadata::RegisterType<vtkDGHex> () at /home/theodore/Desktop/VTK-9.3.1/Common/DataModel/vtkCellMetadata.h:61
name = {Id = 3849577002, static hash32a_const = 2166136261, static hash32b_const = 16777619, static hash64a_const = 14695981039346656037, static hash64b_const = 1099511628211}
status = {first = {<std::__detail::_Node_iterator_base<std::pair<const vtkStringToken, std::function<vtkSmartPointer<vtkCellMetadata>(vtkCellGrid*)> >, true>> = {_M_cur = 0x0}, <No data fields>}, second = false}
#7 0x000055555c11460c in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /home/theodore/Desktop/VTK-9.3.1/Filters/CellGrid/vtkDGHex.cxx:20
No locals.
#8 0x000055555c1155e9 in _GLOBAL__sub_I_vtkDGHex.cxx(void) () at /home/theodore/Desktop/VTK-9.3.1/Filters/CellGrid/vtkDGHex.cxx:170
No locals.
#9 0x00007ffff7704376 in call_init (env=<optimized out>, argv=0x7fffffffd918, argc=1) at ../csu/libc-start.c:145
j = 0
jm = <optimized out>
addrs = <optimized out>
l = <optimized out>
init_array = <optimized out>
#10 __libc_start_main_impl (main=0x5555561ca520 <main(int, char**)>, argc=1, argv=0x7fffffffd918, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffd908) at ../csu/libc-start.c:347
No locals.
#11 0x0000555556291e41 in _start ()
No symbol table info available.
So the key function here is the static one at vtkCellMetadata.h:60
template <typename Subclass>
static bool RegisterType()
{
vtkStringToken name = vtk::TypeName<Subclass>();
// vtkCellMetadata::Constructors = vtkCellMetadata::ConstructorMap();
auto status = vtkCellMetadata::Constructors.insert(std::make_pair(name, [](vtkCellGrid* grid) {
auto result = vtkSmartPointer<Subclass>::New();
if (result)
{
result->SetCellGrid(grid);
}
return result;
}));
return status.second; // true if insertion occurred.
}
Due to the static initialization order fiasco, vtkCellMetadata::Constructors
is not guaranteed to be initialized when this function is called at Filters/CellGrid/vtkDGHex.cxx:20
static bool registerType = vtkCellMetadata::RegisterType<vtkDGHex>();
The SIGFPE is thrown as the result.
If the map is initialized manually, see the commented out line in the first code block, then the application boots up normally.
It may not be reproducible but here is my compiler:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Debian 12.2.0-14)
The binaries compiled in Ubuntu also suffer from this issue. See binaries released here: Release latest · TLCFEM/prebuilds · GitHub
If this is not considered a bug, is there an initialization function to be called to ensure proper initialization of those static variables?
Also, #19348 looks like a related, proper issue.