Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2k stars 574 forks source link

LTO builds fail on Linux #6575

Closed lazyfrosch closed 6 years ago

lazyfrosch commented 6 years ago

Basically all tests fail right now on e4e2842, build worked fine as far as I see it.

https://build.icinga.com/view/Icinga%202/job/icinga2-snapshot/job/rpm-centos-6-2test/arch=x86_64/215/console

++ sudo icinga2 daemon -C
[2018-08-26 05:27:08 -0400] information/cli: Icinga application loader (version: v2.9.1-127-ge4e2842)
[2018-08-26 05:27:08 -0400] information/cli: Loading configuration file(s).
../cli/daemonutility.cpp:150: assertion failed: systemNS->Get("ApplicationType", &vAppType)
Caught SIGABRT.

Your Environment

lazyfrosch commented 6 years ago

It doesn't happen in local test builds with a newer Boost, not sure if the Boost version matters...

lazyfrosch commented 6 years ago

From what I can see with gdb on CentOS 7 - IcingaApplication::StaticInitialize has been executed, but the value could not be loaded via Namespace:

https://github.com/Icinga/icinga2/blob/e4e28421e8f9f5b4a54a792ec1d12582be43b87b/lib/cli/daemonutility.cpp#L148-L150

(gdb) bt
#0  0x00007ffff57391f7 in raise () from /lib64/libc.so.6
#1  0x00007ffff573a8e8 in abort () from /lib64/libc.so.6
#2  0x00000000005f68fa in icinga_assert_fail(char const*, char const*, int) [clone .local.17613] (expr=<optimized out>, 
    file=<optimized out>, line=<optimized out>) at ../base/debug.hpp:55
Python Exception <type 'exceptions.RuntimeError'> Type is not a template.: 
#3  0x0000000000902850 in icinga::DaemonUtility::ValidateConfigFiles (configs=..., objectsFile=...) at ../cli/daemonutility.cpp:150
Python Exception <type 'exceptions.RuntimeError'> Type is not a template.: 
Python Exception <type 'exceptions.RuntimeError'> Type is not a template.: 
#4  0x0000000000902c3e in icinga::DaemonUtility::LoadConfigFiles (configs=..., newItems=..., objectsFile=..., varsfile=...)
    at ../cli/daemonutility.cpp:172
#5  0x000000000090338f in icinga::DaemonCommand::Run (this=<optimized out>, vm=..., ap=...) at ../cli/daemoncommand.cpp:217
#6  0x000000000090d4d3 in Main () at icinga.cpp:679
#7  0x00000000005ad4f7 in main (argc=4, argv=0x7fffffffe5d8) at icinga.cpp:973
(gdb) fr 3
Python Exception <type 'exceptions.RuntimeError'> Type is not a template.: 
#3  0x0000000000902850 in icinga::DaemonUtility::ValidateConfigFiles (configs=..., objectsFile=...) at ../cli/daemonutility.cpp:150
150 ../cli/daemonutility.cpp: No such file or directory.
(gdb) p vAppType
$1 = Empty
Crunsher commented 6 years ago

I could not reproduce this on Ubuntu Xenial with boost 1.58 nor with Debian Stretch and boost 1.62. Since all fail with the same reason, it may have to do with the docker environment or docker itself :confused:

lazyfrosch commented 6 years ago

I re-tested this without Docker - all on e4e28421e8f9f5b4a54a792ec1d12582be43b87b

wrong test result

Is this related to the build type?

lazyfrosch commented 6 years ago

wrong test result

lazyfrosch commented 6 years ago

My bad on the tests yesterday, I guess i was too tired to notice the difference of the error :disappointed:

Will continue to investigate what's different with the package builds!

lazyfrosch commented 6 years ago

So, looks like this involved the LTO build flag or some other linker flags.

Tested on CentOS 7:

cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DICINGA2_LTO_BUILD=ON -DCMAKE_VERBOSE_MAKEFILE=ON
make install

icinga2 daemon -C
[2018-08-29 20:55:48 +0200] information/cli: Icinga application loader (version: v2.9.1-127-ge4e2842)
[2018-08-29 20:55:48 +0200] information/cli: Loading configuration file(s).
/root/icinga2/lib/cli/daemonutility.cpp:150: assertion failed: systemNS->Get("ApplicationType", &vAppType)
Caught SIGABRT.
Current time: 2018-08-29 20:55:48 +0200

[2018-08-29 20:55:48 +0200] critical/Application: Icinga 2 has terminated unexpectedly. Additional information can be found in '/usr/local/var/log/icinga2/crash/report.1535568948.834137'
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo -DICINGA2_LTO_BUILD=OFF -DCMAKE_VERBOSE_MAKEFILE=ON
make install

# icinga2 daemon -C
[2018-08-29 21:06:50 +0200] information/cli: Icinga application loader (version: v2.9.1-127-ge4e2842)
[2018-08-29 21:06:50 +0200] information/cli: Loading configuration file(s).
...
[2018-08-29 21:06:51 +0200] information/ConfigItem: Instantiated 215 CheckCommands.
[2018-08-29 21:06:51 +0200] information/ScriptGlobal: Dumping variables to file '/usr/local/var/cache/icinga2/icinga2.vars'
[2018-08-29 21:06:51 +0200] information/cli: Finished validating the configuration file(s).

