Bennett Helm wrote: > On Nov 14, 2006, at 1:41 PM, Georg Baum wrote: > >> Am Dienstag, 14. November 2006 19:08 schrieb Peter Kümmel: >>> Peter Kümmel wrote: >>>> Bennett Helm wrote: >>>>> Recipe for another crash (1.5 on Mac). >>>>> >>>>> Create a document with a bibliography that specifies two .bib files. >>>>> Select View > View Source, and check the "Display complete source" >>>>> option. Back in the main LyX window, start typing text in a standard >>>>> paragraph. After a few keystrokes, LyX crashes. >>>>> >>>>> As you begin typing, looking at the LaTeX Source window reveals that >> the >>>>> names of the files listed in \Bibliography change as you type. >>>>> >>>>> Here's the backtrace. >>>>> >>>>> Bennett >>>>> >>>> >>>> Similar here on Windows: >>>> >>>> 1. new document >>>> 2. insert List/TOC->Bibtex Bilio >>>> 3. add a biblio >>>> 4. view source ->crash >>>> >>> >>> >>> This fixes the crash here: >>> >>> Index: insets/insetbibtex.C >>> =================================================================== >>> --- insets/insetbibtex.C (revision 15916) >>> +++ insets/insetbibtex.C (working copy) >>> @@ -155,7 +155,8 @@ >>> typedef boost::tokenizer<Separator> Tokenizer; >>> >>> Separator const separator(","); >>> - Tokenizer const tokens(to_utf8(getParam("bibfiles")), >>> separator); >>> + const string param(to_utf8(getParam("bibfiles"))); >>> + Tokenizer const tokens(param, separator); >>> Tokenizer::const_iterator const begin = tokens.begin(); >>> Tokenizer::const_iterator const end = tokens.end(); >>> >>> >>> But why is it needed? >>> Why is the string deconstructed while passed as parameter? >>> >>> std::string const to_utf8(docstring const & ucs4) >>> { >>> std::vector<char> const utf8 = >>> ucs4_to_utf8(ucs4.data(), ucs4.size()); >>> return std::string(utf8.begin(), utf8.end()); >>> } >>> >>> Isn't this deep copying? >> >> Yes, it is. >> >>> There could be hundreds of such constructs in LyX. >>> This is really a ugly bug. >> >> Indeed. Does the attached patch work for you? If yes I would prefer that, >> since we should convert all filename stuff to docstring eventually and >> use >> one place where that is converted to the encoding that is actually usesd >> by the file system. I don't get the crash with or without the patch. > > It seems to make it somewhat harder to trigger (more typing is required > before the crash), but I still get the crash. > > I'm attaching the new backtrace, though at a quick glance it looks the > same as the old one. > > Bennett
Does this patch help? (revert before applying) > > terminate called after throwing an instance of > 'boost::filesystem::basic_filesystem_error<boost::filesystem::basic_path<std::string, > boost::filesystem::path_traits> >' > what(): boost::filesystem::exists > > Program received signal SIGABRT, Aborted. > 0x9003d1dc in kill () > (gdb) bt > #0 0x9003d1dc in kill () > #1 0x9010f2af in raise () > #2 0x9010de02 in abort () > #3 0x90b4039c in __gnu_cxx::__verbose_terminate_handler () > #4 0x90b3e602 in __gxx_personality_v0 () > #5 0x90b3e640 in std::terminate () > #6 0x90b3e754 in __cxa_throw () > #7 0x00653f32 in > boost::throw_exception<boost::filesystem::basic_filesystem_error<boost::filesystem::basic_path<std::string, > boost::filesystem::path_traits> > > ([EMAIL PROTECTED]) at > ../boost/boost/throw_exception.hpp:39 > #8 0x006563dd in > boost::filesystem::exists<boost::filesystem::basic_path<std::string, > boost::filesystem::path_traits> > ([EMAIL PROTECTED]) at > ../boost/boost/filesystem/operations.hpp:281 > #9 0x000fabac in lyx::support::isFileReadable ([EMAIL PROTECTED]) at > ../../boost/boost/filesystem/operations.hpp:600 > #10 0x000f48f3 in lyx::(anonymous namespace)::normalize_name > ([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED]) at insetbibtex.C:120 > #11 0x000f5dce in lyx::InsetBibtex::latex (this=0x1e8f9e60, > [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]) at > insetbibtex.C:166 > #12 0x000b6607 in lyx::Paragraph::Pimpl::simpleTeXSpecialChars > (this=0x1e88bed0, [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED], [EMAIL PROTECTED], c=2097153) at paragraph_pimpl.C:519 > #13 0x000b32e5 in lyx::Paragraph::simpleTeXOnePar (this=0x1e80b808, > [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]) at > paragraph.C:1029 > #14 0x000a85ed in lyx::(anonymous namespace)::TeXOnePar > ([EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED]) at output_latex.C:373 > #15 0x000ab400 in lyx::latexParagraphs ([EMAIL PROTECTED], > [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > [EMAIL PROTECTED], [EMAIL PROTECTED]) at output_latex.C:618 > #16 0x00030fac in lyx::Buffer::writeLaTeXSource (this=0x1e855830, > [EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED], > output_preamble=true, output_body=true) at buffer.C:970 > #17 0x00033fca in lyx::Buffer::getSourceCode (this=0x1e855830, > [EMAIL PROTECTED], par_begin=2, par_end=3, full_source=1) at buffer.C:1668 > #18 0x00372b20 in lyx::frontend::ControlViewSource::updateContent > (this=0x1e8b30b0, fullSource=true) at ControlViewSource.C:56 > #19 0x0035f4ab in lyx::frontend::QViewSource::update_source > (this=0x1f2058f0) at QViewSource.C:107 > #20 0x0035f5f6 in lyx::frontend::QViewSource::update_contents > (this=0x1f2058f0) at QViewSource.C:115 > #21 0x0089351a in > lyx::frontend::QView<lyx::frontend::QViewSourceDialog>::update > (this=0x1f2058f0) at QDialogView.h:132 > #22 0x0016f4f9 in lyx::Dialogs::checkStatus (this=0x129652d0) at > Dialogs.C:248 > #23 0x00164b4b in lyx::LyXView::updateToolbars (this=0x12964734) at > LyXView.C:304 > #24 0x000870cd in lyx::LyXFunc::dispatch (this=0x12917ac0, > [EMAIL PROTECTED]) at lyxfunc.C:1742 > #25 0x000881c6 in lyx::LyXFunc::processKeySym (this=0x12917ac0, > [EMAIL PROTECTED], state=none) at lyxfunc.C:336 > #26 0x001d1bc5 in lyx::frontend::WorkArea::processKeySym > (this=0x12965994, [EMAIL PROTECTED], state=none) at WorkArea.C:175 > #27 0x003250d9 in lyx::frontend::GuiWorkArea::keyPressEvent > (this=0x12965980, e=0xbfffeccc) at GuiWorkArea.C:443 > #28 0x0020a2a2 in QWidget::event () at QLImage.C:172 > #29 0x0025f1f4 in QFrame::event () at Dialogs.C:320 > #30 0x00246d9b in QAbstractScrollArea::event () at Dialogs.C:320 > #31 0x00181fc0 in QApplicationPrivate::notify_helper () at > insetspecialchar.C:65 > #32 0x001881be in QApplication::notify () at insetspecialchar.C:65 > #33 0x001e1a80 in qt_sendSpontaneousEvent () at forkedcontr.C:223 > #34 0x002ee836 in QKeyMapper::sendKeyEvent () at InsetMathString.C:33 > #35 0x002efd1e in QKeyMapperPrivate::translateKeyEvent () at > InsetMathString.C:33 > #36 0x001e44e2 in QApplicationPrivate::globalEventProcessor () at > forkedcontr.C:223 > #37 0x92dc686b in DispatchEventToHandlers () > #38 0x92dc5f10 in SendEventToEventTargetInternal () > #39 0x92dc5dd5 in SendEventToEventTargetWithOptions () > #40 0x92dcd858 in ToolboxEventDispatcherHandler () > #41 0x92dc6c22 in DispatchEventToHandlers () > #42 0x92dc5f10 in SendEventToEventTargetInternal () > #43 0x92dcd1f0 in SendEventToEventTarget () > #44 0x001dccac in qt_mac_send_event () at forkedcontr.C:223 > #45 0x002f7584 in QEventDispatcherMac::processEvents () at > InsetMathString.C:33 > #46 0x0031243a in QEventLoop::processEvents () at InsetMathString.C:33 > #47 0x00312618 in QEventLoop::exec () at InsetMathString.C:33 > #48 0x001e9967 in QCoreApplication::exec () at forkedcontr.C:223 > #49 0x00074dfa in lyx::LyX::priv_exec (this=0x12917ab0, > [EMAIL PROTECTED], argv=0xbffff9e4) at lyx_main.C:350 > #50 0x00074f56 in lyx::LyX::exec ([EMAIL PROTECTED], argv=0xbffff9e4) at > lyx_main.C:171 > #51 0x00002bbd in main (argc=1, argv=0xbffff9e4) at main.C:46 > -- Peter Kümmel
Index: src/insets/insetbibtex.C =================================================================== --- src/insets/insetbibtex.C (revision 15916) +++ src/insets/insetbibtex.C (working copy) @@ -151,19 +151,21 @@ // use such filenames.) // Otherwise, store the (maybe absolute) path to the original, // unmangled database name. - typedef boost::char_separator<char> Separator; - typedef boost::tokenizer<Separator> Tokenizer; + typedef boost::char_separator<char_type> Separator; + typedef boost::tokenizer<Separator, docstring::const_iterator, docstring> Tokenizer; - Separator const separator(","); - Tokenizer const tokens(to_utf8(getParam("bibfiles")), separator); + Separator const separator(from_ascii(",").c_str()); + Tokenizer const tokens(getParam("bibfiles"), separator); Tokenizer::const_iterator const begin = tokens.begin(); Tokenizer::const_iterator const end = tokens.end(); - std::ostringstream dbs; + odocstringstream dbs; for (Tokenizer::const_iterator it = begin; it != end; ++it) { - string const input = trim(*it); + docstring const input = trim(*it); + // FIXME UNICODE + string utf8input(to_utf8(input)); string database = - normalize_name(buffer, runparams, input, ".bib"); + normalize_name(buffer, runparams, utf8input, ".bib"); string const in_file = database + ".bib"; if (!runparams.inComment && !runparams.dryrun && !runparams.nice && @@ -184,10 +186,10 @@ if (it != begin) dbs << ','; - dbs << latex_path(database); + // FIXME UNICODE + dbs << from_utf8(latex_path(database)); } - // FIXME UNICODE - docstring const db_out = from_utf8(dbs.str()); + docstring const db_out = dbs.str(); // Post this warning only once. static bool warned_about_spaces = false;