Peter Kümmel wrote: > Bennett Helm wrote: >> On Nov 18, 2006, at 12:50 PM, Abdelrazak Younes wrote: >> >>> Georg Baum wrote: >>>> Am Freitag, 17. November 2006 21:06 schrieb Peter Kümmel: >>>>> Georg Baum wrote: >>>>>> Peter Kümmel wrote: >>>>>> >>>>>>> My idea was to use some Loki code for singletons and global static >>>> data. >>>>>> I don't know Loki, so maybe I am missing something here, but I believe >>>> that >>>>>> we already have everything needed. >>>>> Yes, we have C++. >>>> What do you mean? I believe that Loki is a well designed library of >>>> good quality, but I do not see the problem that it might solve for >>>> us. Our problem is that some global static objects are destructed too >>>> late, because they need other objects. This problem can be solved >>>> IMHO by putting these objects into the LyX singleton, so I don't see >>>> why we need any additional code. >>> This is what I did. Hopefully, all crash-on-exit problems on windows >>> and Mac should be solved now. >> Unfortunately, not. Quitting LyX on Mac gives: >> >> Program received signal EXC_BAD_ACCESS, Could not access memory. >> Reason: KERN_PROTECTION_FAILURE at address: 0x00000040 >> 0x0008e0a5 in lyx::LyXServerSocket::~LyXServerSocket (this=0xe3c15f0) at >> lyxsocket.C:80 >> 80 theApp->unregisterSocketCallback(fd_); >> (gdb) bt >> #0 0x0008e0a5 in lyx::LyXServerSocket::~LyXServerSocket >> (this=0xe3c15f0) at lyxsocket.C:80 >> #1 0x00664e9e in boost::checked_delete<lyx::LyXServerSocket> >> (x=0xe3c15f0) at ../boost/boost/checked_delete.hpp:34 >> #2 0x00065f61 in lyx::LyX::quit (this=0xbffff960) at lyx_main.C:418 >> #3 0x00066006 in lyx::LyX::~LyX (this=0xbffff960) at lyx_main.C:176 >> #4 0x00002995 in main (argc=1, argv=0xbffff9ec) at main.C:48 >> >> Bennett > > void LyX::quit() > { > lyxerr[Debug::INFO] << "Running QuitLyX." << endl; > > prepareExit(); > > if (use_gui) { > pimpl_->session_->writeFile(); > pimpl_->lyx_server_.reset(); > pimpl_->lyx_socket_.reset(); > pimpl_->application_->exit(0); > } > } > > Could it be that pimpl_->lyx_socket_.reset() does not delete LyXServerSocket? > Maybe when there is somewhere a copy of the smart pointer. > Then after pimpl_->application_->exit(0) theApp is invalid.
Boost doc: The object pointed to is guaranteed to be deleted, either on destruction of the scoped_ptr, or via an explicit reset. Then LyXServerSocket is 'guaranteed' deleted before theApp becomes invalid. Is this bug really due to the "destruction order fiasco"? Peter