LTO builds are enabled for RPM and Debian builds by default

lazyfrosch commented 6 years ago

Confirmed in Travis here: https://travis-ci.org/Icinga/icinga2/builds/422221143

dnsmichi commented 6 years ago

Unfortunately doesn't happen on macOS with clang and boost 1.67. I'll boot my CentOS dev VM.

Crunsher commented 6 years ago

bt full on ubuntu 16.04 master:

/root/icinga2/lib/cli/daemonutility.cpp:150: assertion failed: systemNS->Get("ApplicationType", &vAppType)

Thread 1 "icinga2" received signal SIGABRT, Aborted.
0x00007ffff7a42428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt full
#0  0x00007ffff7a42428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
        resultvar = 0
        pid = 3916
        selftid = 3916
#1  0x00007ffff7a4402a in __GI_abort () at abort.c:89
        save_stage = 2
        act = {__sigaction_handler = {sa_handler = 0x96, sa_sigaction = 0x96}, sa_mask = {__val = {9582528, 140737488326560, 140737488326672, 1, 5893688, 140737488326656, 140737488326496, 107, 
              140737348911837, 140737351858032, 107, 140737488315856, 140737354020672, 107, 0, 140737488326672}}, sa_flags = 9359978, sa_restorer = 0x7fffffff8fd0}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00000000005630da in icinga_assert_fail(char const*, char const*, int) (expr=<optimized out>, file=<optimized out>, line=<optimized out>) at /root/icinga2/lib/base/debug.hpp:55
No locals.
#3  0x00000000006e2584 in icinga::DaemonUtility::ValidateConfigFiles(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, icinga::String const&) (configs=..., objectsFile=...) at /root/icinga2/lib/cli/daemonutility.cpp:150
        success = true
        zonesEtcDir = {m_Data = <incomplete type>}
        packagesVarDir = {m_Data = <incomplete type>}
        zonesVarDir = {m_Data = <incomplete type>}
        systemNS = {px = 0xcbb540}
        vAppType = {m_Value = {which_ = 0, storage_ = {<No data fields>}}}
        appType = {px = 0x0}
