We initialize villas::logging as a static member in log.cpp. At the same time several other objects are created as static objects. Some of them (e.g., MemoryManager, DirectedGraph, HostRamAllocator) use the static object to create their own logging instances, i.e., villas::logging.get().
The initialization order of these objects is undefined and thus what we are doing is undefined behavior.
If I activate link time optimization (-lto) I get segmentation faults because the initialization order is different.
I would suggest to move the initialization of these objects to an explicit initialization function, where we can make the initialization order explicit and call this function for example from a library constructor or via a single static initialization.
I only researched this briefly so I may have misunderstood some of this.
We initialize
villas::logging
as a static member inlog.cpp
. At the same time several other objects are created as static objects. Some of them (e.g.,MemoryManager
,DirectedGraph
,HostRamAllocator
) use the static object to create their own logging instances, i.e.,villas::logging.get()
. The initialization order of these objects is undefined and thus what we are doing is undefined behavior. If I activate link time optimization (-lto
) I get segmentation faults because the initialization order is different.I would suggest to move the initialization of these objects to an explicit initialization function, where we can make the initialization order explicit and call this function for example from a library constructor or via a single static initialization.
I only researched this briefly so I may have misunderstood some of this.