https://bugs.meego.com/show_bug.cgi?id=19464
--- Comment #12 from pohly <[email protected]> 2011-07-08 19:27:34 UTC --- Okay, got it. Now I just need some C++ expert who can tell me whether it is a bug in the code or in my understanding of the language. The problem is that syncPropDefaultPeer, the property description of "defaultPeer", doesn't get initialized in the order in which it should be initialized. What happens is this: Breakpoint 17, SyncEvo::SyncConfig::getRegistry () at /home/pohly/syncevolution/syncevolution/src/syncevo/SyncConfig.cpp:1549 1549 syncPropDefaultPeer.setSharing(ConfigProperty::GLOBAL_SHARING); (gdb) where #0 SyncEvo::SyncConfig::getRegistry () at /home/pohly/syncevolution/syncevolution/src/syncevo/SyncConfig.cpp:1549 #1 0x0000000000673402 in SyncEvo::RegisterWebDAVSyncSource::RegisterWebDAVSyncSource (this=0xc96f60) at /home/pohly/syncevolution/syncevolution/src/backends/webdav/WebDAVSourceRegister.cpp:80 #2 0x00000000006731fb in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /home/pohly/syncevolution/syncevolution/src/backends/webdav/WebDAVSourceRegister.cpp:82 #3 0x0000000000673227 in _GLOBAL__sub_I_WebDAVSourceRegister.cpp(void) () at /home/pohly/syncevolution/syncevolution/src/backends/webdav/WebDAVSourceRegister.cpp:302 #4 0x00000000009376ad in __libc_csu_init () #5 0x00007ffff548de40 in __libc_start_main (main=<value optimized out>, argc=<value optimized out>, ubp_av=<value optimized out>, init=0x937650 <__libc_csu_init>, fini=0x7ffff57eeec8 <main_arena+104>, rtld_fini=0x7fffffffe280, stack_end=0x7fffffffe418) at libc-start.c:187 #6 0x0000000000647b59 in _start () ^^^^^^^^^^^^^^ getRegistry() in SyncConfig.cpp gets called and sets the non-default GLOBAL_SHARING in the static syncPropDefaultPeer instance. (gdb) watch syncPropDefaultPeer.m_sharing Hardware watchpoint 19: syncPropDefaultPeer.m_sharing ^^^^^^^^^^^^^^^ Let's see where that gets reset. (gdb) c Continuing. Hardware watchpoint 19: syncPropDefaultPeer.m_sharing Old value = SyncEvo::ConfigProperty::GLOBAL_SHARING New value = SyncEvo::ConfigProperty::NO_SHARING 0x0000000000680383 in SyncEvo::ConfigProperty::ConfigProperty (this=0xc98200, name=..., comment=..., def=..., descr=...) at /home/pohly/syncevolution/syncevolution/src/syncevo/SyncConfig.h:247 247 m_descr(descr) (gdb) where #0 0x0000000000680383 in SyncEvo::ConfigProperty::ConfigProperty (this=0xc98200, name=..., comment=..., def=..., descr=...) at /home/pohly/syncevolution/syncevolution/src/syncevo/SyncConfig.h:247 #1 0x00000000007963ac in SyncEvo::SafeConfigProperty::SafeConfigProperty (this=0xc98200, name=..., comment=...) at /home/pohly/syncevolution/syncevolution/src/syncevo/SyncConfig.h:880 #2 0x0000000000791128 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /home/pohly/syncevolution/syncevolution/src/syncevo/SyncConfig.cpp:1372 #3 0x0000000000795ad7 in _GLOBAL__sub_I__ZN7SyncEvo19SourceAdminDataNameE () at /home/pohly/syncevolution/syncevolution/src/syncevo/SyncConfig.cpp:2899 #4 0x00000000009376ad in __libc_csu_init () #5 0x00007ffff548de40 in __libc_start_main (main=<value optimized out>, argc=<value optimized out>, ubp_av=<value optimized out>, init=0x937650 <__libc_csu_init>, fini=0x7fffffffd1c0, rtld_fini=0x7ffff558b390 <__memcpy_ssse3+8192>, stack_end=0x7fffffffe418) at libc-start.c:187 #6 0x0000000000647b59 in _start () ^^^^^^^^^^ The constructor of syncPropDefaultPeer is called and sets the default sharing mode. My expectation is that all constructors of instances in a compilation unit get called before any method in that compilation unit executes. However, I am no longer sure whether that is really guaranteed. Stroustrup C++ 10.4.9 only mentions that static instances inside a function are initialized when that function gets called, but doesn't say anything about instances inside the compilation unit. Obviously, that is the solution to the problem here. I'd still like to know whether it is required by the C++ standard. Any opinions? -------- Product: SyncEvolution Component: SyncEvolution MeeGo Release: unspecified Severity: major Priority: Medium Keywords: Status: ASSIGNED Who: [email protected] Assigned To: [email protected] Target Build: --- Flags: Changed: -------- https://bugs.meego.com/show_bug.cgi?id=19464 -- Configure bugmail: https://bugs.meego.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching someone on the CC list of the bug. _______________________________________________ Syncevolution-issues mailing list [email protected] http://lists.syncevolution.org/listinfo/syncevolution-issues