#4  0x00000000006e2b32 in icinga::DaemonUtility::LoadConfigFiles(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, std::vector<boost::intrusive_ptr<icinga::ConfigItem>, std::allocator<boost::intrusive_ptr<icinga::ConfigItem> > >&, icinga::String const&, icinga::String const&) (configs=..., newItems=..., objectsFile=..., varsfile=...) at /root/icinga2/lib/cli/daemonutility.cpp:172
        ascope = {m_Context = {px = 0xcde0b0}}
        upq = {m_ID = 0, m_Name = {m_Data = <incomplete type>}, m_ThreadCount = 0, m_Spawned = false, m_Mutex = {m = {__data = {__lock = 3, __count = 110, __owner = 31, __nusers = 0, 
                __kind = -27456, __spins = 32767, __elision = 0, __list = {__prev = 0x7c00000077, __next = 0x0}}, 
              __size = "\003\000\000\000n\000\000\000\037\000\000\000\000\000\000\000\300\224\377\377\377\177\000\000w\000\000\000|\000\000\000\000\000\000\000\000\000\000", 
              __align = 472446402563}}, m_CVEmpty = {internal_mutex = {__data = {__lock = 0, __count = 0, __owner = 27457, __nusers = 4294934528, __kind = -27457, __spins = 32767, 
                __elision = 0, __list = {__prev = 0x0, __next = 0x3000000003}}, 
              __size = "\000\000\000\000\000\000\000\000Ak\000\000\000\200\377\377\277\224\377\377\377\177\000\000\000\000\000\000\000\000\000\000\003\000\000\000\060\000\000", __align = 0}, 
            cond = {__data = {__lock = 0, __futex = 0, __total_seq = 0, __wakeup_seq = 91, __woken_seq = 0, __mutex = 0x0, __nwaiters = 119, __broadcast_seq = 124}, 
              __size = '\000' <repeats 16 times>, "[", '\000' <repeats 23 times>, "w\000\000\000|\000\000", __align = 0}}, m_CVFull = {internal_mutex = {__data = {__lock = 0, __count = 0, 
                __owner = 1, __nusers = 0, __kind = -27360, __spins = 32767, __elision = 0, __list = {__prev = 0x7ffff629ae78 <operator new(unsigned long)+24>, __next = 0x1e}}, 
              __size = "\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000 \225\377\377\377\177\000\000x\256)\366\377\177\000\000\036\000\000\000\000\000\000", __align = 0}, 
            cond = {__data = {__lock = 6182920, __futex = 0, __total_seq = 31, __wakeup_seq = 140737488330168, __woken_seq = 140737488328296, __mutex = 0x7fffffff9668, __nwaiters = 4294942120, 
                __broadcast_seq = 32767}, 
              __size = "\bX^\000\000\000\000\000\037\000\000\000\000\000\000\000\270\235\377\377\377\177\000\000h\226\377\377\377\177\000\000h\226\377\377\377\177\000\000\250\235\377\377\377\177\000", __align = 6182920}}, m_CVStarved = {internal_mutex = {__data = {__lock = -15496, __count = 32767, __owner = -134334760, __nusers = 32767, __kind = -139913924, __spins = 32767, 
                __elision = 0, __list = {__prev = 0x7ffff7fe36d8, __next = 0x7ffff7a9153c <__GI___libc_free+76>}}, 
              __size = "x\303\377\377\377\177\000\000\330\066\376\367\377\177\000\000<\025\251\367\377\177\000\000\330\066\376\367\377\177\000\000<\025\251\367\377\177\000", 
              __align = 140737488339832}, cond = {__data = {__lock = -26544, __futex = 32767, __total_seq = 5874168, __wakeup_seq = 30, __woken_seq = 140737488330168, __mutex = 0x7fffffff9e28, 
                __nwaiters = 4294940264, __broadcast_seq = 32767}, 
              __size = "P\230\377\377\377\177\000\000\370\241Y\000\000\000\000\000\036\000\000\000\000\000\000\000\270\235\377\377\377\177\000\000(\236\377\377\377\177\000\000h\226\377\377\377\177\000", __align = 140737488328784}}, m_Threads = {threads = {<No data fields>}, m = {state = {shared_count = 5915742, exclusive = false, upgrade = false, exclusive_waiting_blocked = false}, 
              state_change = {m = {__data = {__lock = 625120, __count = 0, __owner = 513, __nusers = 0, __kind = -27120, __spins = 32767, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, 
                  __size = "\340\211\t\000\000\000\000\000\001\002\000\000\000\000\000\000\020\226\377\377\377\177", '\000' <repeats 17 times>, __align = 625120}}, shared_cond = {
                internal_mutex = {__data = {__lock = 0, __count = 0, __owner = 27121, __nusers = 4294934528, __kind = -27121, __spins = 32767, __elision = 0, __list = {__prev = 0x8, 
                      __next = 0x3800000021}}, 
                  __size = "\000\000\000\000\000\000\000\000\361i\000\000\000\200\377\377\017\226\377\377\377\177\000\000\b\000\000\000\000\000\000\000!\000\000\000\070\000\000", __align = 0}, 
---Type <return> to continue, or q <return> to quit---
                cond = {__data = {__lock = 1, __futex = 0, __total_seq = 0, __wakeup_seq = 472446402652, __woken_seq = 0, __mutex = 0x0, __nwaiters = 119, __broadcast_seq = 124}, 
                  __size = "\001", '\000' <repeats 15 times>, "\\\000\000\000n", '\000' <repeats 19 times>, "w\000\000\000|\000\000", __align = 1}}, exclusive_cond = {internal_mutex = {
                  __data = {__lock = 2026619464, __count = 1104601933, __owner = 2, __nusers = 0, __kind = -27088, __spins = 32767, __elision = 0, __list = {__prev = 0x3, 
                      __next = 0x696c63 <icinga::DeleteObjectHandler::HandleRequest(boost::intrusive_ptr<icinga::ApiUser> const&, icinga::HttpRequest&, icinga::HttpResponse&, boost::intrusive_ptr<icinga::Dictionary> const&)+2611>}}, __size = "H\302\313xM\343\326A\002\000\000\000\000\000\000\000\060\226\377\377\377\177\000\000\003\000\000\000\000\000\000\000cli\000\000\000\000", 
                  __align = 4744229179360002632}, cond = {__data = {__lock = -26928, __futex = 32767, __total_seq = 13494064, __wakeup_seq = 30, __woken_seq = 30, 
                    __mutex = 0x7ffff7a91184 <__GI___libc_malloc+84>, __nwaiters = 13494016, __broadcast_seq = 0}, 
                  __size = "\320\226\377\377\377\177\000\000\060\347\315\000\000\000\000\000\036\000\000\000\000\000\000\000\036\000\000\000\000\000\000\000\204\021\251\367\377\177\000\000\000\347\315\000\000\000\000", __align = 140737488328400}}, upgrade_cond = {internal_mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = -27032, __spins = 32767, 
                    __elision = 0, __list = {__prev = 0x7fffffff9668, __next = 0x0}}, 
                  __size = '\000' <repeats 16 times>, "h\226\377\377\377\177\000\000h\226\377\377\377\177\000\000\000\000\000\000\000\000\000", __align = 0}, cond = {__data = {
                    __lock = -161994664, __futex = 32767, __total_seq = 140737323862863, __wakeup_seq = 140737488330176, __woken_seq = 140737488330176, __mutex = 0x4c, __nwaiters = 4130475352, 
                    __broadcast_seq = 32767}, 
                  __size = "X(X\366\377\177\000\000O\v2\366\377\177\000\000\300\235\377\377\377\177\000\000\300\235\377\377\377\177\000\000L\000\000\000\000\000\000\000X\r2\366\377\177\000", 
                  __align = 140737326360664}}}}, m_MaxItems = 140737488328400, m_Stopped = false, m_Processing = 0, m_Tasks = {c = {<No data fields>}, comp = {<No data fields>}}, 
          m_NextTaskID = -164450725, m_ExceptionCallback = {_M_invoker = 0x7fffffff9da8}, m_Exceptions = {<No data fields>}, m_StatusTimer = {px = 0xcde190}, m_StatusTimerTimeout = 0, 
          m_TaskStats = {m_Mutex = {m = {__data = {__lock = -25048, __count = 32767, __owner = -25343, __nusers = 32767, __kind = -15520, __spins = 32767, __elision = 0, __list = {
                    __prev = 0x7fffffff9850, __next = 0x7fffffffc378}}, 
                __size = "(\236\377\377\377\177\000\000\001\235\377\377\377\177\000\000`\303\377\377\377\177\000\000P\230\377\377\377\177\000\000x\303\377\377\377\177\000", 
                __align = 140737488330280}}, m_Slots = {<No data fields>}, m_TimeValue = 140737348441404, m_InsertedValues = 140737488330152}, m_PendingTasks = 140737488339832, 
          m_PendingTasksTimestamp = 6.9533491708160085e-310}
        result = <optimized out>
#5  0x00000000006e3377 in icinga::DaemonCommand::Run(boost::program_options::variables_map const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&) const (this=<optimized out>, vm=..., ap=...)
    at /root/icinga2/lib/cli/daemoncommand.cpp:217
        configs = {<No data fields>}
        newItems = {<No data fields>}
        sa = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
#6  0x0000000000592b99 in Main () at /root/icinga2/icinga-app/icinga.cpp:679
        args = {<No data fields>}
        argc = 6
        argv = 0x7fffffffe5d8
        autocomplete = false
        autoindex = 0
        icingaUser = {m_Data = <incomplete type>}
        icingaGroup = {m_Data = <incomplete type>}
        visibleDesc = {m_caption = <incomplete type>, m_line_length = 80, m_min_description_length = 40, m_options = {<No data fields>}, belong_to_group = {<No data fields>}, 
          groups = {<No data fields>}}
        hiddenDesc = {m_caption = <incomplete type>, m_line_length = 80, m_min_description_length = 40, m_options = {<No data fields>}, belong_to_group = {<No data fields>}, 
          groups = {<No data fields>}}
        positionalDesc = {m_names = {<No data fields>}, m_trailing = <incomplete type>}
        cmdname = {m_Data = <incomplete type>}
        command = {px = 0xd7bc80}
        vm = <incomplete type>
        rc = 1
#7  0x000000000054ca57 in main (argc=6, argv=0x7fffffffe5d8) at /root/icinga2/icinga-app/icinga.cpp:973
        rc = <optimized out>
dnsmichi commented 6 years ago

Compiling on Fedora 28 now with physical hardware (8 cpus, 16gb ram).

(gdb) p *systemNS.px
$2 = {<icinga::Object> = {_vptr.Object = 0xd206b8 <vtable for icinga::Namespace+16>, m_References = 2, m_Mutex = 21167824, m_LockOwner = 0, m_LockCount = 0}, static TypeInstance = {px = 0x1437000}, 
  m_Data = std::map with 71 elements = {[{static NPos = 18446744073709551615, m_Data = "BuildCompilerName"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14717f0}, [{
      static NPos = 18446744073709551615, m_Data = "BuildCompilerVersion"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14718a0}, [{static NPos = 18446744073709551615, 
      m_Data = "BuildHostName"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1471740}, [{static NPos = 18446744073709551615, 
      m_Data = "Configuration"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14326f0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityAuth"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143d9e0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityAuthPriv"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x145e840}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityCron"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14607f0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityDaemon"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14647a0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityFtp"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14647f0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityKern"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1464840}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityLocal0"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14540f0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityLocal1"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1454140}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityLocal2"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1454190}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityLocal3"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14541e0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityLocal4"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1454230}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityLocal5"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1454280}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityLocal6"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14542d0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityLocal7"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1454320}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityLpr"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1454370}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityMail"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14543c0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityNews"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1454410}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilitySyslog"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1454460}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityUser"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14544b0}, [{static NPos = 18446744073709551615, 
      m_Data = "FacilityUucp"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1454500}, [{static NPos = 18446744073709551615, 
      m_Data = "GlobDirectory"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1469420}, [{static NPos = 18446744073709551615, 
      m_Data = "GlobFile"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1469370}, [{static NPos = 18446744073709551615, 
      m_Data = "Json"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1469050}, [{static NPos = 18446744073709551615, 
      m_Data = "LogCritical"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1470210}, [{static NPos = 18446744073709551615, 
      m_Data = "LogDebug"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x146ff50}, [{static NPos = 18446744073709551615, 
      m_Data = "LogInformation"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14700b0}, [{static NPos = 18446744073709551615, 
      m_Data = "LogNotice"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1470000}, [{static NPos = 18446744073709551615, 
      m_Data = "LogWarning"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1470160}, [{static NPos = 18446744073709551615, 
      m_Data = "MatchAll"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1469210}, [{static NPos = 18446744073709551615, 
      m_Data = "MatchAny"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14692c0}, [{static NPos = 18446744073709551615, 
      m_Data = "Math"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1466ed0}, [{static NPos = 18446744073709551615, 
      m_Data = "PlatformArchitecture"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1471690}, [{static NPos = 18446744073709551615, 
      m_Data = "PlatformKernel"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1471310}, [{static NPos = 18446744073709551615, 
      m_Data = "PlatformKernelVersion"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1471410}, [{static NPos = 18446744073709551615, 
      m_Data = "PlatformName"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1471500}, [{static NPos = 18446744073709551615, 
      m_Data = "PlatformVersion"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14715e0}, [{static NPos = 18446744073709551615, 
      m_Data = "assert"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143e2a0}, [{static NPos = 18446744073709551615, 
      m_Data = "basename"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14405b0}, [{static NPos = 18446744073709551615, 
      m_Data = "bool"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1440f50}, [{static NPos = 18446744073709551615, 
      m_Data = "cidr_match"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143fca0}, [{static NPos = 18446744073709551615, 
---Type <return> to continue, or q <return> to quit---
      m_Data = "dirname"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143d0e0}, [{static NPos = 18446744073709551615, 
      m_Data = "escape_shell_arg"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143ccc0}, [{static NPos = 18446744073709551615, 
      m_Data = "escape_shell_cmd"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143f0f0}, [{static NPos = 18446744073709551615, 
      m_Data = "exit"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143ef10}, [{static NPos = 18446744073709551615, 
      m_Data = "get_object"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143e3b0}, [{static NPos = 18446744073709551615, 
      m_Data = "get_objects"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1442000}, [{static NPos = 18446744073709551615, 
      m_Data = "get_time"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143d2c0}, [{static NPos = 18446744073709551615, 
      m_Data = "glob"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143c460}, [{static NPos = 18446744073709551615, 
      m_Data = "glob_recursive"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143df10}, [{static NPos = 18446744073709551615, 
      m_Data = "intersection"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143f580}, [{static NPos = 18446744073709551615, 
      m_Data = "keys"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143eb50}, [{static NPos = 18446744073709551615, 
      m_Data = "len"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143f970}, [{static NPos = 18446744073709551615, 
      m_Data = "log"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143f410}, [{static NPos = 18446744073709551615, 
      m_Data = "match"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1443300}, [{static NPos = 18446744073709551615, 
      m_Data = "msi_get_component_path"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14403d0}, [{static NPos = 18446744073709551615, 
      m_Data = "number"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1441130}, [{static NPos = 18446744073709551615, 
      m_Data = "parse_performance_data"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143b2e0}, [{static NPos = 18446744073709551615, 
      m_Data = "path_exists"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143e090}, [{static NPos = 18446744073709551615, 
      m_Data = "ptr"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143e970}, [{static NPos = 18446744073709551615, 
      m_Data = "random"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14421b0}, [{static NPos = 18446744073709551615, 
      m_Data = "range"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x14426e0}, [{static NPos = 18446744073709551615, 
      m_Data = "regex"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1443550}, [{static NPos = 18446744073709551615, 
      m_Data = "sleep"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143c5b0}, [{static NPos = 18446744073709551615, 
      m_Data = "string"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x1440d70}, [{static NPos = 18446744073709551615, 
      m_Data = "track_parents"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143ced0}, [{static NPos = 18446744073709551615, 
      m_Data = "typeof"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143ed30}, [{static NPos = 18446744073709551615, 
      m_Data = "union"}] = std::shared_ptr<icinga::NamespaceValue> (use count 1, weak count 0) = {get() = 0x143f790}}, m_Behavior = std::unique_ptr<icinga::NamespaceBehavior> = {get() = 0x14325b0}}

The assert is correct about not returning any value here, neither ApplicationType nor NodeName exist in this scope. I believe that this is an ordering problem where LTO puts the StaticInitialize() methods away for some reason and they are never called.

dnsmichi commented 6 years ago

A good read: https://isocpp.org/wiki/faq/ctors#static-init-order loosely related though, but definitely a problem with the static initializers we keep using.

dnsmichi commented 6 years ago

lto on f28 seems to be broken with gcc 8.1.1, the builds crash a lot with internal errors and take quite some time. Not sure if it is a good thing to generally enable this compile time option.

dnsmichi commented 6 years ago

For some reason, System.* set via IcingaApplication StaticInitialize() are not available in the System's namespace later on. NodeName for example is.

[2018-09-03 22:00:58 +0200] information/cli: Loading configuration file(s).
Global NS: {
    ActiveStages = {
        _api = "imagine-1441134214-2"
    }
    Environment = "production"
    ExcludeSnmpDevTypes = [ "websuite", "vpn" ]
    Icinga = {
        Acknowledgement = "Acknowledgement"
        Critical = "Critical"
        Custom = "Custom"
        DbCatAcknowledgement = 4.000000
        DbCatCheck = 256.000000
        DbCatComment = 8.000000
        DbCatConfig = 1.000000
        DbCatDowntime = 16.000000
        DbCatEventHandler = 32.000000
        DbCatEverything = -1.000000
        DbCatExternalCommand = 64.000000
        DbCatFlapping = 128.000000
        DbCatLog = 512.000000
        DbCatNotification = 1024.000000
        DbCatProgramStatus = 2048.000000
        DbCatRetention = 4096.000000
        DbCatState = 2.000000
        DbCatStateHistory = 8192.000000
        Down = "Down"
        DowntimeEnd = "DowntimeEnd"
        DowntimeNoChildren = "DowntimeNoChildren"
        DowntimeNonTriggeredChildren = "DowntimeNonTriggeredChildren"
        DowntimeRemoved = "DowntimeRemoved"
        DowntimeStart = "DowntimeStart"
        DowntimeTriggeredChildren = "DowntimeTriggeredChildren"
        FlappingEnd = "FlappingEnd"
        FlappingStart = "FlappingStart"
        HostDown = 1.000000
        HostUp = 0.000000
        OK = "OK"
        Problem = "Problem"
        Recovery = "Recovery"
        ServiceCritical = 2.000000
        ServiceOK = 0.000000
        ServiceUnknown = 3.000000
        ServiceWarning = 1.000000
        Unknown = "Unknown"
        Up = "Up"
        Warning = "Warning"
        get_check_command = {
            type = "Function"
        }
        get_event_command = {
            type = "Function"
        }
        get_host = {
            type = "Function"
        }
        get_host_group = {
            type = "Function"
        }
        get_notification_command = {
            type = "Function"
        }
        get_service = {
            type = "Function"
        }
        get_service_group = {
            type = "Function"
        }
        get_services = {
            type = "Function"
        }
        get_time_period = {
            type = "Function"
        }
        get_user = {
            type = "Function"
        }
        get_user_group = {
            type = "Function"
        }
    }
    Internal = {
        run_with_activation_context = {
            type = "Function"
        }
    }
    MaxConcurrentChecks = 512.000000
    NodeName = "imagine"
    PluginDir = "/usr/lib64/nagios/plugins"
    SnmpCommunity = "blablub"
    StatsFunctions = {
        ApiListener = {
            type = "Function"
        }
        CIB = {
            type = "Function"
        }
        CheckResultReader = {
            type = "Function"
        }
        CheckerComponent = {
            type = "Function"
        }
        CompatLogger = {
            type = "Function"
        }
        ElasticsearchWriter = {
            type = "Function"
        }
        ExternalCommandListener = {
            type = "Function"
        }
        FileLogger = {
            type = "Function"
        }
        GelfWriter = {
            type = "Function"
        }
        GraphiteWriter = {
            type = "Function"
        }
        IcingaApplication = {
            type = "Function"
        }
        IdoMysqlConnection = {
            type = "Function"
        }
        IdoPgsqlConnection = {
            type = "Function"
        }
        InfluxdbWriter = {
            type = "Function"
        }
        LivestatusListener = {
            type = "Function"
        }
        NotificationComponent = {
            type = "Function"
        }
        OpenTsdbWriter = {
            type = "Function"
        }
        PerfdataWriter = {
            type = "Function"
        }
        StatusDataWriter = {
            type = "Function"
        }
        SyslogLogger = {
            type = "Function"
        }
    }
    System = {
        BuildCompilerName = "GNU"
        BuildCompilerVersion = "8.1.1"
        BuildHostName = "imagine"
        Configuration = {
            type = "Configuration"
        }
        FacilityAuth = "LOG_AUTH"
        FacilityAuthPriv = "LOG_AUTHPRIV"
        FacilityCron = "LOG_CRON"
        FacilityDaemon = "LOG_DAEMON"
        FacilityFtp = "LOG_FTP"
        FacilityKern = "LOG_KERN"
        FacilityLocal0 = "LOG_LOCAL0"
        FacilityLocal1 = "LOG_LOCAL1"
        FacilityLocal2 = "LOG_LOCAL2"
        FacilityLocal3 = "LOG_LOCAL3"
        FacilityLocal4 = "LOG_LOCAL4"
        FacilityLocal5 = "LOG_LOCAL5"
        FacilityLocal6 = "LOG_LOCAL6"
        FacilityLocal7 = "LOG_LOCAL7"
        FacilityLpr = "LOG_LPR"
        FacilityMail = "LOG_MAIL"
        FacilityNews = "LOG_NEWS"
        FacilitySyslog = "LOG_SYSLOG"
        FacilityUser = "LOG_USER"
        FacilityUucp = "LOG_UUCP"
        GlobDirectory = 2.000000
        GlobFile = 1.000000
        Json = {
            decode = {
                type = "Function"
            }
            encode = {
                type = "Function"
            }
        }
        LogCritical = 4.000000
        LogDebug = 0.000000
        LogInformation = 2.000000
        LogNotice = 1.000000
        LogWarning = 3.000000
        MatchAll = 0.000000
        MatchAny = 1.000000
        Math = {
            E = 2.718282
            LN10 = 2.302585
            LN2 = 0.693147
            LOG10E = 0.434294
            LOG2E = 1.442695
            PI = 3.141593
            SQRT1_2 = 0.707107
            SQRT2 = 1.414214
            abs = {
                type = "Function"
            }
            acos = {
                type = "Function"
            }
            asin = {
                type = "Function"
            }
            atan = {
                type = "Function"
            }
            atan2 = {
                type = "Function"
            }
            ceil = {
                type = "Function"
            }
            cos = {
                type = "Function"
            }
            exp = {
                type = "Function"
            }
            floor = {
                type = "Function"
            }
            isinf = {
                type = "Function"
            }
            isnan = {
                type = "Function"
            }
            log = {
                type = "Function"
            }
            max = {
                type = "Function"
            }
            min = {
                type = "Function"
            }
            pow = {
                type = "Function"
            }
            random = {
                type = "Function"
            }
            round = {
                type = "Function"
            }
            sign = {
                type = "Function"
            }
            sin = {
                type = "Function"
            }
            sqrt = {
                type = "Function"
            }
            tan = {
                type = "Function"
            }
        }
        PlatformArchitecture = "x86_64"
        PlatformKernel = "Linux"
        PlatformKernelVersion = "4.17.7-200.fc28.x86_64"
        PlatformName = "Fedora"
        PlatformVersion = "28 (Workstation Edition)"
        assert = {
            type = "Function"
        }
        basename = {
            type = "Function"
        }
        bool = {
            type = "Function"
        }
        cidr_match = {
            type = "Function"
        }
        dirname = {
            type = "Function"
        }
        escape_shell_arg = {
            type = "Function"
        }
        escape_shell_cmd = {
            type = "Function"
        }
        exit = {
            type = "Function"
        }
        get_object = {
            type = "Function"
        }
        get_objects = {
            type = "Function"
        }
        get_time = {
            type = "Function"
        }
        glob = {
            type = "Function"
        }
        glob_recursive = {
            type = "Function"
        }
        intersection = {
            type = "Function"
        }
        keys = {
            type = "Function"
        }
        len = {
            type = "Function"
        }
        log = {
            type = "Function"
        }
        match = {
            type = "Function"
        }
        msi_get_component_path = {
            type = "Function"
        }
        number = {
            type = "Function"
        }
        parse_performance_data = {
            type = "Function"
        }
        path_exists = {
            type = "Function"
        }
        ptr = {
            type = "Function"
        }
        random = {
            type = "Function"
        }
        range = {
            type = "Function"
        }
        regex = {
            type = "Function"
        }
        sleep = {
            type = "Function"
        }
        string = {
            type = "Function"
        }
        track_parents = {
            type = "Function"
        }
        typeof = {
            type = "Function"
        }
        union = {
            type = "Function"
        }
    }
    TicketSalt = "53e2933de37b626b537dee4dff608958"
    Types = {
        ApiListener = {
            type = "Type"
        }
        ApiUser = {
            type = "Type"
        }
        Application = {
            type = "Type"
        }
        Array = {
            type = "Type"
        }
        Boolean = {
            type = "Type"
        }
        CheckCommand = {
            type = "Type"
        }
        CheckResult = {
            type = "Type"
        }
        CheckResultReader = {
            type = "Type"
        }
        Checkable = {
            type = "Type"
        }
        CheckerComponent = {
            type = "Type"
        }
        Command = {
            type = "Type"
        }
        Comment = {
            type = "Type"
        }
        CompatLogger = {
            type = "Type"
        }
        ConfigObject = {
            type = "Type"
        }
        Configuration = {
            type = "Type"
        }
        CustomVarObject = {
            type = "Type"
        }
        DateTime = {
            type = "Type"
        }
        DbConnection = {
            type = "Type"
        }
        Dependency = {
            type = "Type"
        }
        Dictionary = {
            type = "Type"
        }
        Downtime = {
            type = "Type"
        }
        ElasticsearchWriter = {
            type = "Type"
        }
        Endpoint = {
            type = "Type"
        }
        EventCommand = {
            type = "Type"
        }
        ExternalCommandListener = {
            type = "Type"
        }
        FileLogger = {
            type = "Type"
        }
        Function = {
            type = "Type"
        }
        GelfWriter = {
            type = "Type"
        }
        GraphiteWriter = {
            type = "Type"
        }
        Host = {
            type = "Type"
        }
        HostGroup = {
            type = "Type"
        }
        IcingaApplication = {
            type = "Type"
        }
        IdoMysqlConnection = {
            type = "Type"
        }
        IdoPgsqlConnection = {
            type = "Type"
        }
        InfluxdbWriter = {
            type = "Type"
        }
        LivestatusListener = {
            type = "Type"
        }
        Logger = {
            type = "Type"
        }
        Namespace = {
            type = "Type"
        }
        Notification = {
            type = "Type"
        }
        NotificationCommand = {
            type = "Type"
        }
        NotificationComponent = {
            type = "Type"
        }
        Number = {
            type = "Type"
        }
        Object = {
            type = "Type"
        }
        OpenTsdbWriter = {
            type = "Type"
        }
        PerfdataValue = {
            type = "Type"
        }
        PerfdataWriter = {
            type = "Type"
        }
        Reference = {
            type = "Type"
        }
        ScheduledDowntime = {
            type = "Type"
        }
        Service = {
            type = "Type"
        }
        ServiceGroup = {
            type = "Type"
        }
        StatusDataWriter = {
            type = "Type"
        }
        StreamLogger = {
            type = "Type"
        }
        String = {
            type = "Type"
        }
        SyslogLogger = {
            type = "Type"
        }
        TimePeriod = {
            type = "Type"
        }
        Type = {
            type = "Type"
        }
        User = {
            type = "Type"
        }
        UserGroup = {
            type = "Type"
        }
        Zone = {
            type = "Type"
        }
    }
    ZoneName = "imagine"
    f = {
        type = "Function"
    }
    get_host_interfaces = {
        type = "Function"
    }
    test = {
        type = "Function"
    }
}
[2018-09-03 22:00:58 +0200] critical/Application: Error: Namespace does not contain field 'ApplicationType'
diff --git a/lib/cli/daemonutility.cpp b/lib/cli/daemonutility.cpp
index ea1630c8a..fa278d6d5 100644
--- a/lib/cli/daemonutility.cpp
+++ b/lib/cli/daemonutility.cpp
@@ -21,6 +21,7 @@
 #include "base/utility.hpp"
 #include "base/logger.hpp"
 #include "base/application.hpp"
+#include "base/serializer.hpp"
 #include "config/configcompiler.hpp"
 #include "config/configcompilercontext.hpp"
 #include "config/configitembuilder.hpp"
@@ -145,9 +146,16 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
        if (!success)
                return false;

+
        Namespace::Ptr systemNS = ScriptGlobal::Get("System");
-       Value vAppType;
-       VERIFY(systemNS->Get("ApplicationType", &vAppType));
+       std::cout << "Global NS: " << Serialize(ScriptGlobal::GetGlobals()) << std::endl;
+
+       Value vAppType = systemNS->Get("ApplicationType");
+
+//     Value vAppType;
+//     VERIFY(systemNS->Get("ApplicationType", &vAppType));

moving those code parts into icinga-app don't solve the underlying problem though, as in a later step the config compiler cannot find the script variables.

[2018-09-03 22:13:14 +0200] critical/config: Error: Error while evaluating expression: Tried to access undefined script variable 'OK'
Location: in /etc/icinga2/conf.d/templates.conf: 65:14-65:15
/etc/icinga2/conf.d/templates.conf(63):   command = "mail-service-notification"
/etc/icinga2/conf.d/templates.conf(64): 
/etc/icinga2/conf.d/templates.conf(65):   states = [ OK, Warning, Critical, Unknown ]
                                                     ^^

StaticInitialize() definitely is called, still those Namespace registrations happen from various sides. No idea so far what's going on with LTO here, need a fresh look tomorrow. Poke @gunnarbeutner ;)

dnsmichi commented 6 years ago

I'm now working on an Ubuntu box granted by @Crunsher with more resources.

Interestingly enough, the System namespace isn't created nor available in IcingaApplication::StaticInitialize() at this point.

diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp
index 28ca04b..c1a4b86 100644
--- a/lib/icinga/icingaapplication.cpp
+++ b/lib/icinga/icingaapplication.cpp
@@ -59,9 +59,13 @@ void IcingaApplication::StaticInitialize()

        ScriptGlobal::Set("NodeName", node_name);

-       ScriptGlobal::Set("System.ApplicationType", "IcingaApplication", true);
+       Namespace::Ptr systemNS = ScriptGlobal::Get("System");
+       systemNS->Set("ApplicationType", "IcingaApplication", true);
+       systemNS->Set("ApplicationVersion", Application::GetAppVersion(), true);

-       ScriptGlobal::Set("System.ApplicationVersion", Application::GetAppVersion(), true);
+//     ScriptGlobal::Set("System.ApplicationType", "IcingaApplication", true);
+
+//     ScriptGlobal::Set("System.ApplicationVersion", Application::GetAppVersion(), true);
root@jflach:~/icinga2# /root/i2/lib/icinga2/sbin/icinga2 daemon -DRunAsUser=nagios -DRunAsGroup=nagios
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::invalid_argument> >'
  what():  Tried to access undefined script variable 'System'
Aborted (core dumped)

Since I've read a lot about the Loader and DeferredInitializers yesterday evening, I now know that the macro INITIALIZE_ONCE_WITH_PRIORITY inserts the task into a priority queue. The higher the value, the faster things are initialized.

Registration: lib/base/initialize.hpp -> icinga::InitializeOnceHelper -> Loader::AddDeferredInitializer()

Execution of static initializers: int main() -> Application::InitializeBase() -> Loader::ExecuteDeferredInitializers()

So, where's the code which creates the System namespace? Right, another INITIALIZE_ONCE_WITH_PRIORITY call in scriptframe.cpp

Actually with the same priority (50) as the one for the IcingaApplication. It seems that the optimizations involved with LTO actually create byte code which invokes the IcingaApplication setters first, and later override them in the ScriptFrame initializer.

That is why the System namespace doesn't hold the ApplicationType/Version constants, but globals for example has NodeName.

Changing the initialize once priority for the scriptframe initializer solves the problem with LTO builds. I have a patch nearly ready.

dnsmichi commented 6 years ago

Triggered a snapshot build run: https://build.icinga.com/view/Icinga%202/job/icinga2-snapshot/job/rpm-centos-7-2test/210/console